Skip to content

Commit

Permalink
v13.1.9 final: fix fields.Mod in calcChanges
Browse files Browse the repository at this point in the history
- `isNotWeapon` attribute for WeaponsList object
- Rage damage bonus now only if using Str
- Fix location column visibility on Colourful
  • Loading branch information
morepurplemorebetter committed Sep 8, 2023
1 parent f71400a commit a591428
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 48 deletions.
6 changes: 2 additions & 4 deletions _functions/Functions1.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ function ToggleWhiteout(toggle) {

// Show/hide the whiteout field on page 3 depending on the state of the layers
if (!typePF && !minVer) {
if (CurrentVars.vislayers == undefined) CurrentVars.vislayers = ["rules", "equipment"];
if (nowWhat) {
if (CurrentVars.vislayers[0] === "notes") Show("Extra.Notes Whiteout");
if (CurrentVars.vislayers[1] === "equipment") Show("Extra.Other Holdings Whiteout");
Expand Down Expand Up @@ -669,7 +668,7 @@ function LayerVisibilityOptions(showMenu, useSelect) {
if (typePF || minVer) return; //don't do this function in the Printer-Friendly version

var isReset = false;
if (CurrentVars.vislayers == undefined) {
if (CurrentVars.vislayers === undefined) {
isReset = !showMenu;
CurrentVars.vislayers = ["rules", "equipment"];
}
Expand Down Expand Up @@ -706,7 +705,6 @@ function LayerVisibilityOptions(showMenu, useSelect) {
var thermoTxt = thermoM("Show the 3rd page " + selection[0] + " and " + selection[1] + " sections...");
calcStop();

Value("Extra.Layers Remember", selection);
var LNotesFlds = [
"Text.Header.Notes.Left",
"Extra.Notes",
Expand Down Expand Up @@ -9326,7 +9324,7 @@ function HideInvLocationColumn(type, currentstate) {
RowName.rect = gRect; // Update the value of b.rect
RowName.value = RowName.value; //re-input the value as to counteract the changing of font
}
if (typePF || (type === "Extra.Gear " && What("Extra.Layers Remember").split(",")[1] === "equipment") || type === "Adventuring Gear ") { //only show things on the third page, if the extra equipment section is visible
if (typePF || (type === "Extra.Gear " && CurrentVars.vislayers[1] === "equipment") || type === "Adventuring Gear ") { //only show things on the third page, if the extra equipment section is visible
tDoc[HideShow](type + "Location");
if (!currentstate && type === "Adventuring Gear " && What("Adventuring Gear Remember") === false) {
Hide("Adventuring Gear Location.Row " + FieldNumbers.gearMIrow);
Expand Down
30 changes: 24 additions & 6 deletions _functions/Functions2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ function RunCreatureCallback(sPrefix, sType, bAdd, fOverride, sOverrideNm) {
var sEvalType = (/companion/i).test(sType) ? "companionCallback" : "creatureCallback";
var aPrefix = (/all/i).test(sPrefix) ? What("Template.extras.AScomp").split(",").splice(1) : [sPrefix];
if (bAdd === undefined) bAdd = true;
var prefix, oCrea, sCompType, sEval;
var prefix, oCrea, sCompType;
var doEval = function(evalThing, evalName) {
if (!evalThing) return;
try {
Expand Down Expand Up @@ -5643,7 +5643,7 @@ function ApplyWeapon(inputText, fldName, isReCalc, onlyProf, forceRedo) {

//add mod
var StrDex = What(QI ? "Str" : prefix + "Comp.Use.Ability.Str.Score") < What(QI ? "Dex" : prefix + "Comp.Use.Ability.Dex.Score") ? 2 : 1;
fields.Mod = isReCalc && !theWea.ability ? What(fldBase + "Mod") :
fields.Mod = isReCalc && !theWea.ability ? tDoc.getField(fldBase + "Mod").currentValueIndices :
(/finesse/i).test(theWea.description) ? StrDex : theWea.ability;

//change mod if this is concerning a spell/cantrip
Expand Down Expand Up @@ -5680,7 +5680,7 @@ function ApplyWeapon(inputText, fldName, isReCalc, onlyProf, forceRedo) {
var WeaponText = inputText + " " + fields.Description;
var isDC = (/dc/i).test(fields.To_Hit_Bonus);
var isSpell = thisWeapon[3] || (theWea && (/cantrip|spell/i).test(theWea.type)) || (!theWea && (/\b(cantrip|spell)\b/i).test(WeaponText)) ? true : false;
var isWeapon = !isSpell || (isSpell && theWea && !(/cantrip|spell/i).test(theWea.type));
var isWeapon = theWea && theWea.isNotWeapon ? false : !isSpell || (isSpell && theWea && !(/cantrip|spell/i).test(theWea.type));
var isMeleeWeapon = isWeapon && (/melee/i).test(fields.Range);
var isRangedWeapon = isWeapon && (/^(?!.*melee).*\d+.*$/i).test(fields.Range);
var isNaturalWeapon = isWeapon && theWea && (/natural/i).test(theWea.type);
Expand Down Expand Up @@ -5798,7 +5798,7 @@ function CalcAttackDmgHit(fldName) {
var fldBaseBT = prefix + "BlueText." + Q + "Attack." + fldNmbr + ".";
var fields = {
Proficiency : tDoc.getField(fldBase + "Proficiency").isBoxChecked(0),
Mod : What(fldBase + "Mod"),
Mod : tDoc.getField(fldBase + "Mod").currentValueIndices,
Range : What(fldBase + "Range"),
Damage_Type : What(fldBase + "Damage Type"),
Description : What(fldBase + "Description"),
Expand Down Expand Up @@ -5834,7 +5834,7 @@ function CalcAttackDmgHit(fldName) {
prof : !fields.Proficiency ? 0 : (QI ? (tDoc.getField("Proficiency Bonus Dice").isBoxChecked(0) ? 0 : Number(How("Proficiency Bonus"))) : (tDoc.getField(prefix + "BlueText.Comp.Use.Proficiency Bonus Dice").isBoxChecked(0) ? 0 : What(prefix + "Comp.Use.Proficiency Bonus"))),
die : fields.Damage_Die,
modToDmg : thisWeapon[2],
mod : !fields.Mod || fields.Mod === "empty" ? 0 : What(prefix + fields.Mod),
mod : getAbiModValue(fields.Mod, prefix),
magic : thisWeapon[1],
bHit : fields.To_Hit_Bonus,
bDmg : fields.Damage_Bonus,
Expand All @@ -5847,7 +5847,7 @@ function CalcAttackDmgHit(fldName) {

// Gather some information on the weapon
var isSpell = thisWeapon[3] || (theWea && (/cantrip|spell/i).test(theWea.type)) || (!theWea && (/\b(cantrip|spell)\b/i).test(WeaponText)) ? true : false;
var isWeapon = !isSpell || (isSpell && theWea && !(/cantrip|spell/i).test(theWea.type));
var isWeapon = theWea && theWea.isNotWeapon ? false : !isSpell || (isSpell && theWea && !(/cantrip|spell/i).test(theWea.type));
var isMeleeWeapon = isWeapon && (/melee/i).test(fields.Range);
var isRangedWeapon = isWeapon && (/^(?!.*melee).*\d+.*$/i).test(fields.Range);
var isNaturalWeapon = isWeapon && theWea && (/natural/i).test(theWea.type);
Expand Down Expand Up @@ -6153,6 +6153,24 @@ function FunctionIsNotAvailable() {
});
};

// get the string for the modifier field
// this can be based on index number Str = 1, Dex = 2, etc.
// or on the abbreviation string "Str", "Dex", etc.
// wildshapeNo is the index of the monser on wild shape page, starting with 1
function getAbiModValue(ability, prefix, wildshapeNo) {
var mod = 0;
var abi = !isNaN(ability) && ability > 0 && ability <= AbilityScores.abbreviations.length ? AbilityScores.abbreviations[ability - 1] : AbilityScores.abbreviations.indexOf(ability) !== -1 ? ability : "error";
if (abi === "error") return mod;
if (!prefix) {
mod = Number(What(abi + " Mod"));
} else if (wildshapeNo) {
mod = Number(What(prefix + "Wildshape." + wildshapeNo + ".Ability." + abi + ".Mod"));
} else {
mod = Number(What(prefix + "Comp.Use.Ability." + abi + ".Mod"));
}
return mod;
}

// a way to eval the content of a modifier field; prefix === true if it is the character (true) or a string if it is for a companion page (the prefix of the companion page); if isSpecial === "test" it will output undefined if an error occurs; if isSpecial is a number it will look for that entry on the Wild Shape page with the corresponding prefix variable as a prefix;
function EvalBonus(input, prefix, isSpecial) {
if (!input) {
Expand Down
2 changes: 1 addition & 1 deletion _functions/FunctionsSpells.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ function CreateSpellList(inputObject, toDisplay, extraArray, returnOrdered, objN
try {
evalThing(inputObject, objName, objType);
} catch (error) {
var eText = "The custom calcChange.spellList function '" + evalName + "' produced an error! It will be removed from the sheet for now, but please contact the author of the feature to have this issue corrected:\n " + error;
var eText = "The custom calcChanges.spellList function '" + evalName + "' produced an error! It will be removed from the sheet for now, but please contact the author of the feature to have this issue corrected:\n " + error;
for (var e in error) eText += "\n " + e + ": " + error[e];
console.println(eText);
console.show();
Expand Down
2 changes: 1 addition & 1 deletion _variables/Lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ var CurrentCasters = {};
var CurrentSources = {firstTime : true, globalExcl : [], globalKnown : []};
var CurrentEvals = {};
var CurrentScriptFiles = {};
var CurrentVars = { manual : {} };
var CurrentVars = { manual : {}, vislayers : ["rules", "equipment"] };
var UpdateSpellSheets = {};
var CurrentFeatureChoices = {};
var CurrentStats = {};
Expand Down
10 changes: 5 additions & 5 deletions _variables/ListsClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var Base_ClassList = {
source : [["SRD", 8], ["P", 48]],
minlevel : 1,
description : desc([
"Start/end as bonus action; add damage to melee weapons that use Str; lasts 1 min",
"Start/end as bonus action; bonus damage to melee weapon attacks using Str; lasts 1 min",
"Adv. on Strength checks/saves (not attacks); resistance to bludgeoning/piercing/slashing",
"Stops if I end turn without attacking or taking damage since last turn, or unconscious"
]),
Expand All @@ -121,11 +121,11 @@ var Base_ClassList = {
calcChanges : {
atkCalc : [
function (fields, v, output) {
if (v.isMeleeWeapon && classes.known.barbarian && classes.known.barbarian.level && (/\brage\b/i).test(v.WeaponTextName)) {
if (v.isMeleeWeapon && fields.Mod === 1 && classes.known.barbarian && classes.known.barbarian.level && /\brage\b/i.test(v.WeaponTextName)) {
output.extraDmg += classes.known.barbarian.level < 9 ? 2 : classes.known.barbarian.level < 16 ? 3 : 4;
}
},
"If I include the word 'Rage' in a melee weapon's name, the calculation will add my Rage's bonus damage to it."
"If I include the word 'Rage' in a melee weapon's name that uses Strength, the calculation will add my Rage's bonus damage to it. Be aware that if the weapon is used to make a ranged attack, the rage bonus damage shouldn't be added (e.g. when using a thrown weapon)."
]
}
},
Expand Down Expand Up @@ -541,7 +541,7 @@ var Base_ClassList = {
name : "Druidic",
source : [["SRD", 19], ["P", 66]],
minlevel : 1,
description : desc("I know Druidic; Hidden messages with it can only be understood by who know Druidic"),
description : desc("I know Druidic; Hidden messages with it are only understood by those who know Druidic"),
languageProfs : ["Druidic"]
},
"spellcasting" : {
Expand Down Expand Up @@ -782,7 +782,7 @@ var Base_ClassList = {
if (isNaN(curDie) || curDie < aMonkDie) {
fields.Damage_Die = '1d' + aMonkDie;
};
if (fields.Mod == 1 || fields.Mod == 2 || What(AbilityScores.abbreviations[fields.Mod - 1] + " Mod") < What(AbilityScores.abbreviations[v.StrDex - 1] + " Mod")) {
if (fields.Mod === 1 || fields.Mod === 2 || What(AbilityScores.abbreviations[fields.Mod - 1] + " Mod") < What(AbilityScores.abbreviations[v.StrDex - 1] + " Mod")) {
fields.Mod = v.StrDex;
}
};
Expand Down
12 changes: 8 additions & 4 deletions _variables/ListsGear.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ var Base_WeaponsList = {
weight : 1,
description : "Target +1d4 damage at the start of each of its turn; Can end it as an action with a DC 10 Dex check",
abilitytodamage : false,
ammo : "alchemist fire"
ammo : "alchemist fire",
isNotWeapon : true
},
"vials of acid" : {
regExpSearch : /^(?=.*vial)(?=.*acid).*$/i,
Expand All @@ -689,7 +690,8 @@ var Base_WeaponsList = {
weight : 1,
description : "",
abilitytodamage : false,
ammo : "vials of acid"
ammo : "vials of acid",
isNotWeapon : true
},
"holy water" : {
regExpSearch : /^(?=.*holy)(?=.*water).*$/i,
Expand All @@ -703,7 +705,8 @@ var Base_WeaponsList = {
weight : 1,
description : "Only does damage against fiends and undead; Comes in flasks",
abilitytodamage : false,
ammo : "holy water"
ammo : "holy water",
isNotWeapon : true
},
"burning torch" : {
regExpSearch : /^(?=.*torch)(?=.*burning).*$/i,
Expand All @@ -716,7 +719,8 @@ var Base_WeaponsList = {
range : "Melee",
weight : 1,
description : "Only does damage while burning",
abilitytodamage : false
abilitytodamage : false,
isNotWeapon : true
},
// Cantrips
"spell attack" : {
Expand Down
Loading

0 comments on commit a591428

Please sign in to comment.