Skip to content

Commit a591428

Browse files
v13.1.9 final: fix fields.Mod in calcChanges
- `isNotWeapon` attribute for WeaponsList object - Rage damage bonus now only if using Str - Fix location column visibility on Colourful
1 parent f71400a commit a591428

File tree

9 files changed

+99
-48
lines changed

9 files changed

+99
-48
lines changed

_functions/Functions1.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ function ToggleWhiteout(toggle) {
387387

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

671670
var isReset = false;
672-
if (CurrentVars.vislayers == undefined) {
671+
if (CurrentVars.vislayers === undefined) {
673672
isReset = !showMenu;
674673
CurrentVars.vislayers = ["rules", "equipment"];
675674
}
@@ -706,7 +705,6 @@ function LayerVisibilityOptions(showMenu, useSelect) {
706705
var thermoTxt = thermoM("Show the 3rd page " + selection[0] + " and " + selection[1] + " sections...");
707706
calcStop();
708707

709-
Value("Extra.Layers Remember", selection);
710708
var LNotesFlds = [
711709
"Text.Header.Notes.Left",
712710
"Extra.Notes",
@@ -9326,7 +9324,7 @@ function HideInvLocationColumn(type, currentstate) {
93269324
RowName.rect = gRect; // Update the value of b.rect
93279325
RowName.value = RowName.value; //re-input the value as to counteract the changing of font
93289326
}
9329-
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
9327+
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
93309328
tDoc[HideShow](type + "Location");
93319329
if (!currentstate && type === "Adventuring Gear " && What("Adventuring Gear Remember") === false) {
93329330
Hide("Adventuring Gear Location.Row " + FieldNumbers.gearMIrow);

_functions/Functions2.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ function RunCreatureCallback(sPrefix, sType, bAdd, fOverride, sOverrideNm) {
10851085
var sEvalType = (/companion/i).test(sType) ? "companionCallback" : "creatureCallback";
10861086
var aPrefix = (/all/i).test(sPrefix) ? What("Template.extras.AScomp").split(",").splice(1) : [sPrefix];
10871087
if (bAdd === undefined) bAdd = true;
1088-
var prefix, oCrea, sCompType, sEval;
1088+
var prefix, oCrea, sCompType;
10891089
var doEval = function(evalThing, evalName) {
10901090
if (!evalThing) return;
10911091
try {
@@ -5643,7 +5643,7 @@ function ApplyWeapon(inputText, fldName, isReCalc, onlyProf, forceRedo) {
56435643

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

56495649
//change mod if this is concerning a spell/cantrip
@@ -5680,7 +5680,7 @@ function ApplyWeapon(inputText, fldName, isReCalc, onlyProf, forceRedo) {
56805680
var WeaponText = inputText + " " + fields.Description;
56815681
var isDC = (/dc/i).test(fields.To_Hit_Bonus);
56825682
var isSpell = thisWeapon[3] || (theWea && (/cantrip|spell/i).test(theWea.type)) || (!theWea && (/\b(cantrip|spell)\b/i).test(WeaponText)) ? true : false;
5683-
var isWeapon = !isSpell || (isSpell && theWea && !(/cantrip|spell/i).test(theWea.type));
5683+
var isWeapon = theWea && theWea.isNotWeapon ? false : !isSpell || (isSpell && theWea && !(/cantrip|spell/i).test(theWea.type));
56845684
var isMeleeWeapon = isWeapon && (/melee/i).test(fields.Range);
56855685
var isRangedWeapon = isWeapon && (/^(?!.*melee).*\d+.*$/i).test(fields.Range);
56865686
var isNaturalWeapon = isWeapon && theWea && (/natural/i).test(theWea.type);
@@ -5798,7 +5798,7 @@ function CalcAttackDmgHit(fldName) {
57985798
var fldBaseBT = prefix + "BlueText." + Q + "Attack." + fldNmbr + ".";
57995799
var fields = {
58005800
Proficiency : tDoc.getField(fldBase + "Proficiency").isBoxChecked(0),
5801-
Mod : What(fldBase + "Mod"),
5801+
Mod : tDoc.getField(fldBase + "Mod").currentValueIndices,
58025802
Range : What(fldBase + "Range"),
58035803
Damage_Type : What(fldBase + "Damage Type"),
58045804
Description : What(fldBase + "Description"),
@@ -5834,7 +5834,7 @@ function CalcAttackDmgHit(fldName) {
58345834
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"))),
58355835
die : fields.Damage_Die,
58365836
modToDmg : thisWeapon[2],
5837-
mod : !fields.Mod || fields.Mod === "empty" ? 0 : What(prefix + fields.Mod),
5837+
mod : getAbiModValue(fields.Mod, prefix),
58385838
magic : thisWeapon[1],
58395839
bHit : fields.To_Hit_Bonus,
58405840
bDmg : fields.Damage_Bonus,
@@ -5847,7 +5847,7 @@ function CalcAttackDmgHit(fldName) {
58475847

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

6156+
// get the string for the modifier field
6157+
// this can be based on index number Str = 1, Dex = 2, etc.
6158+
// or on the abbreviation string "Str", "Dex", etc.
6159+
// wildshapeNo is the index of the monser on wild shape page, starting with 1
6160+
function getAbiModValue(ability, prefix, wildshapeNo) {
6161+
var mod = 0;
6162+
var abi = !isNaN(ability) && ability > 0 && ability <= AbilityScores.abbreviations.length ? AbilityScores.abbreviations[ability - 1] : AbilityScores.abbreviations.indexOf(ability) !== -1 ? ability : "error";
6163+
if (abi === "error") return mod;
6164+
if (!prefix) {
6165+
mod = Number(What(abi + " Mod"));
6166+
} else if (wildshapeNo) {
6167+
mod = Number(What(prefix + "Wildshape." + wildshapeNo + ".Ability." + abi + ".Mod"));
6168+
} else {
6169+
mod = Number(What(prefix + "Comp.Use.Ability." + abi + ".Mod"));
6170+
}
6171+
return mod;
6172+
}
6173+
61566174
// 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;
61576175
function EvalBonus(input, prefix, isSpecial) {
61586176
if (!input) {

_functions/FunctionsSpells.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ function CreateSpellList(inputObject, toDisplay, extraArray, returnOrdered, objN
999999
try {
10001000
evalThing(inputObject, objName, objType);
10011001
} catch (error) {
1002-
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;
1002+
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;
10031003
for (var e in error) eText += "\n " + e + ": " + error[e];
10041004
console.println(eText);
10051005
console.show();

_variables/Lists.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ var CurrentCasters = {};
302302
var CurrentSources = {firstTime : true, globalExcl : [], globalKnown : []};
303303
var CurrentEvals = {};
304304
var CurrentScriptFiles = {};
305-
var CurrentVars = { manual : {} };
305+
var CurrentVars = { manual : {}, vislayers : ["rules", "equipment"] };
306306
var UpdateSpellSheets = {};
307307
var CurrentFeatureChoices = {};
308308
var CurrentStats = {};

_variables/ListsClasses.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ var Base_ClassList = {
106106
source : [["SRD", 8], ["P", 48]],
107107
minlevel : 1,
108108
description : desc([
109-
"Start/end as bonus action; add damage to melee weapons that use Str; lasts 1 min",
109+
"Start/end as bonus action; bonus damage to melee weapon attacks using Str; lasts 1 min",
110110
"Adv. on Strength checks/saves (not attacks); resistance to bludgeoning/piercing/slashing",
111111
"Stops if I end turn without attacking or taking damage since last turn, or unconscious"
112112
]),
@@ -121,11 +121,11 @@ var Base_ClassList = {
121121
calcChanges : {
122122
atkCalc : [
123123
function (fields, v, output) {
124-
if (v.isMeleeWeapon && classes.known.barbarian && classes.known.barbarian.level && (/\brage\b/i).test(v.WeaponTextName)) {
124+
if (v.isMeleeWeapon && fields.Mod === 1 && classes.known.barbarian && classes.known.barbarian.level && /\brage\b/i.test(v.WeaponTextName)) {
125125
output.extraDmg += classes.known.barbarian.level < 9 ? 2 : classes.known.barbarian.level < 16 ? 3 : 4;
126126
}
127127
},
128-
"If I include the word 'Rage' in a melee weapon's name, the calculation will add my Rage's bonus damage to it."
128+
"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)."
129129
]
130130
}
131131
},
@@ -541,7 +541,7 @@ var Base_ClassList = {
541541
name : "Druidic",
542542
source : [["SRD", 19], ["P", 66]],
543543
minlevel : 1,
544-
description : desc("I know Druidic; Hidden messages with it can only be understood by who know Druidic"),
544+
description : desc("I know Druidic; Hidden messages with it are only understood by those who know Druidic"),
545545
languageProfs : ["Druidic"]
546546
},
547547
"spellcasting" : {
@@ -782,7 +782,7 @@ var Base_ClassList = {
782782
if (isNaN(curDie) || curDie < aMonkDie) {
783783
fields.Damage_Die = '1d' + aMonkDie;
784784
};
785-
if (fields.Mod == 1 || fields.Mod == 2 || What(AbilityScores.abbreviations[fields.Mod - 1] + " Mod") < What(AbilityScores.abbreviations[v.StrDex - 1] + " Mod")) {
785+
if (fields.Mod === 1 || fields.Mod === 2 || What(AbilityScores.abbreviations[fields.Mod - 1] + " Mod") < What(AbilityScores.abbreviations[v.StrDex - 1] + " Mod")) {
786786
fields.Mod = v.StrDex;
787787
}
788788
};

_variables/ListsGear.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,8 @@ var Base_WeaponsList = {
675675
weight : 1,
676676
description : "Target +1d4 damage at the start of each of its turn; Can end it as an action with a DC 10 Dex check",
677677
abilitytodamage : false,
678-
ammo : "alchemist fire"
678+
ammo : "alchemist fire",
679+
isNotWeapon : true
679680
},
680681
"vials of acid" : {
681682
regExpSearch : /^(?=.*vial)(?=.*acid).*$/i,
@@ -689,7 +690,8 @@ var Base_WeaponsList = {
689690
weight : 1,
690691
description : "",
691692
abilitytodamage : false,
692-
ammo : "vials of acid"
693+
ammo : "vials of acid",
694+
isNotWeapon : true
693695
},
694696
"holy water" : {
695697
regExpSearch : /^(?=.*holy)(?=.*water).*$/i,
@@ -703,7 +705,8 @@ var Base_WeaponsList = {
703705
weight : 1,
704706
description : "Only does damage against fiends and undead; Comes in flasks",
705707
abilitytodamage : false,
706-
ammo : "holy water"
708+
ammo : "holy water",
709+
isNotWeapon : true
707710
},
708711
"burning torch" : {
709712
regExpSearch : /^(?=.*torch)(?=.*burning).*$/i,
@@ -716,7 +719,8 @@ var Base_WeaponsList = {
716719
range : "Melee",
717720
weight : 1,
718721
description : "Only does damage while burning",
719-
abilitytodamage : false
722+
abilitytodamage : false,
723+
isNotWeapon : true
720724
},
721725
// Cantrips
722726
"spell attack" : {

0 commit comments

Comments
 (0)