Skip to content
Snippets Groups Projects
stats.sty 23.74 KiB
\ProvidesPackage{config/stats}
%%%%%%%%%%%%%%%%%%%% Introduction

\newtoggle{genExamples}
\settoggle{genExamples}{false}

\newtoggle{allyCharacter}
\settoggle{allyCharacter}{false}

\newtoggle{perfectArmour}
\settoggle{perfectArmour}{false}

%      _        _   
%  ___| |_ __ _| |_ 
% / __| __/ _` | __|
% \__ \ || (_| | |_ 
% |___/\__\__,_|\__|
%                   
% 
%  _     _            _        
% | |__ | | ___   ___| | _____ 
% | '_ \| |/ _ \ / __| |/ / __|
% | |_) | | (_) | (__|   <\__ \
% |_.__/|_|\___/ \___|_|\_\___/
%                              
%
% This file makes stat blocks for monsters.
% 
% The writer feeds in something like this:
% 
% \npc{\M}{Patrick the Pyromanacer}
% 
% \person{0}% STRENGTH
% {0}% DEXTERITY 
% {0}% SPEED
% {{0}% INTELLIGENCE
% {0}% WITS
% {0}}% CHARISMA
% {0}% DR
% {0}% COMBAT
% {}% SKILLS
% {Nothing}% EQUIPMENT
% {}
% 
% The \person command takes various stats, and
% inside that 'SKILLS' variable (variable no. 8),
% we can add additional things, like
% \knacks{\adrenalinesurge}.
% 
% Most of the rest of the commands deal with
% properly calculating derived stats, like the TN
% to hit the creature.


\newtoggle{mind}
\newtoggle{creatureBox}
\newtoggle{examplecharacter}
\settoggle{examplecharacter}{false}
\newtoggle{debug}\settoggle{debug}{false}
\newcommand{\ent}[1]{\textbf{#1}}
\newcommand{\test}{}
\newcommand{\skills}{}
\newcommand{\equipment}{}
\newcommand{\mods}{}
\newcommand\showCR{}

\newcommand\absNum[1]{\ifnum\value{#1}>0+\fi\ifnum\value{#1}=0\else\arabic{#1}\fi}

% we calculate damage here because we can't display 1d6+6 damage - it has to turn into 2d6+2 damage.
\newcommand\conDmg[1]{%
  \setcounter{numberofdice}{1}%
  \setcounter{damagebonus}{\value{#1}}%
  \addtocounter{damagebonus}{-4}%
  \whileboolexpr{%
    test {\ifnumcomp{\value{damagebonus}}{>}{3}}%
  }{%
    \addtocounter{damagebonus}{-4}%
    \addtocounter{numberofdice}{1}%
  }%
}

\newcommand\showDam{%
  \arabic{numberofdice}D6\absNum{damagebonus}%
}

\newcommand\dmg[1]{\conDmg{#1}\showDam}

\newcommand\showSkills{
    \foreach \s in {Projectiles,Combat,Brawl,Academics,Athletics,Caving,Crafts,Deceit,Empathy,Flight,Medicine,Performance,Larceny,Seafaring,Stealth,Tactics,Vigilance,Wyldcrafting}
      {\ifnum\value{\s}>0 \s~\arabic{\s}, \fi}
}

\newcommand\showBoxes{%
  \ifnum\value{mp}<1%
    \ifnum\value{hp}>11%
      \HPboxes%
    \else%
      \ifnum\value{hp}>6%
        \HPHPboxes%
      \else%
        \HPHPHPboxes%
      \fi%
    \fi%
  \else%
    \ifnum\value{sp}<1%
      \HPMPboxes%
    \else%
      \HPMPSPboxes%
    \fi%
  \fi%
}

\newcounter{wounds}
\setcounter{wounds}{0}

\newcommand\boxStat[1]{%
  \addtocounter{#1}{-\value{wounds}}%
  \Repeat{\value{wounds}}{\CheckedBox}%
  \Repeat{\value{#1}}{\Square}%
}

\newcommand\HPboxes{
  \begin{tabular}{r}
  \hiderowcolors
    HP \arabic{hp}
    \Repeat{\value{noAppearing}}{
    \boxStat{hp} \\
    }
  \end{tabular}
}

\newcommand\HPHPboxes{
  \begin{tabular}{rr}
  \hiderowcolors
    HP \arabic{hp}
    \whileboolexpr{test {\ifnumcomp{\value{noAppearing}}{>}{0}}}{%
      \ifnumodd{\value{noAppearing}}{ & \boxStat{hp} \\}{\boxStat{hp}}%
      \addtocounter{noAppearing}{-1}
    }
  \end{tabular}
}

\newcommand\HPHPHPboxes{
  \begin{tabular}{rrr}
    \hiderowcolors
    HP \arabic{hp}
    \whileboolexpr{test {\ifnumcomp{\value{noAppearing}}{>}{0}}}{%
      \boxStat{hp}
      \addtocounter{noAppearing}{-1}
      &
      \ifnum\value{noAppearing}>0\boxStat{hp}\fi
      \addtocounter{noAppearing}{-1}
      &
      \ifnum\value{noAppearing}>0\boxStat{hp}\fi
      \addtocounter{noAppearing}{-1}
      \\
    }
  \end{tabular}
}

\newcommand\HPMPboxes{
  \setcounter{enc}{\value{hp}}
  \addtocounter{enc}{\value{mp}}
  \ifnum\value{enc}<20
    \begin{tabular}{rr}
      \hiderowcolors
      \Repeat{\value{noAppearing}}{
      HP \arabic{hp}
      \boxStat{hp}
      &
      MP \arabic{mp}
      \boxStat{mp}
      \\
      }
      \\
    \end{tabular}
  \else
    \begin{tabular}{r}
      \hiderowcolors
      \Repeat{\value{noAppearing}}{
      HP \arabic{hp} \boxStat{hp} \\
      MP \arabic{mp} \boxStat{mp} \\
      }
    \end{tabular}
  \fi
}

\newcommand\HPMPSPboxes{
  \setcounter{enc}{\value{hp}}
  \addtocounter{enc}{\value{mp}}
  \addtocounter{enc}{\value{sp}}
  \ifnum\value{enc}<20
    \begin{tabular}{rrr}
      \hiderowcolors
      \Repeat{\value{noAppearing}}{
      HP \arabic{hp}
      \boxStat{hp}
      &
      MP \arabic{mp}
      \boxStat{mp}
      &
      SP \arabic{sp}
      \boxStat{sp}
      \\
      }
    \end{tabular}
  \else
    \ifnum\value{enc}<10
      \begin{tabular}{rr}
        \hiderowcolors
        \Repeat{\value{noAppearing}}{
          HP \arabic{hp} \boxStat{hp} &
          MP \arabic{mp} \boxStat{mp} \\
          & SP \arabic{sp} \boxStat{sp} \\
        }
      \end{tabular}
    \else
      \begin{tabular}{r}
        \hiderowcolors
        \Repeat{\value{noAppearing}}{
          HP \arabic{hp} \boxStat{hp} \\
          MP \arabic{mp} \boxStat{mp} \\
          SP \arabic{sp} \boxStat{sp} \\
        }
      \end{tabular}
    \fi
  \fi
}


%%%%%%%%%%%%%%%%%%%% Character Generation %%%%%%%%%%%%%%%%%%%%
%
%                       _                
%  ___ ___  _   _ _ __ | |_ ___ _ __ ___ 
% / __/ _ \| | | | '_ \| __/ _ \ '__/ __|
%| (_| (_) | |_| | | | | ||  __/ |  \__ \
% \___\___/ \__,_|_| |_|\__\___|_|  |___/
%                                        
%
% Attributes: str, dex, spd, int, wts, cha
% secondary str, dex and spd
\newcounter{att}
\newcounter{dr}
\newcounter{knacks}


% Extras: MP hp fp
% Derived: dicenumber, dicebonus,
\newcounter{mp}
\newcounter{sp}
\newcounter{hp}
\newcounter{fp}
\newcounter{numberofdice}
\newcounter{damagebonus}
\newcounter{xp}
\newcounter{xpbonus}
\newcounter{attackXPtotal}
\newcounter{defenceXPtotal} %rem

\newcounter{initiative}
\newcounter{weight}
\newcounter{maxWeight}
\newcounter{ap}
\newcounter{damage}
\newcounter{shieldBonus}
\newcounter{shieldWeight}
\newcounter{shieldInit}
\newcounter{cost}
\newcounter{heft}% used to see how many AP points to swing a weapon
\newcounter{encumbrance}
  \setcounter{encumbrance}{0}


%                                                _
%   ___ ___  _ __ ___  _ __ ___   __ _ _ __   __| |___
%  / __/ _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` / __|
% | (_| (_) | | | | | | | | | | | (_| | | | | (_| \__ \
%  \___\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|___/
% 



% magic
\newcommand{\magicPath}{}

\newcommand{\knacks}[1]{\gdef\showKnacks{#1}}

\newcommand\showKnacks{}


%%%%%%%%%%%%%%%%%%%%% Knacks
%
\newcommand{\adrenalinesurge}{%
  \addtocounter{knacks}{1}%
  Adrenaline Surge (+1 Damage, once per \ifnum\value{knacks}<2 combat\else round, \arabic{knacks} uses per combat\fi)%
}
\newcommand{\berserker}{%
  Berserker (+1 \glsentrytext{ap}. on round 2 of combat, +1 Damage. on round 3)%
  \addtocounter{knacks}{1}%
}
\newcommand{\brawler}{Brawler\addtocounter{knacks}{1}%
\iftoggle{examplecharacter}{ (+2 to unarmed attacks)}{}}
\newcommand{\charge}{%
  Fast Charge
  (+1 \glsentrytext{ap}, Attack, and Damage after charging 6 steps)%
  \addtocounter{knacks}{1}%
}
\newcommand{\cuttingswing}{%
  Cutting Swing
  (when an opponent hits 0 \glspl{hp}, damage transfers to the next opponent)%
  \addtocounter{knacks}{1}%
}
\newcommand{\dodger}{%
  \addtocounter{knacks}{1}%
  Dodger
  (+\arabic{knacks} to dodge projectiles)%
}
\newcommand{\guardian}{%
  \addtocounter{knacks}{1}%
  Guardian
  (spend 0 AP to guard someone, and gain +1 to guarding against attacks)%
}
\newcommand{\laststand}{%
  \addtocounter{knacks}{1}%
  Last Stand
  (when losing \glspl{hp}, the character gains \setcounter{enc}{2}\addtocounter{enc}{\value{knacks}}\arabic{enc} AP)%
}
\newcommand{\lucky}{%
  \addtocounter{knacks}{1}%
  \addtocounter{fp}{4}%
  Lucky (add 4 \glsentryshortpl{fp})
}

\newcommand{\mightydraw}{%
  \addtocounter{knacks}{1}%
  Mighty Draw
  \setcounter{enc}{\value{knacks}}\roundUp{enc} (reduce cost to draw longbow by \arabic{enc} AP)
}
\newcommand{\perfectsneakattack}{%
  \addtocounter{knacks}{1}%
  Perfect Sneak Attack
  (+\arabic{knacks} Damage for sneak attacks)
}
\newcommand{\precisestrike}{%
  \addtocounter{knacks}{1}%
  Precise Strike
  (+1 Attack when calculating Vitals shot)
}
\newcommand{\specialist}[1]{Specialist \addtocounter{knacks}{1}
\iftoggle{examplecharacter}{ (+2 when using any #1)}{(#1)}}
\newcommand{\stunningstrike}{%
  \addtocounter{knacks}{1}%
  Stunning Strike
  (take -1 penalty, and opponent's AP reduces by half Damage)%
}
\newcommand{\snapshot}{%
  \addtocounter{knacks}{1}%
  Snap Shot
  (Pay 0 AP to reload arrow or draw weapon)%
}
\newcommand{\unstoppable}{%
  \addtocounter{knacks}{1}%
  \addtocounter{hp}{2}%
  Unstoppable
  (+2 \glsentryshortpl{hp}, and +\arabic{knacks} to any Medicine rolls to save them when dying)
}
\newcommand{\vengeful}{Vengeful\addtocounter{knacks}{1}%
\iftoggle{examplecharacter}{ (+2 Intelligence after losing HP)}{}}
  \newcommand{\weaponmaster}[1]{%
  \addtocounter{att}{1}%
  \addtocounter{knacks}{1}%
  Weapon Master
  (+1 Attack when using a {#1})
}

\newcommand{\autophage}{%
  \addtocounter{knacks}{1}%
  Autophage
  (cast with \glspl{fatigue} instead of \glspl{mp})
}

\newcommand{\snapcaster}{%
  \addtocounter{knacks}{1}%
  \ifnum\value{Wits}>\value{Charisma}%
    \global\settoggle{snapCaster}{true}%
  \fi%
  Snap Caster
  (spells use Wits and cost 1 less \glsentrytext{ap})
}

\newcommand{\ritualcaster}{%
  \addtocounter{knacks}{1}%
  Ritual Caster
  (spells use Intelligence, caster may spend 1 extra \gls{mp})
}

\newcommand{\fasthealer}{%
  \addtocounter{knacks}{1}%
  Fast Healer
  (resting heals 2 additional \glspl{fatigue} and 1 \gls{mp})
}

\newcommand{\combatcaster}{Combat Caster\addtocounter{knacks}{1}}
\newcommand\chosenEnemy[1]{Chosen Enemy (+1 against #1, -2 when trying to be friendly)\addtocounter{knacks}{1}}

% _ __   ___ _ __ ___  ___  _ __  
%| '_ \ / _ \ '__/ __|/ _ \| '_ \ 
%| |_) |  __/ |  \__ \ (_) | | | |
%| .__/ \___|_|  |___/\___/|_| |_|
%|_|                              
% 
%
%       _                          _            
%%  ___| |__   __ _ _ __ __ _  ___| |_ ___ _ __ 
%% / __| '_ \ / _` | '__/ _` |/ __| __/ _ \ '__|
%%| (__| | | | (_| | | | (_| | (__| ||  __/ |   
%% \___|_| |_|\__,_|_|  \__,_|\___|\__\___|_|   
%%                                              
%%  optional counters, such as mana, are cleaned
%%  clear: weaponsknack1 and 2, 
%% 
%
\newcommand{\mind}[3]{
\setcounter{Intelligence}{#1}\setcounter{Wits}{#2}\setcounter{Charisma}{#3}
}

\newtoggle{snapCaster}
\settoggle{snapCaster}{true}
%

%%%%%%%%%%% Person
%
\newcommand{\person}[9]{
  \settoggle{creatureBox}{true}
  \settoggle{mind}{true}
  \clean

  \setcounter{Strength}{#1}
	\setcounter{hp}{#1}
  \setcounter{Dexterity}{#2}
  \setcounter{Speed}{#3}
  \mind#4
  \setcounter{att}{#6}
  \setcounter{Combat}{#6}
  \renewcommand{\skills}{#7}
  \renewcommand{\equipment}{#8}

  \iftoggle{verbose}{
    \begin{tcolorbox}[
      title={\npcsymbol\ \name},
      before upper={\parindent0pt},
      ornamented,
      fontupper=\small,
      halign=flush left,
      left=5pt,
      right=5pt,
      top=0pt,
      bottom=0pt,
      ]

    #9

    \creaturestats

    \skillsEtc

    \derivedstats

    \end{tcolorbox}

  }{
    \vspace{2em}
    \noindent
    \begin{minipage}{\linewidth}
    \hrulefill\hspace{-0.15em}\raisebox{-1em}{\huge\npcsymbol}

    \begin{center}\textbf{\large\name}\end{center}
    #9%
    \hphantom{\equipment}%
    \vspace{-2em}
    \derivedstats

    \skillsEtc

    \hrulefill
    \end{minipage}
  }

  \iftoggle{personality}{
    \begin{multicols}{2}
    \raggedright
    \textbf{Mannerism:}~\mannerism
    \par
    \textbf{Description:}~\NPCdescription
    \par\pagebreak[3]
    \textbf{Wants:}~\npcGoal
    \ifdefempty{\npcQuote}{}{\par
      \textbf{Quote:}~\textit{``\npcQuote''}
    }
    \end{multicols}

    \settoggle{personality}{false}}%
	{}
  \settoggle{creatureBox}{false}
  \setcounter{noAppearing}{1}
  \setcounter{wounds}{0}
  \renewcommand\abilities{}
  \global\togglefalse{perfectArmour}
  \renewcommand\npcQuote{}
}

\newcommand{\animal}[9]{
  \settoggle{creatureBox}{true}
	\settoggle{mind}{false}
	\clean

	\setcounter{Strength}{#1}
	\setcounter{hp}{#1}
	\setcounter{Dexterity}{#2}
	\setcounter{Speed}{#3}
	\setcounter{Wits}{#4}
	\setcounter{dr}{#5}
	\setcounter{att}{#6}
	\renewcommand{\skills}{#7}
	\renewcommand{\abilities}{#8}
  \setcounter{covering}{4}

  \iftoggle{verbose}{
    \begin{tcolorbox}[
      title={\npcsymbol\ \name},
      before upper={\parindent0pt},
      ornamented,
      fontupper=\small,
      halign=flush left,
      left=5pt,
      right=5pt,
      top=0pt,
      bottom=0pt,
      ]

    \iftoggle{personality}{

    \begin{minipage}{\linewidth}
    \textbf{Description:} \NPCdescription

    \textbf{Mannerism:} \mannerism
    \end{minipage}

    \vspace{1em}

    \settoggle{personality}{false}}%
    
    \creaturestats

    #9

    \skillsEtc
    \derivedstats

    \end{tcolorbox}

  }{
    \vspace{2em}
    \noindent
    \begin{minipage}{\linewidth}
    \hrulefill\hspace{-0.15em}\raisebox{-1em}{\huge\npcsymbol}

    \begin{center}\textbf{\large\name}\end{center}
    #9%
    \hphantom{\abilities}%
    \vspace{-2em}
    \derivedstats

    \skillsEtc

    \hrulefill
    \end{minipage}
  }

  \settoggle{creatureBox}{false}
  \renewcommand\abilities{}
  \global\togglefalse{perfectArmour}
  \setcounter{wounds}{0}
}

\newcommand{\clean}{
  \global\togglefalse{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,Stealth,Tactics,Vigilance,Wyldcrafting}%
    {\setcounter{\s}{0}}
  \setcounter{noAppearing}{1}
  \setcounter{dr}{0}
  \setcounter{fp}{0}
  \setcounter{sp}{0}
  \setcounter{heft}{1}
  \setcounter{weight}{0}
  \setcounter{encumbrance}{0}
  \setcounter{damage}{0}
  \setcounter{knacks}{0}
  \setcounter{mp}{0}
  \setcounter{xpbonus}{0}
}

%%       _   _        _ _           _            
%%  __ _| |_| |_ _ __(_) |__  _   _| |_ ___  ___ 
%% / _` | __| __| '__| | '_ \| | | | __/ _ \/ __|
%%| (_| | |_| |_| |  | | |_) | |_| | ||  __/\__ \
%% \__,_|\__|\__|_|  |_|_.__/ \__,_|\__\___||___/
%% 
%% Print the line,
%% print the attributes.
%% print the skills
%% print the knacks
%% print the equipment
%
\newcommand{\creaturestats}{

% Reference versions (which always are non-verbose) don't
% have the space for full-sized stats.

\footnotesize
\begin{tabularx}{\textwidth}{lr@{\hskip 3em}lr@{\hskip 3em}lr}

% the tcolorbox has coloured rows (xcolor package)
% but that doesn't work with creature stats, so we suppress it here
\hiderowcolors
	Strength & \arabic{Strength} & Dexterity & \arabic{Dexterity} & Speed & \arabic{Speed} \\
\iftoggle{mind}{
	Intelligence & \arabic{Intelligence}  & Wits & \arabic{Wits} & Charisma & \arabic{Charisma}  \\}{%
	&& Wits & \arabic{Wits} \\
	}

\end{tabularx}

}

\newcommand\skillsEtc{

  \foreach \s in {Air,Earth,Fate,Fire,Water}%
    {\ifnum\value{\s}>0 \addtocounter{mp}{3}\fi}

\begin{tabularx}{\linewidth}{p{.15\textwidth}>{\raggedright\arraybackslash}X}

  \iftoggle{verbose}{
    \ent{Skills} &
    \showSkills
      \skills \\
  }{}

  \ifdefempty{\showKnacks}{}{
    \ent{Knacks} & \showKnacks \\
  }

  \ifnum\value{mp}>0
    \ent{Spheres} &
    \foreach \s in {Air,Earth,Fate,Fire,Water}%
      {\ifnum\value{\s}>0 \s~\arabic{\s}, \fi}
    \\
  \fi

	\iftoggle{mind}%
    {%
    \ifdefempty{\equipment}{}
    {
      \setcounter{attackXPtotal}{\value{Charisma}}% Must store Charisma while talisman shows spells
      \ent{Equipment} & \equipment \\
    }
    }%
    {}

  \ifdefempty{\abilities}{}%
    {\ent{Abilities:} & \abilities}
	\mods

\end{tabularx}

}

%%     _               _        _
%%  __| | ___ _ __ ___| |_ __ _| |_ ___ 
%% / _` |/ _ \ '__/ __| __/ _` | __/ __|
%%| (_| |  __/ |  \__ \ || (_| | |_\__ \
%% \__,_|\___|_|  |___/\__\__,_|\__|___/
%% 
%% 
%% dice instead of Damage
%% print out att, spd, DAM, dex, dr (type), str
%%
%
\newcommand{\derivedstats}{
  \iftoggle{verbose}{\hrulefill}{}
  \setlength\topsep{0pt}
  \setlength\parskip{0pt}
  \iftoggle{debug}{str: \arabic{Strength}, dex: \arabic{Dexterity}, spd: \arabic{Speed}, att: \arabic{att}, damage: \arabic{damage}, Attack total: \arabic{attackXPtotal}, Def Total: \arabic{defenceXPtotal}}{}

% Stats for allies don't need to show Combat +1 as 'TN 8 to hit', they just need to show '+1'.
\addtocounter{hp}{6}%
\ifnum\value{Combat}>\value{Brawl}\else\setcounter{att}{\value{Brawl}}\fi%
\iftoggle{allyCharacter}{}{%
  \addtocounter{att}{7}%
}%
\addtocounter{att}{\value{Dexterity}}%
\setcounter{maxWeight}{\value{hp}}% now to compute encumbrance
\divide\value{maxWeight} by 2%
\ifnum\value{weight}>\value{maxWeight}%
  \addtocounter{encumbrance}{\value{weight}}%
  \addtocounter{encumbrance}{-\value{maxWeight}}%
\fi%
\begin{center}
  \iftoggle{verbose}{\normalsize}{\large}%
  \setcounter{ap}{\value{Speed}}%
  \addtocounter{ap}{3}%
  \addtocounter{ap}{-\value{encumbrance}}%
  \scshape AP \ifnum\value{ap}<1 $\frac{1}{2}$ \else \arabic{ap}\fi%
  \ifnumcomp{\value{heft}}{>}{1}{ (AP Cost: \arabic{heft})}{},
  Att %
  \iftoggle{allyCharacter}{$2D6$\ifnum\value{att}>-1 +\fi}{}%
  \arabic{att}%
  \setcounter{enc}{\value{att}},%
  \addtocounter{damage}{\value{Strength}}
  \addtocounter{damage}{4}%
  \mbox{Dam \dmg{damage}, }%
    \ifnumcomp{\value{dr}}{>}{0}{%
      \setcounter{enc}{\value{att}}%
      \addtocounter{enc}{\value{covering}}%
      \stepcounter{enc}%
      \mbox{DR \arabic{dr}%
      \iftoggle{perfectArmour}%
        {}%
        { (\arabic{enc}!)}, }%
    }{}%
  \iftoggle{genExamples}{%
    HP~\arabic{hp},
    \ifnum\value{mp}>0%
      MP \arabic{mp},
    \fi%
    \ifnum\value{sp}>0%
    SP \arabic{sp},
    \fi%
  }{%
    \par%
    \showBoxes%
  }%
  \iftoggle{allyCharacter}{}{%
    \iftoggle{examplecharacter}{}{%
      \calculateXP%
      \outline{\glsentrytext{cr}: \showCR}%
    }%
  }%
\end{center}%
}
%
%
%% __  ______  
%% \ \/ /  _ \ 
%%  \  /| |_) |
%%  /  \|  __/ 
%% /_/\_\_|    
%%  
\newcommand{\calculateXP}{%
  %%% Now to get the XP value of the creature's attack ability.
  %%% = Attack (TN) * Dam + max((spd-hef),mp)^2
  \setcounter{attackXPtotal}{\value{att}}%
  \multiply\value{attackXPtotal} by \value{damage}%
  \addtocounter{Speed}{-\value{heft}}%
  \ifnum\value{Speed}>\value{mp}%
    \setcounter{enc}{\value{Speed}}%
  \else%
    \setcounter{enc}{\value{mp}}%
  \fi%
    \multiply\value{enc} by\value{enc}%
    \addtocounter{attackXPtotal}{\value{enc}}%
    %%% And now the XP defence total.
    %%% = (att - 7 + dr) x hp
    \ifnum\value{att}>7%
      \setcounter{defenceXPtotal}{\value{att}}%
      \addtocounter{defenceXPtotal}{-7}%
    \else%
      \setcounter{defenceXPtotal}{0}%
    \fi%
    \addtocounter{defenceXPtotal}{\value{dr}}%
    \multiply\value{defenceXPtotal} by\value{hp}\addtocounter{defenceXPtotal}{0}%

  % XP = attackXPtotal + defenceXPtotal
    \setcounter{xp}{\value{attackXPtotal}}%
    \addtocounter{xp}{\value{defenceXPtotal}}%

  \iftoggle{debug}{str: \arabic{Strength}, dex: \arabic{Dexterity}, spd: \arabic{Speed}, att: \arabic{att}, damage: \arabic{damage}, weight: \arabic{weight}, encumbrance: \arabic{encumbrance}, XP Bonus: \arabic{xpbonus}, Attack total: \arabic{attackXPtotal}, Def Total: \arabic{defenceXPtotal}, mp: \arabic{mp} Grand Total: \arabic{xp}}{\iftoggle{verbose}{\hrulefill}}%
    
  \iftoggle{examplecharacter}%
  {}%
  {%
    \ifnumcomp{\value{xp}}{<}{73}%
      {\ifnumcomp{\value{xp}}{<}{40}%
        {\renewcommand\showCR{\arabic{xpbonus}}}{\renewcommand\showCR{$\frac{1}{2}$}}}%
        {%
            \addtocounter{xp}{-60}%
            \divide\value{xp} by 13%
            \addtocounter{xp}{\value{xpbonus}}%
            \renewcommand\showCR{\arabic{xp}}%
        }%
    % if the creature has a mind, print fate points (if any).
    %
    \addtocounter{fp}{\value{Charisma}}%
    \ifnum\value{fp}>3%
    \ignorespaces\arabic{fp}~\glsentrytext{fp}%
      \iftoggle{genExamples}%
        {}%
        {\space\Repeat{\value{fp}}{\Square}}%
    \par%
    \fi%
  }%
}

\newcommand\swarm[6][]%
  {
    \begin{tcolorbox}[
      title={\A\ Swarm: #2},
      before upper={\parindent0pt},
      ornamented,
      fontupper=\small,
      halign=flush left,
      left=10pt,
      right=15pt,
      top=0pt,
      bottom=0pt,
      ]
    \clean
    \setcounter{hp}{#3}
    \setcounter{Dexterity}{#4}
    \setcounter{att}{#4}
    \addtocounter{att}{10}
    \setcounter{Speed}{#5}
    \setcounter{ap}{#5}
    \addtocounter{ap}{3}
    \setcounter{Wits}{#6}
    \renewcommand\abilities{#1}

    \scshape
    \begin{tabularx}{.8\textwidth}{YYYY}
    \hiderowcolors

    \Gls{ap}: \arabic{ap} & Att: $\arabic{att} - HP$ 
    \iftoggle{verbose}{
      & Speed: \arabic{Speed}
      & Wits: \arabic{Wits}
    }{
      & Dam: 1
    }
    \\
    &
    \iftoggle{genExamples}%
      {HP: \arabic{hp}
      \\
      }%
      {\showBoxes }
      & \\ 
    \end{tabularx}

    \normalfont
    \ifdefempty{\abilities}{}{%
      \textbf{Abilities}: \abilities
      \vspace{1em}
    }%
    \end{tcolorbox}
  }


%%%%%%%%%%%%%%%%%%%% Creature Abilities

\newcommand{\abilities}{}

\newcommand\hide[1]{%
  \setcounter{dr}{#1}%
}

\newcommand\undead{%
  \addtocounter{Speed}{-1}%
  \addtocounter{Brawl}{2}%
  \renewcommand\abilities{%
    Undead%
    \ifnum\value{dr}>1%
      \stepcounter{dr}%
    \else%
      \setcounter{dr}{2}%
    \fi%
  }%
}

\newcommand{\acidSpray}{%
  Acidic Spray
  \setcounter{track}{4}%
  \addtocounter{track}{\value{Speed}}%
  (\dmg{track} Damage,
  \setcounter{track}{\value{Dexterity}}%
  \addtocounter{track}{8}%
  \glsentrytext{tn} \arabic{track} to dodge)%
}

\newcommand{\acidBody}{%
  Acidic Body (inflict
  \setcounter{track}{3}%
  \global\toggletrue{perfectArmour}%
  \addtocounter{track}{\value{Strength}}%
  \dmg{track} Damage each turn of grappling)%
}

\newcommand{\gelRegen}{%
  Regeneration (1 HP/ round, max. \setcounter{hp}{\value{Strength}}\addtocounter{hp}{6}\roundUp{hp} \arabic{hp})%
}

\newcommand\gloopy{%
  Viscid (on a tie, the attacker \emph{must} inflict Damage, but the weapon sticks into the body,
  \setcounter{track}{\value{Strength}}%
  \addtocounter{track}{7}%
  \tn[\arabic{track}] to pull out)%
}

\newcommand{\amphibious}{
	Amphibious%
}

\newcommand{\claws}{%
  Claws (+1~Damage)%
  \ifnum\value{Combat}>\value{Brawl}\else%
    \stepcounter{damage}%
  \fi%
}

\newcommand{\fireBreath}{%
  Fiery breath (equivalent to a torch)%
}

% To fly, creatures should have Speed
% + Dexterity greater than Strength +
% DR.

\newcommand{\flight}{%
  Flight %
  \setcounter{enc}{\value{dr}}%
  \roundUp{enc}%
  \addtocounter{enc}{\value{Strength}}%
  \setcounter{track}{\value{Speed}}%
  \addtocounter{track}{\value{Air}}%
  \ifnum\value{enc}>\value{track}%
    (can glide, but not fly)
  \else%
    \ifnum\value{enc}=\value{track}%
      (moves at x8 speed, must run before takeoff)%
    \else%
      \ignorespaces(moves at x8 speed)%
    \fi%
  \fi%
}

\newcommand{\stench}{%
  Stench (breathing in demands \roll{Strength}{Wyldcrafting} check, \glsentrytext{tn}
  \setcounter{track}{10}%
  \addtocounter{track}{-\value{Speed}}%
  \arabic{track},
  or take 3 \glspl{fatigue}%
  )
}

\newcommand{\crazyGas}{%
  Gas (hallucinations and
  \setcounter{track}{4}%
  \addtocounter{track}{\value{Strength}}%
  \arabic{track} \glspl{fatigue} per round)%
}

\newcommand{\quadraped}{%
  Quadraped (double movement)%
}

\newcommand{\teeth}{%
  Fangs%
}

\newcommand{\tentacles}{%
  \addtocounter{track}{3}%
  \divide\value{track} by 2%
  Tentacles \ifnum\value{track}>2%
    (grapple up to \arabic{track} opponents without becoming prone)%
  \fi%
}

\newcommand{\venom}{%
  Venom (grappling inflicts 1D6 Fatigue)%
}

\newcommand{\web}{%
  \setcounter{track}{6}\addtocounter{track}{\value{Strength}}%
  Web (Strength + Athletics, TN \arabic{track} to break free as a movement action)%
}

%%%%%%%%%%%%%%%%%%%%% Magic Path
\newcommand{\Spheres}[1]{ \\
	\raggedright \ent{Spheres:} & #1
}

\newcommand\mutation[1]{%
  \ifcase\value{#1}\relax%
    \hide{\value{r3}}%
  \or%
    \teeth%
  \or%
    \claws%
  \or%
    \venom%
  \or%
    \tentacles%
  \or%
    \web%
  \else%
    \flight%
  \fi%
}