Skip to content
Snippets Groups Projects
stats.sty 23.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • \ProvidesPackage{config/stats}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%%%%%%%%%%%%%%%%% Introduction
    
    
    \newtoggle{genExamples}
    \settoggle{genExamples}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    \newtoggle{allyCharacter}
    \settoggle{allyCharacter}{false}
    
    
    \newtoggle{perfectArmour}
    \settoggle{perfectArmour}{false}
    
    
    \newtoggle{weaponMaster}
    \settoggle{weaponMaster}{false}
    
    
    \newcommand\showNumbers{
      \par
      Str: \arabic{Strength},
      Dex: \arabic{Dexterity},
      Spd: \arabic{Speed},
    
      Att: \arabic{toHit},
    
      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}
      \par
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      Armour DR: \arabic{armourDR}
      Armour Weight: \arabic{armourWeight}
    
    \newcommand\afterStatBlock{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \iftoggle{genExamples}{}{%
    
        \setcounter{enc}{\value{noAppearing}}%
        \addtocounter{enc}{4}%
        \needspace{\value{enc}\baselineskip}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \showBoxes%
        }%
    
      \ifdefempty{\NPCdescription}{\vfill\null}{%
    
        \raggedright%
    
        \textbf{Description:}~\NPCdescription.
        \textbf{Wants:}~\npcGoal.
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \textbf{Mannerism:}~\mannerism.
    
        \ifdefempty{\currentQuote}{}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \textbf{Quote:}~\textit{``\currentQuote''}%
    
        }%
        \par%
    
        \vspace{1em}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %      _        _   
    %  ___| |_ __ _| |_ 
    % / __| __/ _` | __|
    % \__ \ || (_| | |_ 
    % |___/\__\__,_|\__|
    %                   
    % 
    %  _     _            _        
    % | |__ | | ___   ___| | _____ 
    % | '_ \| |/ _ \ / __| |/ / __|
    % | |_) | | (_) | (__|   <\__ \
    % |_.__/|_|\___/ \___|_|\_\___/
    %                              
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    \newtoggle{mind}
    
    \newtoggle{creatureBox}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newtoggle{examplecharacter}
    \settoggle{examplecharacter}{false}
    \newcommand{\ent}[1]{\textbf{#1}}
    \newcommand{\equipment}{}
    
    \newcommand{\Abilities}{}
    
    \newcommand{\addAbility}[1]{\edef\Abilities{\Abilities{}#1.  }}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\Knacks}{}
    
    \newcommand{\Equipment}{}
    \newcommand{\addEquipment}[1]{\edef\Equipment{\Equipment{}#1, }}
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\showCR{}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\absNum[1]{\ifnum\value{#1}>-1+\fi\arabic{#1}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % 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}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \set{damagebonus}{#1}%
    
      \addtocounter{damagebonus}{-4}%
      \whileboolexpr{%
        test {\ifnumcomp{\value{damagebonus}}{>}{3}}%
      }{%
    
        \addtocounter{damagebonus}{-4}%
    
        \addtocounter{numberofdice}{1}%
      }%
    }
    
    \newcommand\showDam{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \arabic{numberofdice}D6\ifnum\value{damagebonus}=0\else\absNum{damagebonus}\fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand\dmg[1]{\conDmg{#1}\showDam}
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\showSkills{
    
        \foreach \s in {Projectiles,Melee,Brawl,Academics,Athletics,Caving,Crafts,Cultivation,Deceit,Empathy,Flight,Medicine,Performance,Larceny,Seafaring,Stealth,Survival,Vigilance}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          {\ifnum\value{\s}>0 \s~\arabic{\s}, \fi}
    }
    
    
    \newcommand\traits[7]{%
      \clean%
      \randomize%
    
      \body#2%
      \mind#3%
      #4%
      \foreach \k in {#5}{%
        \stepcounter{knacks}%
      }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{knacksPlusTwo}{\value{knacks}}%
      \addtocounter{knacksPlusTwo}{2}%
      \edef\Knacks{#5}%
    
      \foreach \s in {Air,Earth,Fate,Fire,Water}%
        {\ifnum\value{\s}>0 \addtocounter{mp}{3}\fi}%
      \renewcommand\equipment{#6}%
      #7%
    
      \computeStats%
    
      \computeEncumbrance%
    }
    
    \newcommand\statblock[1]{
        \begin{tcolorbox}[
    
          before={\vspace{.5em}\begin{minipage}{\linewidth}},
    
          code={\setlength\parindent{0pt}#1},
    
          title={\npcsymbol~\name},
    
          after={\afterStatBlock\end{minipage}},
    
          ornamented,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          size=fbox,
    
          fontupper=\small,
          halign=flush left,
          ]
          \creaturestats
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \begin{tabularx}{\linewidth}{rL}
    
          \hiderowcolors
    
          \ent{Skills} & \showSkills \\
          \ifnum\value{mp}>0%
            \ent{Spheres} &
            \foreach \s in {Air,Earth,Fate,Fire,Water}%
              {\ifnum\value{\s}>0 \s~\arabic{\s}, \fi}
            \\
          \fi
          \ifnum\value{knacks}>0
    
    Malin Freeborn's avatar
    Malin Freeborn committed
            \ent{Knacks} & \Knacks \\
    
          \fi
          \ifdefempty{\Abilities}{}{%
            \ent{Abilities} & \Abilities \\
          }
          \ifdefempty{\equipment}{}{%
            \ent{Equipment} &
            \ifdefempty{\weaponName}{}{%
              \weaponName, %
            }%
            \ifdefempty{\armourName}{}{%
              \armourName, %
            }%
            \equipment.
          }%
          \end{tabularx}
          \tcblower%%%%%%%%%%%%%%%%%%%%
    
          \derivedstats\null
    
        \end{tcolorbox}
    }
    
    \newcommand\Animal[6]{
      \statblock{
        \traits{#1}%
          {#2}%
          {{-6}{#3}{-6}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          {#5}% SKILLS
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          {}% KNACKS
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\Person[7]{
      \statblock{
        \traits{#1}%
          {#2}%
          {#3}%
          {%
            #4
          }% SKILLS
          {#5}% KNACKS
          {#6}% EQUIPMENT
          {#7}% ABILITIES
      }
    
      \setcounter{wounds}{0}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\showBoxes{%
    
      \ifnum\value{noAppearing}=1\fpStat\qquad\fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{mp}>0%
    
        {\centering\Repeat{\value{noAppearing}}{\hpStat\quad\mpStat\qquad}}%
    
      \else%
    
        {\centering\Repeat{\value{noAppearing}}{\hpStat\quad}}%
    
      \vfill\null\par%
    
    \newcounter{wounds}
    \setcounter{wounds}{0}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{freeHP}
    \setcounter{freeHP}{0}
    
    
    \newcommand\boxStat[1]{%
    
      \Repeat{\value{#1}}{\Square}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\hpStat{%
    
      \Repeat{\value{weight}}{\glsentrysymbol{weight}}%
      \Repeat{\value{freeHP}}{\glsentrysymbol{hp}}%
      \Repeat{\value{wounds}}{\makebox[0pt]{\hspace{.7em}\checked}\glsentrysymbol{hp}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\mpStat{%
    
      \Repeat{\value{mp}}{\glsentrysymbol{mp}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\fpStat{%
      \Repeat{\value{fp}}{\glsentrysymbol{fp}}%
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%%%%%%%%%%%%%%%%% Character Generation %%%%%%%%%%%%%%%%%%%%
    %
    %                       _                
    %  ___ ___  _   _ _ __ | |_ ___ _ __ ___ 
    % / __/ _ \| | | | '_ \| __/ _ \ '__/ __|
    %| (_| (_) | |_| | | | | ||  __/ |  \__ \
    % \___\___/ \__,_|_| |_|\__\___|_|  |___/
    %                                        
    %
    % Attributes: str, dex, spd, int, wts, cha
    % secondary str, dex and spd
    \newcounter{att}
    
    \newcounter{toHit}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{dr}
    \newcounter{knacks}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcounter{knacksPlusTwo}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    % Extras: MP hp fp
    % Derived: dicenumber, dicebonus,
    \newcounter{mp}
    \newcounter{hp}
    \newcounter{fp}
    \newcounter{numberofdice}
    \newcounter{damagebonus}
    \newcounter{xp}
    \newcounter{xpbonus}
    \newcounter{attackXPtotal}
    
    \newcounter{defenceXPtotal} %rem
    
    \newcounter{weight}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \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}
    
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %                                                _
    %   ___ ___  _ __ ___  _ __ ___   __ _ _ __   __| |___
    %  / __/ _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` / __|
    % | (_| (_) | | | | | | | | | | | (_| | | | | (_| \__ \
    %  \___\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|___/
    % 
    
    
    %%%%%%%%%%%%%%%%%%%%% Knacks
    %
    
    \newcommand{\adrenalinesurge}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      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)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\brawler}{%
    
      Brawler (+2 to unarmed attacks)
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\charge}{%
    
      Fast Charge (+1 \glsentrytext{ap}, Attack, and Damage after charging 6 steps)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\cuttingswing}{%
    
      Cutting Swing (when an opponent hits 0 \glspl{hp}, damage transfers to the next opponent)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\dodger}{%
    
      Dodger (+\arabic{knacks} to dodge projectiles)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\guardian}{%
    
      Guardian (spend 0~\glsfmtplural{ap} to guard someone, and gain +1 to guarding against attacks)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\laststand}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      Last~Stand
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      (when losing \glspl{hp}, the character gains \arabic{knacksPlusTwo}~\glspl{ap})%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\lucky}{%
      \addtocounter{fp}{4}%
    
      Lucky (add 4~\glsentryshortpl{fp})%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand{\mightydraw}{%
    
      Mighty Draw \setcounter{encnum}{\value{knacks}}%
      \divide\value{encnum}by 2%
      (reduce cost to draw longbow by%
      \ifnum\value{encnum}=0\stepcounter{encnum}\fi \arabic{encnum}~\glsfmtplural{ap})%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\perfectsneakattack}{%
    
      Perfect Sneak Attack (+\arabic{knacks} Damage for sneak attacks)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\precisestrike}{%
    
      Precise Strike (+1 Attack when calculating \pgls{vitalShot})%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\specialist}[1]{%
    
      Specialist \iftoggle{examplecharacter}{ (+2 when using any #1)}{(#1)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\stunningstrike}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      Stunning Strike (hit an opponent with fewer \glsfmtplural{ap}, and take a -1 Penalty to attack; opponent's \glsfmtplural{ap} reduces by \arabic{knacks})%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\snapshot}{%
    
      Snap Draw (Pay 0 \glsfmtplural{ap} to reload bow or draw weapon)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\unstoppable}{%
      \addtocounter{hp}{2}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{freeHP}{2}%
    
      Unstoppable %
    
      (+2 \glsentryshortpl{hp}%
        \ifnum\value{Intelligence}>-5, and +\arabic{knacks} to any Medicine rolls to save them when dying%
      \fi)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    \newcommand{\vengeful}{%
    
      Vengeful (+2~\iftoggle{snapCaster}{Wits}{Charisma} after losing~\glsfmtplural{hp})%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    
    \newcommand{\weaponmaster}{%
      Weapon Master (+1 to \weaponName\ attacks)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\autophage}{%
    
      Autophage (cast with \glspl{ep} instead of \glsfmtplural{mp})%
    
    \newcommand{\snapcaster}{%
    
      \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}{%
    
      Fast Healer (resting heals one more \glsentrytext{ep} or~\glsentrytext{mp})%
    
    \newcommand{\chosenEnemy}[1]{%
      Chosen Enemy (+1 against #1, -2 when trying to be friendly)%
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % _ __   ___ _ __ ___  ___  _ __  
    %| '_ \ / _ \ '__/ __|/ _ \| '_ \ 
    %| |_) |  __/ |  \__ \ (_) | | | |
    %| .__/ \___|_|  |___/\___/|_| |_|
    %|_|                              
    % 
    %
    %       _                          _            
    %%  ___| |__   __ _ _ __ __ _  ___| |_ ___ _ __ 
    %% / __| '_ \ / _` | '__/ _` |/ __| __/ _ \ '__|
    %%| (__| | | | (_| | | | (_| | (__| ||  __/ |   
    %% \___|_| |_|\__,_|_|  \__,_|\___|\__\___|_|   
    %%                                              
    %%  optional counters, such as mana, are cleaned
    %%  clear: weaponsknack1 and 2, 
    %% 
    %
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\body}[3]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifltxcounter{#1}{\setcounter{Strength}{\value{#1}}}{\setcounter{Strength}{#1}}%
      \ifltxcounter{#2}{\setcounter{Dexterity}{\value{#2}}}{\setcounter{Dexterity}{#2}}%
      \ifltxcounter{#3}{\setcounter{Speed}{\value{#3}}}{\setcounter{Speed}{#3}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand{\mind}[3]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifltxcounter{#1}{\setcounter{Intelligence}{\value{#1}}}{\setcounter{Intelligence}{#1}}%
      \ifltxcounter{#2}{\setcounter{Wits}{\value{#2}}}{\setcounter{Wits}{#2}}%
      \ifltxcounter{#3}{\setcounter{Charisma}{\value{#3}}}{\setcounter{Charisma}{#3}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    
    \newtoggle{snapCaster}
    \settoggle{snapCaster}{true}
    
    \newcommand{\clean}{%
      \global\togglefalse{snapCaster}%
    
      \global\togglefalse{weaponMaster}%
    
      \foreach \s in {Air,Earth,Fate,Fire,Water,Projectiles,Melee,Brawl,Academics,Alchemy,Athletics,Caving,Crafts,Cultivation,Deceit,Empathy,Flight,Medicine,Performance,Larceny,Seafaring,Stealth,Survival,Vigilance}%
    
        {\setcounter{\s}{0}}%
    
      \foreach \s in {encumbrance,dr,covering,weaponDamage,weaponBonus,weaponWeight,armourWeight,armourDR,armourWeight,fp,heft,weight,damage,knacks,mp,xpbonus,xp}%
    
        {\setcounter{\s}{0}}%
      \setcounter{noAppearing}{1}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    %%       _   _        _ _           _            
    %%  __ _| |_| |_ _ __(_) |__  _   _| |_ ___  ___ 
    %% / _` | __| __| '__| | '_ \| | | | __/ _ \/ __|
    %%| (_| | |_| |_| |  | | |_) | |_| | ||  __/\__ \
    %% \__,_|\__|\__|_|  |_|_.__/ \__,_|\__\___||___/
    %% 
    %% Print the line,
    %% print the attributes.
    %% print the skills
    %% print the knacks
    %% print the equipment
    %
    \newcommand{\creaturestats}{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \footnotesize
      \begin{tabularx}{\textwidth}{lr@{\hskip 3em}lr@{\hskip 3em}lr}
      \hiderowcolors
        Strength & \arabic{Strength} & Dexterity & \arabic{Dexterity} & Speed & \arabic{Speed} \\
        \ifnum\value{Intelligence}>-6 Intelligence\fi &
        \ifnum\value{Intelligence}>-6 \arabic{Intelligence}\fi &
        Wits & \arabic{Wits} &
        \ifnum\value{Charisma}>-6 Charisma\fi &
        \ifnum\value{Charisma}>-6 \arabic{Charisma}\fi
        \\
      \end{tabularx}
    
    %%
    %%
    %%                               _        _       
    %%  ___ ___  _ __ ___  _ __  ___| |_ __ _| |_ ___ 
    %% / __/ _ \| '_ ` _ \| '_ \/ __| __/ _` | __/ __|
    %%| (_| (_) | | | | | | |_) \__ \ || (_| | |_\__ \
    %% \___\___/|_| |_| |_| .__/|___/\__\__,_|\__|___/
    %%                    |_|                         
    %%
    
    \newcommand\computeStats{
    
      \setcounter{hp}{6}%
      \addtocounter{hp}{\value{Strength}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{hp}{-\value{wounds}}%
    
      % Stats for allies don't need to show Melee +1 as 'TN 8 to hit', they just need to show '+1'.
    
      \ifnum\value{weaponBonus}>0%
        \set{att}{Melee}%
        \iftoggle{weaponMaster}{\stepcounter{att}}{}%
      \else%
        \set{att}{Brawl}%
      \fi%
    
      \ifnum\value{att}<0\setcounter{att}{0}\fi%
    
      \addtocounter{att}{\value{Dexterity}}%
      \addtocounter{att}{\value{weaponBonus}}%
      \set{toHit}{att}%
      \addtocounter{toHit}{7}%
    
      \setcounter{ap}{\value{Speed}}%
      \addtocounter{ap}{3}%
      \addtocounter{ap}{-\value{encumbrance}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{damage}{\value{Strength}}%
      \addtocounter{damage}{4}%
      \addtocounter{damage}{\value{weaponDamage}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \iftoggle{allyCharacter}{}{%
        \addtocounter{covering}{\value{toHit}}%
      }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnumcomp{\value{dr}}{>}{\value{armourDR}}%
      {%
        \divide\value{armourDR} by 2%
        \addtocounter{dr}{\value{armourDR}}%
      }{%
        \divide\value{dr} by 2%
        \addtocounter{dr}{\value{armourDR}}%
      }%
    
      \addtocounter{fp}{\value{Charisma}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\computeEncumbrance{%
      \setcounter{maxWeight}{\value{hp}}% now to compute encumbrance
      \roundUp{maxWeight}%
      \ifnum\value{armourWeight}>\value{maxWeight}%
        \addtocounter{encumbrance}{\value{armourWeight}}%
        \addtocounter{encumbrance}{-\value{maxWeight}}%
      \fi%
      \ifnum\value{weaponWeight}>\value{maxWeight}%
        \addtocounter{encumbrance}{\value{weaponWeight}}%
        \addtocounter{encumbrance}{-\value{maxWeight}}%
      \fi%
      \ifnum\value{weight}>\value{maxWeight}%
        \addtocounter{encumbrance}{\value{weight}}%
        \addtocounter{encumbrance}{-\value{weight}}%
      \fi%
      \addtocounter{weight}{\value{weaponWeight}}%
      \addtocounter{weight}{\value{armourWeight}}%
      \ifnum\value{weight}>\value{hp}%
        \addtocounter{encumbrance}{\value{weight}}%
        \addtocounter{encumbrance}{-\value{hp}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \setcounter{freeHP}{0}%
      \else%
        \setcounter{freeHP}{\value{hp}}%
        \addtocounter{freeHP}{-\value{weight}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \fi%
      \addtocounter{ap}{-\value{encumbrance}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{toHit}{-\value{encumbrance}}%
    
      \addtocounter{weight}{-\value{encumbrance}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%     _               _        _
    %%  __| | ___ _ __ ___| |_ __ _| |_ ___ 
    %% / _` |/ _ \ '__/ __| __/ _` | __/ __|
    %%| (_| |  __/ |  \__ \ || (_| | |_\__ \
    %% \__,_|\___|_|  |___/\__\__,_|\__|___/
    %% 
    %% 
    %% dice instead of Damage
    %% print out att, spd, DAM, dex, dr (type), str
    %%
    %
    
    \newcommand{\derivedstats}{%
      \setlength\topsep{0pt}%
      \setlength\parskip{0pt}%
    
      \begin{center}
        \iftoggle{verbose}{\normalsize}{\large}%
        \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$\absNum{att}}{\arabic{toHit}},\space%
        \mbox{Dam \dmg{damage},\space}%
    
          \ifnumcomp{\value{dr}}{>}{0}{%
            \mbox{DR \arabic{dr}%
            \iftoggle{perfectArmour}%
              {}%
              { (\arabic{covering}!)}, }%
          }{}%
    
        \iftoggle{genExamples}{%
          HP~\arabic{hp},
          \ifnum\value{mp}>0%
            MP \arabic{mp},
          \fi%
        }{}
        \iftoggle{genExamples}{%
          \ifnum\value{Intelligence}>-1%
            \Glsentrytext{weight}~held~\arabic{weight},%
          \fi%
        }{}
        {\hfil\small\textcolor{\pageSideColor}{\calculateXP}}%
    
      \end{center}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %
    %
    %% __  ______  
    %% \ \/ /  _ \ 
    %%  \  /| |_) |
    %%  /  \|  __/ 
    %% /_/\_\_|    
    %%  
    
    \newcommand{\calculateXP}{%
    
      %%% Now to get the XP value of the creature's attack ability.
      %%% = Attack (TN) * Dam + max((spd-hef),mp)^2
    
      \iftoggle{allyCharacter}{}{%
        \iftoggle{examplecharacter}{}{%
    
          \setcounter{attackXPtotal}{\value{toHit}}%
          \multiply\value{attackXPtotal} by \value{damage}%
          \multiply\value{attackXPtotal} by \value{ap}%
          \divide\value{attackXPtotal} by 50%
          \addtocounter{attackXPtotal}{-\value{heft}}%
          \setcounter{defenceXPtotal}{\value{hp}}%
          \multiply\value{defenceXPtotal} by \value{dr}%
          \divide\value{defenceXPtotal} by 10%
          \setcounter{enc}{\value{mp}}%
          \divide\value{enc} by 2%
          \addtocounter{defenceXPtotal}{\value{enc}}%
          \addtocounter{xp}{\value{attackXPtotal}}%
          \addtocounter{xp}{\value{defenceXPtotal}}%
          \ifnum\value{xp}<0\setcounter{xp}{0}\fi
    
          \glsentrytext{cr}~\arabic{xp}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    \newcommand\swarm[6][]%
    
    {
      \begin{tcolorbox}[
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        title={\Sw\ #2},
    
        before upper={\parindent0pt},
        ornamented,
        fontupper=\small,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        left=3pt,
        right=3pt,
    
        top=0pt,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        bottom=10pt,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \randomize
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \set{hp}{#3}
      \set{Dexterity}{#4}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \set{toHit}{#4}
      \addtocounter{toHit}{10}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \set{Speed}{#5}
      \set{ap}{#5}
    
      \addtocounter{ap}{3}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{dr}{8}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \set{Wits}{#6}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      #1
      \set{freeHP}{hp}
    
      \scshape
      \begin{tabularx}{.8\textwidth}{YYYY}
      \hiderowcolors
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \Gls{ap}: \arabic{ap} & Att: $\arabic{toHit} - HP$ 
    
      \iftoggle{verbose}{
        & Speed: \arabic{Speed}
        & Wits: \arabic{Wits}
      }{
        & Dam: 1
      }
      \\
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \end{tabularx}%
      \par\qquad%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      HP:~\iftoggle{genExamples}%
        {\arabic{hp}}%
        {\hpStat}%
    
      \ifdefempty{\Abilities}{}{%
        \normalfont
        \par\textbf{Abilities:} \Abilities
      }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      {\hfil\small\textcolor{\pageSideColor}{\calculateXP}}%
    
      \end{tcolorbox}%
    }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    %%%%%%%%%%%%%%%%%%%% Creature Abilities
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\hide[1]{%
    
      \set{dr}{#1}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{weight}{\value{dr}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{covering}{5}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\undead{%
    
      \addtocounter{Speed}{-1}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \set{Charisma}{-5}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{Brawl}<3%
        \setcounter{Brawl}{2}%
      \fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{dr}>1%
        \stepcounter{dr}%
      \else%
        \setcounter{dr}{2}%
      \fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \set{covering}{5}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{weaponWeight}{0}% Stop EP showing.
      \setcounter{armourWeight}{0}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Undead}%
    
    \newcommand{\acidSpray}{%
      \setcounter{track}{4}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{track}{\value{Strength}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{age}{7}%
      \addtocounter{age}{\value{Dexterity}}%
    
      \addtocounter{age}{\value{Projectiles}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \conDmg{track}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Acid spray (\glsentrytext{tn}~\arabic{age} to dodge or \showDam~Damage)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\acidBody}[1][Acidic]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \toggletrue{perfectArmour}%
      \set{track}{Strength}%
      \addtocounter{track}{3}%
      \conDmg{track}%
      \addAbility{#1 body (inflict \showDam~Damage each turn of grappling)}%
    
    }
    
    \newcommand{\gelRegen}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{track}{\value{Strength}}%
      \addtocounter{track}{6}%
      \roundUp{track}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Regeneration (1 \glsentrytext{hp}/ round, max. \arabic{track})}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\viscid{%
    
      \setcounter{track}{\value{Strength}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{track}{7}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Viscid (on a tie, the attacker must inflict Damage, but the weapon sticks into the body, \glsentrytext{tn}~\arabic{track}  to pull out)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\gloopy{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Liquid (non-fire Damage removes 2~\glsentrytext{hp} but creates a 1~\glsentrytext{hp} copy)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\amphibious}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    	\addAbility{Amphibious}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\claws}{%
    
      \ifnum\value{weaponDamage}<1%
        \stepcounter{weaponDamage}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Claws (+1~Damage)}%
    
    \newcommand{\fireBreath}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{track}{4}%
      \conDmg{track}%
      \setcounter{enc}{\value{hp}}%
      \addtocounter{enc}{\value{hp}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Fiery breath (range: \arabic{enc} \glspl{step}, Dam: \showDam\ifnum\value{mp}>0\ plus 1 per \glsentrytext{mp} spent\fi)}%
    
    % To fly, creatures should have Speed
    % + Dexterity greater than Strength +
    % DR.
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\flight}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{weight}{\value{maxWeight}}%
    
      \setcounter{enc}{\value{dr}}%
    
      \roundUp{enc}%
    
      \addtocounter{enc}{\value{Strength}}%
    
      \setcounter{track}{\value{Speed}}%
      \addtocounter{track}{\value{Air}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Wings %
    
      \ifnum\value{enc}>\value{track}%
        (can glide, but not fly)
    
        \ifnum\value{enc}=\value{track}%
          (moves at x8 speed, must run before takeoff)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          (moves at x8 speed)%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      }%
    
    }
    
    \newcommand{\stench}{%
      \setcounter{track}{10}%
    
      \addtocounter{track}{-\value{Speed}}%
    
      \addAbility{Stench (breathing in demands \roll{Strength}{Survival} check, \glsentrytext{tn}~\arabic{track},
    
      or take 3~\glspl{ep})}%
    
    }
    
    \newcommand{\crazyGas}{%
      \setcounter{track}{4}%
    
      \addtocounter{track}{\value{Strength}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Gas (receive hallucinations and \arabic{track}~\glspl{ep} per round)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\quadruped}{%
      \addAbility{Quadruped (double movement)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\hexapod}{%
      \addAbility{Hexapod (double movement)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\octopod}{%
      \addAbility{Octopod (double movement)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\teeth}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Fangs}%
    
    }
    
    \newcommand{\tentacles}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{track}{2}%
      \addtocounter{track}{\value{Strength}}%
      \addtocounter{track}{\value{Dexterity}}%
      \ifnum\value{track}<2\setcounter{track}{2}\fi%
    
      \set{enc}{track}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \roundUp{enc}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addtocounter{weight}{\value{track}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{\arabic{track}~tentacles (grapple up to \arabic{enc} opponents without going prone)}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\venom}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \conDmg{r4b}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Venom (grappling attack inflicts \showDam~\glsfmtlongpl{ep})}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand{\web}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{track}{8}%
      \addtocounter{track}{\value{Strength}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \addAbility{Web (\roll{Strength}{Athletics}, \glsentrytext{tn}~\arabic{track} to break free for 1~\glsentrytext{ap})}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{Strength}>0%
        \addtocounter{weight}{\value{Strength}}%
      \fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    %%%%%%%%%%%%%%%%%%%%% Magic Path
    
    \newcommand{\Spheres}[1]{ \\
    
      \raggedright \ent{Spheres} & #1
    }
    
    \newcommand\mutation[2][1]{%
      \Repeat{#1}{%
        \ifcase\value{#2}\relax%
          \hide{\value{r3}}%
        \or%
          \teeth%
        \or%
          \claws%
        \or%
          \venom%
        \or%
          \amphibious%
        \or%
          \tentacles%
        \or%
          \web%
        \else%
          \flight%
        \fi%
        \stepcounter{#2}%
      }%
    
    
    %%%%%%%%%%%%%%%%%%%% Human Names
    
    \newcounter{humanNameNo}
      \setcounter{humanNameNo}{\value{r12}}
    \newcounter{humanNameSuffNo}
      \setcounter{humanNameSuffNo}{\value{r4}}
    
    \newcommand\humanNamePrefix{%
      \randomfour%
      \addtocounter{humanNameNo}{\value{r4}}%
      \ifnum\value{humanNameNo}>19\addtocounter{humanNameNo}{-19}\fi%
      \expandafter\expandafter\ifcase\value{humanNameNo}\relax%
      \or%
        Grit%
      \or%
        Rank%
      \or%
        Scour%
      \or%
        Steer%
      \or%
        Mush%
      \or%
        Stoat%
      \or%
        Court%
      \or%
        Glum%
      \or%
        Flic%
      \or%
        Dug%
      \or%
        Nark%
      \or%
        Nettle%
      \or%
        Slate%
      \or%
        Gourse%
      \or%
        Cinder%
      \or%
        Soot%
      \or%
        Moc%
      \or%
        Keel%
      \else%
        Gout%
      \fi%
    }
    
    \newcommand\humanNameSuffix{%
      \randomthreeB%
      \addtocounter{humanNameSuffNo}{\value{r3b}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{humanNameSuffNo}>20\addtocounter{humanNameSuffNo}{-20}\fi%
    
      \ifcase\value{humanNameSuffNo}\relax%
      \or%
        itch%
      \or%
        vore%
      \or%
        snag%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \or%
        derth%
    
      \or%
        peel%
      \or%
        groat%
      \or%
        fen%
      \or%
        nash%
      \or%
        nail%
      \or%
        rash%
      \or%
        flay%
      \or%
        boak%
      \or%
        broil%
      \or%
        pike%
      \or%
        filch%
      \or%
        snatch%
      \or%
        flea%
      \or%
        fray%
      \or%
        rag%
      \else%
        blathe%
      \fi%
    }
    
    \newcommand\composeHumanName{%
      \humanNamePrefix\humanNameSuffix%
    }