Skip to content

Commit

Permalink
v13.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
morepurplemorebetter committed Aug 16, 2022
1 parent 34282f0 commit 60753cf
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 27 deletions.
47 changes: 31 additions & 16 deletions _functions/Functions1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,18 @@ function FindRace(inputracetxt, novardialog, aOldRace) {
var bSkipDialogAndForce = inputracetxt && IsNotImport ? undefined : CurrentVars.oldRaceAmendRemember ? true : false;
AmendOldToNewRace(CurrentRace.useFromPreviousRace, bSkipDialogAndForce);
}
// if set, apply some generic defaults (age/height/weight/scores/languages) if nothing was set for those attributes. These defaults were added with the introduction of VRGtR
if (CurrentRace.scoresGeneric) {
if (!CurrentRace.scores && !CurrentRace.scorestxt) {
// No fixed stat increases, so list the generic one
CurrentRace.scorestxt = "+2 to one ability score and +1 to a different score, -or- +1 to three different scores";
}
var genericHeightWeight = " vary in size. If you'd like to determine your character's height or weight randomly, consult the Random Height and Weight table in the PHB, and choose the row in the table that best represents the build you imagine for your character.";
if (!CurrentRace.height) CurrentRace.height = genericHeightWeight;
if (!CurrentRace.weight) CurrentRace.weight = genericHeightWeight;
if (!CurrentRace.age) CurrentRace.age = " typically live to be around 100 years old";
if (!CurrentRace.languageProfs) CurrentRace.languageProfs = ["Common", 1];
}
}

// set the current race level when loading the sheet
Expand All @@ -2473,6 +2485,7 @@ function ApplyRace(inputracetxt, novardialog) {

var newRace = ParseRace(inputracetxt);
var oldRace = [CurrentRace.known, CurrentRace.variant];
var isMetric = What("Unit System") === "metric";
if (newRace[0] !== oldRace[0] || newRace[1] !== oldRace[1]) {
if (CurrentRace.known) {// remove the old race if one was detected
thermoTxt = thermoM("Removing the " + CurrentRace.name + " features...", false); //change the progress dialog text
Expand All @@ -2497,18 +2510,18 @@ function ApplyRace(inputracetxt, novardialog) {
thermoM(1/10); //increment the progress dialog's progress

// Add race height
var theHeight = What("Unit System") === "metric" && CurrentRace.heightMetric ? CurrentRace.heightMetric : CurrentRace.height;
AddTooltip("Height", CurrentRace.plural + theHeight);
var theHeight = (isMetric || !CurrentRace.height) && CurrentRace.heightMetric ? CurrentRace.heightMetric : CurrentRace.height;
if (theHeight) AddTooltip("Height", CurrentRace.plural + theHeight);
// Add race weight
var theWeight = What("Unit System") === "metric" ? CurrentRace.weightMetric : CurrentRace.weight;
AddTooltip("Weight", CurrentRace.plural + theWeight);
var theWeight = (isMetric || !CurrentRace.weight) && CurrentRace.weightMetric ? CurrentRace.weightMetric : CurrentRace.weight;
if (theWeight) AddTooltip("Weight", CurrentRace.plural + theWeight);
// Add race age
AddTooltip("Age", CurrentRace.plural + CurrentRace.age);
// Add race size
SetCreatureSize(false, [inputracetxt, CurrentRace.plural], CurrentRace.size);
// Add racial traits
var tempString = stringSource(CurrentRace, "full,page", CurrentRace.name + " is found in ", ".");
var theTraits = What("Unit System") === "imperial" ? CurrentRace.trait : ConvertToMetric(CurrentRace.trait, 0.5);
var theTraits = !isMetric ? CurrentRace.trait : ConvertToMetric(CurrentRace.trait, 0.5);
Value("Racial Traits", theTraits, tempString);

thermoM(2/6); //increment the progress dialog's progress
Expand Down Expand Up @@ -4255,11 +4268,11 @@ function RemoveString(field, toremove, newline) {
var thestring = toremove.replace(/\n/g, "\r");
var regExString = thestring.RegEscape();
var thefield = tDoc.getField(field);
if (!thefield) return;
if (!thefield || !thefield.value) return;
var stringsArray, regExStringsArray;
if (newline === false) {
stringsArray = [thestring];
regExStringsArray = [regExString];
if (newline === false || typeof newline === "string") {
stringsArray = [newline + thestring, thestring];
regExStringsArray = [(newline + thestring).RegEscape(), regExString];
} else {
stringsArray = [
thestring + "\r",
Expand Down Expand Up @@ -4440,16 +4453,21 @@ function CalcAllSkills(isCompPage) {
// ability score modifier
setVals[setFld] = mod[theAbi];
var addProf = 0;
// modifier field
var modFldVal = What(isInit && !pr ? "Init Bonus" : isInit && pr ? pr + "Comp.Use.Combat.Init.Bonus" : !pr ? setFld + " Bonus" : pr + "BlueText.Comp.Use.Skills." + skFld + ".Bonus");
var modFldHasProf = !pr && /([^-]|^)Prof/i.test(modFldVal);
setVals[setFld] += EvalBonus(modFldVal, !pr ? true : pr);
// proficiency bonus
// Do not add Remarkable Athlete or Jack of All Trades if "Prof" is added as a bonus, because of the literal wording of those features
if (isInit) {
if (!pr) setVals[setFld] += remAth ? Math.ceil(profB / 2) : jackOf ? Math.floor(profB / 2) : 0;
if (!pr && !modFldHasProf) setVals[setFld] += remAth ? Math.ceil(profB / 2) : jackOf ? Math.floor(profB / 2) : 0;
} else if ((doPass || !profDie) && !pr) {
if (tDoc.getField(setFld + " Prof").isBoxChecked(0)) {
addProf = profB;
if (tDoc.getField(setFld + " Exp").isBoxChecked(0)) addProf += profB;
} else if (remAth && (/^(Str|Dex|Con)$/).test(theAbi)) {
} else if (remAth && !modFldHasProf && (/^(Str|Dex|Con)$/).test(theAbi)) {
addProf = Math.ceil(profB / 2);
} else if (jackOf) {
} else if (jackOf && !modFldHasProf) {
addProf = Math.floor(profB / 2);
}
} else if ((doPass || !profDie) && typePF) {
Expand All @@ -4466,9 +4484,6 @@ function CalcAllSkills(isCompPage) {
}
}
if (!profDie) setVals[setFld] += addProf;
// modifier field
var modFld = isInit && !pr ? "Init Bonus" : isInit && pr ? pr + "Comp.Use.Combat.Init.Bonus" : !pr ? setFld + " Bonus" : pr + "BlueText.Comp.Use.Skills." + skFld + ".Bonus";
setVals[setFld] += EvalBonus(What(modFld), !pr ? true : pr);
// all skill bonus
if (!isInit) setVals[setFld] += allBonus;
// passive perception
Expand Down Expand Up @@ -6631,7 +6646,7 @@ function CalcAbilityDC() {
useSSDC = false;
break;
}
if (aSpCast && aSpCast.calcSpellScores) {
if (aSpCast && aSpCast.calcSpellScores && aSpCast.calcSpellScores.dc !== undefined) {
useSSDC = true;
foundSSDC.push(aSpCast.calcSpellScores.dc);
if (!foundSSDCref[aSpCast.calcSpellScores.dc]) foundSSDCref[aSpCast.calcSpellScores.dc] = [];
Expand Down
6 changes: 5 additions & 1 deletion _functions/Functions2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5636,6 +5636,7 @@ function ApplyWeapon(inputText, fldName, isReCalc, onlyProf, forceRedo) {
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);
var isThrownWeapon = isWeapon && /\bthrown\b/i.test(fields.Description) && /\d ?(ft|m)\.?($|[^)])/i.test(fields.Range);

var gatherVars = {
WeaponText : WeaponText,
Expand All @@ -5646,6 +5647,7 @@ function ApplyWeapon(inputText, fldName, isReCalc, onlyProf, forceRedo) {
isMeleeWeapon : isMeleeWeapon,
isRangedWeapon : isRangedWeapon,
isNaturalWeapon : isNaturalWeapon,
isThrownWeapon : isThrownWeapon,
theWea : theWea,
StrDex : StrDex,
WeaponName : WeaponName,
Expand Down Expand Up @@ -5801,6 +5803,7 @@ function CalcAttackDmgHit(fldName) {
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);
var isThrownWeapon = isWeapon && /\bthrown\b/i.test(fields.Description) && /\d ?(ft|m)\.?($|[^)])/i.test(fields.Range);

// see if this is a off-hand attack and the modToDmg shouldn't be use
var isOffHand = isMeleeWeapon && (/^(?!.*(spell|cantrip))(?=.*(off.{0,3}hand|secondary)).*$/i).test(WeaponText);
Expand All @@ -5823,6 +5826,7 @@ function CalcAttackDmgHit(fldName) {
isMeleeWeapon : isMeleeWeapon,
isRangedWeapon : isRangedWeapon,
isNaturalWeapon : isNaturalWeapon,
isThrownWeapon : isThrownWeapon,
theWea : theWea,
WeaponName : WeaponName,
baseWeaponName : theWea.baseWeapon ? theWea.baseWeapon : WeaponName,
Expand Down Expand Up @@ -8075,7 +8079,7 @@ function processToNotesPage(AddRemove, items, type, mainObj, parentObj, namesArr
CurrentUpdates.notesChanges.push(changeMsg);
}
} else {
RemoveString('Extra.Notes', noteStr, true);
RemoveString('Extra.Notes', noteStr);
}
} else { // add to its own section on a notes page
if (AddRemove) {
Expand Down
6 changes: 3 additions & 3 deletions _functions/FunctionsSpells.js
Original file line number Diff line number Diff line change
Expand Up @@ -3073,7 +3073,7 @@ function AskUserSpellSheet() {
var loopEnd = loop ? spBonus.length : 1;
for (var i = 0; i < loopEnd; i++) {
var spBonusi = loop ? spCast.bonus[bKey][i] : spCast.bonus[bKey];
spBonusi.selection = [];
if (!spBonusi.selection) spBonusi.selection = [];

var iterate = !spBonusi.times ? 1 : isArray(spBonusi.times) ? spBonusi.times[Math.min(spBonusi.times.length, spCast.level) - 1] : spBonusi.times; //if we have to apply this thing multiple times, do so
for (var y = 1; y <= iterate; y++) {
Expand All @@ -3082,7 +3082,7 @@ function AskUserSpellSheet() {
if (BonusSpecialActions.oncelr[boNmr]) spCast.special.oncelr.push(dia.selectBo[boNmr]); //those that are usable once per LR for referencing it later
if (BonusSpecialActions.oncesr[boNmr]) spCast.special.oncesr.push(dia.selectBo[boNmr]); //those that are usable once per SR for referencing it later
if (BonusSpecialActions.other[boNmr]) spCast.special.other[dia.selectBo[boNmr]] = (/^(atwill|oncelr|oncesr|markedbox|checkbox|checkedbox)$/).test(BonusSpecialActions.other[boNmr]) ? BonusSpecialActions.other[boNmr] : BonusSpecialActions.other[boNmr].substring(0, (/\(.\)|\d-\d/).test(BonusSpecialActions.other[boNmr]) ? 3 : 2); //those that have a special first column, up to two/three characters
spBonusi.selection.push(dia.selectBo[boNmr]); //set the selection(s)
spBonusi.selection[y-1] = dia.selectBo[boNmr]; //set the selection(s)
boNmr += 1; //count the number of bonus things
}
}
Expand Down Expand Up @@ -3764,7 +3764,7 @@ function MakeSpellMenu_SpellOptions(MenuSelection) {
case "makeempty" :
if (SSvisible) {
var asking = {
cMsg : "Unfortunately it is not possible to hide the Spell Sheet. They can only be deleted.\n\nDo you want to remove all the Spell Sheets except the first one and remove the content of the first one?\nYou can then manually fill out the Spell Sheet and add/remove more pages using the \"Layout\" and \"Spells\" buttons in the \"JavaScript Window\" or in the bookmarks.\n\nRemoving the Spell Sheets cannot be undone!",
cMsg : 'Unfortunately it is not possible to hide the Spell Sheet. They can only be deleted.\n\nDo you want to remove all the Spell Sheets except the first one and remove the content of the first one?\nYou can then manually fill out the Spell Sheet and add/remove more pages using the "Layout" and "Spells" buttons in the "JavaScript Window" or in the bookmarks.\n\nRemoving the Spell Sheets cannot be undone!',
cTitle : "Delete all the Spell Sheets",
nIcon : 2, //question
nType : 2, //Yes-No
Expand Down
9 changes: 5 additions & 4 deletions _variables/ListsClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var FightingStyles = {
name : "Defense Fighting Style",
description : desc("+1 bonus to AC when I'm wearing armor"),
extraAC : {
name : "Defense Fighting Style", // necessary for features referring to fighting style properties directly
mod : 1,
text : "I gain a +1 bonus to AC while wearing armor.",
stopeval : function (v) { return !v.wearingArmor; }
Expand Down Expand Up @@ -761,11 +762,11 @@ var Base_ClassList = {
}),
action : [["bonus action", "Unarmed Strike (with Attack action)"]],
eval : function() {
AddString('Extra.Notes', 'Monk features:\n\u25C6 If I wear armor/shield, I lose Unarmored Defense, Martial Arts, and Unarmored Movement', true);
AddString('Extra.Notes', 'Monk features:\n\u25C6 If I wear armor/shield, I lose Unarmored Defense, Martial Arts, and Unarmored Movement');
show3rdPageNotes();
},
removeeval : function() {
RemoveString('Extra.Notes', 'Monk features:\n\u25C6 If I wear armor/shield, I lose Unarmored Defense, Martial Arts, and Unarmored Movement', true);
RemoveString('Extra.Notes', 'Monk features:\n\u25C6 If I wear armor/shield, I lose Unarmored Defense, Martial Arts, and Unarmored Movement');
},
calcChanges : {
atkAdd : [
Expand Down Expand Up @@ -1503,7 +1504,7 @@ var Base_ClassList = {
minlevel : 1,
description : desc([
"Once per turn, I can add damage to a finesse/ranged weapon attack if I have advantage",
"I don't need adv. if a conscious ally is within 5 ft of the target and I don't have disadv."
"I don't need adv. if the target has a conscious enemy within 5 ft and I don't have disadv."
]),
additional : levels.map(function (n) {
return Math.ceil(n / 2) + "d6";
Expand Down Expand Up @@ -3489,7 +3490,7 @@ var Base_ClassSubList = {
source : [["SRD", 51], ["P", 109]],
minlevel : 10,
description : desc([
"After a short or long rest, I can choose one damage type to become resistance to",
"After a short or long rest, I can choose one damage type to become resistant to",
"This lasts until I choose another type; Magical and silver weapons ignore this resistance"
])
},
Expand Down
4 changes: 2 additions & 2 deletions _variables/ListsMagicItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -2910,7 +2910,7 @@ var Base_MagicItemsList = {
type : "weapon (mace)",
rarity : "rare",
magicItemTable : "G",
description : "This magic mace sheds bright light in a 20-ft radius and dim light for another 20 ft while held. Fiends and undead hit with it take +2d6 radiant damage and becomes frightened of me until my next turn ends. If the target has less than 26 HP after taking the damage, it must make a DC 15 Wis save or be destroyed.",
description : "While held, this magic mace sheds bright light in a 20-ft radius and dim light for another 20 ft. It deals +2d6 radiant damage vs. fiends and undead. If it has less than 26 HP after this damage, it must make a DC 15 Wis save or be destroyed. If successfully, it instead becomes frightened of me until the end of my next turn.",
descriptionFull : "When you hit a fiend or an undead with this magic weapon, that creature takes an extra 2d6 radiant damage. If the target has 25 hit points or fewer after taking this damage, it must succeed on a DC 15 Wisdom saving throw or be destroyed. On a successful save, the creature becomes frightened of you until the end of your next turn.\n While you hold this weapon, it sheds bright light in a 20-foot radius and dim light for an additional 20 feet.",
attunement : true,
weight : 4,
Expand All @@ -2920,7 +2920,7 @@ var Base_MagicItemsList = {
regExpSearch : /^(?=.*mace)(?=.*disruption).*$/i,
name : "Mace of Disruption",
source : [["SRD", 229], ["D", 179]],
description : "Fiend/undead +2d6 radiant damage, frightened until my next turn ends, and if HP<26, DC 15 Wis save or die"
description : "Fiend/undead +2d6 radiant damage and if HP<26, DC 15 Wis save: fail - die, success - frightened until my next turn ends"
}
},
"mace of smiting" : {
Expand Down
6 changes: 5 additions & 1 deletion additional content syntax/_common attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Magic Item main attributes
Magic Item choices
Sheet: v13.1.0 and newer
Sheet: v13.1.1 and newer
*/
"example feature name" = { // you can ignore this, it is just here to make this file valid JavaScript

Expand Down Expand Up @@ -1551,6 +1551,7 @@ calcChanges : {
USE: dynamically change what is put in the fields of an attack entry
Note that this is only run for attacks that are recognized, not manually added
CHANGE: v13.0.8 (priority, 3rd array entry)
v13.1.1 (added v.isThrownWeapon)
// 1st array entry // REQUIRED //
Both examples do the exact same thing, just one is a string and the other is a function.
Expand Down Expand Up @@ -1591,6 +1592,7 @@ calcChanges : {
isMeleeWeapon, // boolean, whether (true) or not (false) this attack has a range of 'melee' and is considered a melee weapon attack
isRangedWeapon, // boolean, whether (true) or not (false) this attack has a range that doesn't include 'melee' and is considered a ranged weapon attack
isNaturalWeapon, // boolean, whether (true) or not (false) this attack has the type 'natural'
isThrownWeapon, // boolean, whether (true) or not (false) this attack has the 'thrown' property [added v13.1.1]
theWea, // object, the entry as it appears in the WeaponsList object
StrDex, // number, either 1 (Str) or 2 (Dex) depending on which of the two ability scores is higher
WeaponName, // string, the name of the entry in the WeaponsList object
Expand Down Expand Up @@ -1653,6 +1655,7 @@ calcChanges : {
USE: dynamically change how the To Hit and Damage of attacks are calculated
Note that this is only run for attacks that are recognized, not manually added
CHANGE: v13.0.8 (priority, 3rd array entry)
v13.1.1 (added v.isThrownWeapon)
// 1st array entry // REQUIRED //
Both examples do the exact same thing, just one is a string and the other is a function.
Expand Down Expand Up @@ -1681,6 +1684,7 @@ calcChanges : {
isMeleeWeapon, // boolean, whether (true) or not (false) this attack has a range of 'melee' and is considered a melee weapon attack
isRangedWeapon, // boolean, whether (true) or not (false) this attack has a range that doesn't include 'melee' and is considered a ranged weapon attack
isNaturalWeapon, // boolean, whether (true) or not (false) this attack has the type 'natural'
isThrownWeapon, // boolean, whether (true) or not (false) this attack has the 'thrown' property [added v13.1.1]
isOffHand, // boolean, whether (true) or not (false) this attack is both a melee weapon and an off-hand attack
theWea, // object, the entry as it appears in the WeaponsList object
WeaponName, // string, the name of the entry in the WeaponsList object
Expand Down

0 comments on commit 60753cf

Please sign in to comment.