From 73573edca2c4b4b3e5b876c91a5793e951f6ecfe Mon Sep 17 00:00:00 2001 From: Malin Freeborn <malinfreeborn@posteo.net> Date: Wed, 8 Nov 2023 23:57:53 +0100 Subject: [PATCH] automatically calculate resistance TN --- magic.sty | 20 +++++++++++++++++--- monsters.sty | 2 ++ stats.sty | 5 +++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/magic.sty b/magic.sty index b73dfe01..faf87c32 100644 --- a/magic.sty +++ b/magic.sty @@ -12,6 +12,8 @@ \setcounter{spellCost}{1} \newcounter{spellPlusTwo} \setcounter{spellPlusTwo}{1} +\newcounter{castingBonus} + \setcounter{castingBonus}{1} \newcommand\spellName{} \newcommand\spellEnhancements{} @@ -40,6 +42,18 @@ \renewcommand\spellEnhancements{#2}% \renewcommand\spellAction{#3}% \renewcommand\spellSphere{#4}% + % What bonus does the caster receive? Some spells will display the caster's current Bonus, so we must calculate it. We start by setting it sky-high, then for each element in {Earth,Fire}, et c. we check if this is lower than the current castingBonus, if (if so), lower the bonus. + \setcounter{castingBonus}{10}% + \foreach \e in {#4}{% + \ifnum\value{\e}<\value{castingBonus}% + \setcounter{castingBonus}{\value{\e}}% + \fi% + }{}% + \iftoggle{snapCaster}{% + \addtocounter{castingBonus}{\value{Wits}}% + }{% + \addtocounter{castingBonus}{\value{Charisma}}% + }% \renewcommand\spellResistance{#5} \renewcommand\spellSum{#6} \renewcommand\spellNotes{#7} @@ -75,13 +89,14 @@ \newcommand\spellIndex{\index[spells]{\textbf{\spellName} Cost: \arabic{spellCost}, \spellEnhancements, \spellAction~\spellSphere, Range: \spellRange, \ifnum\value{spellTargets}>1 Targets: \arabic{spellTargets}, \fi Resisted by: \detokenize{\spellResistance}, \spellSum \spellNotes }} \newcommand\shortSpell{% + \addtocounter{castingBonus}{7}% \item[\spellName] Cost: \arabic{spellCost}, - \spellEnhancements, + \spellEnhancements~ \spellAction~ \spellSphere - Resisted by: \spellResistance + Resisted by: \spellResistance\ (\tn[\arabic{castingBonus}]) \spellSum \ \spellNotes @@ -97,7 +112,6 @@ }% } - \newcommand\spellRange{} \newcommand\setRange{% \iftoggle{distant}% diff --git a/monsters.sty b/monsters.sty index 5d5b95ad..8a43a211 100644 --- a/monsters.sty +++ b/monsters.sty @@ -1527,6 +1527,7 @@ mana stone holding \arabic{track} MP, \ifodd\thechapter\lootJewellery\fi}% EQUIP \setcounter{Earth}{1}% \fi% \undead + \knacks{\snapcaster} } } @@ -1573,6 +1574,7 @@ mana stone holding \arabic{track} MP, \ifodd\thechapter\lootJewellery\fi}% EQUIP mana stone with \arabic{track} mana, \lootJewellery, \randomtwo\lootJewellery, \lootMagic}% EQUIPMENT { \renewcommand\abilities{\undead} + \knacks{\snapcaster} } } diff --git a/stats.sty b/stats.sty index 35f1f99b..42a5ffc0 100644 --- a/stats.sty +++ b/stats.sty @@ -369,6 +369,7 @@ \newcommand{\snapcaster}{% \addtocounter{knacks}{1}% + \global\settoggle{snapCaster}{true}% Snap Caster (spells use Wits and cost 1 less \glsentrytext{ap}) } @@ -408,6 +409,9 @@ \newcommand{\mind}[3]{ \setcounter{Intelligence}{#1}\setcounter{Wits}{#2}\setcounter{Charisma}{#3} } + +\newtoggle{snapCaster} +\settoggle{snapCaster}{true} % %%%%%%%%%%% Person @@ -561,6 +565,7 @@ } \newcommand{\clean}{ + \global\toggletrue{snapCaster} \knacks{} \foreach \s in {Air,Earth,Fate,Fire,Water,Projectiles,Combat,Brawl,Academics,Alchemy,Athletics,Caving,Crafts,Deceit,Empathy,Flight,Medicine,Performance,Larceny,Seafaring,Tactics,Vigilance,Wyldcrafting}% {\setcounter{\s}{0}} -- GitLab