Skip to content
Snippets Groups Projects
stats.sty 25.3 KiB
Newer Older
\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}

Malin Freeborn's avatar
Malin Freeborn committed
%      _        _   
%  ___| |_ __ _| |_ 
% / __| __/ _` | __|
% \__ \ || (_| | |_ 
% |___/\__\__,_|\__|
%                   
% 
%  _     _            _        
% | |__ | | ___   ___| | _____ 
% | '_ \| |/ _ \ / __| |/ / __|
% | |_) | | (_) | (__|   <\__ \
% |_.__/|_|\___/ \___|_|\_\___/
%                              
Malin Freeborn's avatar
Malin Freeborn committed
%
Malin Freeborn's avatar
Malin Freeborn committed
% 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}.
Malin Freeborn's avatar
Malin Freeborn committed
% 
% Most of the rest of the commands deal with
% properly calculating derived stats, like the TN
% to hit the creature.

Malin Freeborn's avatar
Malin Freeborn committed

\newtoggle{mind}
\newtoggle{creatureBox}
Malin Freeborn's avatar
Malin Freeborn committed
\newtoggle{examplecharacter}
\settoggle{examplecharacter}{false}
\newtoggle{debug}\settoggle{debug}{false}
\newcommand{\ent}[1]{\textbf{#1}}
\newcommand{\test}{}
\newcommand{\skills}{}
\newcommand{\equipment}{}
\newcommand{\mods}{}
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}%
  \setcounter{damagebonus}{\value{#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
}
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,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}}{
Malin Freeborn's avatar
Malin Freeborn committed
          HP \arabic{hp} \boxStat{hp} \\
          MP \arabic{mp} \boxStat{mp} \\
          SP \arabic{sp} \boxStat{sp} \\
        }
      \end{tabular}
    \fi
  \fi
Malin Freeborn's avatar
Malin Freeborn committed

%%%%%%%%%%%%%%%%%%%% 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
Malin Freeborn's avatar
Malin Freeborn committed

Malin Freeborn's avatar
Malin Freeborn committed
\newcounter{initiative}
\newcounter{weight}
Malin Freeborn's avatar
Malin Freeborn committed
\newcounter{maxWeight}
\newcounter{ap}
Malin Freeborn's avatar
Malin Freeborn committed
\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
%                                                _
%   ___ ___  _ __ ___  _ __ ___   __ _ _ __   __| |___
%  / __/ _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` / __|
% | (_| (_) | | | | | | | | | | | (_| | | | | (_| \__ \
%  \___\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|___/
% 


% magic
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\magicPath}{}
\newcommand{\knacks}[1]{\gdef\showKnacks{#1}}

\newcommand\showKnacks{}
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
\newcommand{\charge}{%
Malin Freeborn's avatar
Malin Freeborn committed
  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

Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\cuttingswing}{%
Malin Freeborn's avatar
Malin Freeborn committed
  Cutting Swing
Malin Freeborn's avatar
Malin Freeborn committed
  (when an opponent hits 0 \glspl{hp}, damage transfers to the next opponent)%
}
\newcommand{\dodger}{%
Malin Freeborn's avatar
Malin Freeborn committed
  Dodger
Malin Freeborn's avatar
Malin Freeborn committed
  (+\arabic{knacks} to dodge projectiles)%
}
\newcommand{\guardian}{%
  Guardian
  (spend 0 AP to guard someone, and gain +1 to guarding against attacks)%
}
\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 \setcounter{enc}{2}\addtocounter{enc}{\value{knacks}}\arabic{enc} AP)%
}
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
Malin Freeborn's avatar
Malin Freeborn committed
  \setcounter{enc}{\value{knacks}}\roundUp{enc} (reduce cost to draw longbow by \arabic{enc} AP)
Malin Freeborn's avatar
Malin Freeborn committed
}
\newcommand{\perfectsneakattack}{%
  Perfect Sneak Attack
  (+\arabic{knacks} Damage for sneak attacks)
}
\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
\newcommand{\stunningstrike}{%
  Stunning Strike
  (take -1 penalty, and opponent's AP reduces by half Damage)%
}
\newcommand{\snapshot}{%
  Snap Draw
Malin Freeborn's avatar
Malin Freeborn committed
  (Pay 0 AP to reload arrow or draw weapon)%
}
\newcommand{\unstoppable}{%
  \addtocounter{hp}{2}%
  Unstoppable
  (+2 \glsentryshortpl{hp}, and +\arabic{knacks} to any Medicine rolls to save them when dying)%
Malin Freeborn's avatar
Malin Freeborn committed
}
Malin Freeborn's avatar
Malin Freeborn committed

\newcommand{\vengeful}{%
  Vengeful%
  \iftoggle{examplecharacter}{ (+2 Intelligence after losing HP)}{}%
}

\newcommand{\weaponmaster}[1]{%
Malin Freeborn's avatar
Malin Freeborn committed
  \addtocounter{att}{1}%
  Weapon Master
Malin Freeborn's avatar
Malin Freeborn committed
  (+1 Attack when using a {#1})%
Malin Freeborn's avatar
Malin Freeborn committed
}
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\autophage}{%
  \addtocounter{knacks}{1}%
  Autophage
Malin Freeborn's avatar
Malin Freeborn committed
  (cast with \glspl{ep} instead of \glspl{mp})%
\newcommand{\snapcaster}{%
  \ifnum\value{Wits}>\value{Charisma}%
    \global\settoggle{snapCaster}{true}%
  \fi%
  Snap Caster
  (spells use Wits and cost 1 less \glsentrytext{ap})
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\ritualcaster}{%
  \addtocounter{knacks}{1}%
  Ritual Caster
  (spells use Intelligence, caster may spend 1 extra \gls{mp})
}

\newcommand{\fasthealer}{%
  Fast Healer
Malin Freeborn's avatar
Malin Freeborn committed
  (resting heals 2 additional \glspl{ep} and 1 \gls{mp})%
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\combatcaster}{Combat Caster}
\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]{%
  \setcounter{Strength}{#1}\setcounter{Dexterity}{#2}\setcounter{Speed}{#3}%
}

\newcommand{\mind}[3]{%
  \setcounter{Intelligence}{#1}\setcounter{Wits}{#2}\setcounter{Charisma}{#3}%
Malin Freeborn's avatar
Malin Freeborn committed
}

\newtoggle{snapCaster}
\settoggle{snapCaster}{true}
Malin Freeborn's avatar
Malin Freeborn committed
%

%%%%%%%%%%% Person
%
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\person}[9]{
  \settoggle{creatureBox}{true}
  \settoggle{mind}{true}
Malin Freeborn's avatar
Malin Freeborn committed
  \clean

  \setcounter{Strength}{#1}
	\setcounter{hp}{#1}
  \setcounter{Dexterity}{#2}
  \setcounter{Speed}{#3}
  \mind#4
  \setcounter{att}{#6}
Malin Freeborn's avatar
Malin Freeborn committed
  \setcounter{Combat}{#6}
  \renewcommand{\skills}{#7}
  \renewcommand{\equipment}{#8}

Malin Freeborn's avatar
Malin Freeborn committed
  \iftoggle{verbose}{
    \begin{tcolorbox}[
      title={\npcsymbol\ \name},
      before upper={\parindent0pt},
      ornamented,
      fontupper=\small,
      halign=flush left,
Malin Freeborn's avatar
Malin Freeborn committed
      left=5pt,
      right=5pt,
      top=0pt,
Malin Freeborn's avatar
Malin Freeborn committed
      bottom=0pt,
Malin Freeborn's avatar
Malin Freeborn committed
    \creaturestats

Malin Freeborn's avatar
Malin Freeborn committed
    \skillsEtc

    \derivedstats

    \end{tcolorbox}

Malin Freeborn's avatar
Malin Freeborn committed
  }{
    \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}
Malin Freeborn's avatar
Malin Freeborn committed

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

    \settoggle{personality}{false}}%
	{}
  \settoggle{creatureBox}{false}
  \setcounter{noAppearing}{1}
  \setcounter{wounds}{0}
  \renewcommand\abilities{}
Malin Freeborn's avatar
Malin Freeborn committed
  \global\togglefalse{perfectArmour}
Malin Freeborn's avatar
Malin Freeborn committed
  \renewcommand\npcQuote{}
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\animal}[9]{
  \settoggle{creatureBox}{true}
Malin Freeborn's avatar
Malin Freeborn committed
	\settoggle{mind}{false}
Malin Freeborn's avatar
Malin Freeborn committed
	\clean

	\setcounter{Strength}{#1}
	\setcounter{hp}{#1}
	\setcounter{Dexterity}{#2}
	\setcounter{Speed}{#3}
	\setcounter{Wits}{#4}
Malin Freeborn's avatar
Malin Freeborn committed
	\setcounter{dr}{#5}
	\setcounter{Brawl}{#6}
Malin Freeborn's avatar
Malin Freeborn committed
	\renewcommand{\skills}{#7}
	\renewcommand{\abilities}{#8}
Malin Freeborn's avatar
Malin Freeborn committed
  \setcounter{covering}{5}
Malin Freeborn's avatar
Malin Freeborn committed

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

    \iftoggle{personality}{
Malin Freeborn's avatar
Malin Freeborn committed

Malin Freeborn's avatar
Malin Freeborn committed
    \begin{minipage}{\linewidth}
    \textbf{Description:} \NPCdescription
Malin Freeborn's avatar
Malin Freeborn committed

    \textbf{Mannerism:} \mannerism
Malin Freeborn's avatar
Malin Freeborn committed
    \end{minipage}
Malin Freeborn's avatar
Malin Freeborn committed

    \vspace{1em}
Malin Freeborn's avatar
Malin Freeborn committed

    \settoggle{personality}{false}}%
    
Malin Freeborn's avatar
Malin Freeborn committed
    \creaturestats
Malin Freeborn's avatar
Malin Freeborn committed
    \skillsEtc%
    \derivedstats%
    \end{tcolorbox}%
Malin Freeborn's avatar
Malin Freeborn committed
  }{
    \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}
Malin Freeborn's avatar
Malin Freeborn committed

  \settoggle{creatureBox}{false}
Malin Freeborn's avatar
Malin Freeborn committed
  \renewcommand\abilities{}
Malin Freeborn's avatar
Malin Freeborn committed
  \global\togglefalse{perfectArmour}
  \setcounter{wounds}{0}
Malin Freeborn's avatar
Malin Freeborn committed
}

\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}
Malin Freeborn's avatar
Malin Freeborn committed
  \foreach \s in {dr,weaponDamage,weaponBonus,armourDR,armourWeight,fp,sp,heft,weight,damage,knacks,mp,xpbonus}%
    {\setcounter{\s}{0}}
Malin Freeborn's avatar
Malin Freeborn committed
}

%%       _   _        _ _           _            
%%  __ _| |_| |_ _ __(_) |__  _   _| |_ ___  ___ 
%% / _` | __| __| '__| | '_ \| | | | __/ _ \/ __|
%%| (_| | |_| |_| |  | | |_) | |_| | ||  __/\__ \
%% \__,_|\__|\__|_|  |_|_.__/ \__,_|\__\___||___/
%% 
%% 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.

Malin Freeborn's avatar
Malin Freeborn committed
\footnotesize
\begin{tabularx}{\textwidth}{lr@{\hskip 3em}lr@{\hskip 3em}lr}
Malin Freeborn's avatar
Malin Freeborn committed

% 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}  \\}{%
Malin Freeborn's avatar
Malin Freeborn committed
	&& Wits & \arabic{Wits} 
  &
  \ifnum\value{Charisma}>0
  Charisma & \arabic{Charisma}
  \fi
  \\
Malin Freeborn's avatar
Malin Freeborn committed
	}
Malin Freeborn's avatar
Malin Freeborn committed
\end{tabularx}
}

\newcommand\skillsEtc{
Malin Freeborn's avatar
Malin Freeborn committed
  \foreach \s in {Air,Earth,Fate,Fire,Water}%
    {\ifnum\value{\s}>0 \addtocounter{mp}{3}\fi}

Malin Freeborn's avatar
Malin Freeborn committed
\begin{tabular}{p{.18\textwidth}>{\raggedright\arraybackslash}p{.75\textwidth}}
  \hiderowcolors
  \iftoggle{verbose}{
    \ent{Skills} &
Malin Freeborn's avatar
Malin Freeborn committed
    \showSkills
      \skills \\
  }{}

  \ifdefempty{\showKnacks}{}{
    \ent{Knacks} & \showKnacks \\
Malin Freeborn's avatar
Malin Freeborn committed

  \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
Malin Freeborn's avatar
Malin Freeborn committed
      \ent{Equipment} & \equipment, \weaponName, \armourName \\
  \ifdefempty{\abilities}{}%
    {\ent{Abilities} & \abilities}
\end{tabular}
%%
%%
%%                               _        _       
%%  ___ ___  _ __ ___  _ __  ___| |_ __ _| |_ ___ 
%% / __/ _ \| '_ ` _ \| '_ \/ __| __/ _` | __/ __|
%%| (_| (_) | | | | | | |_) \__ \ || (_| | |_\__ \
%% \___\___/|_| |_| |_| .__/|___/\__\__,_|\__|___/
%%                    |_|                         
%%

\newcommand\computeStats{
  \setcounter{hp}{6}%
  \addtocounter{hp}{\value{Strength}}%
  % Stats for allies don't need to show Combat +1 as 'TN 8 to hit', they just need to show '+1'.
  \ifnum\value{Combat}>\value{Brawl}\else\setcounter{att}{\value{Brawl}}\fi%
  \iftoggle{allyCharacter}{}{%
    \addtocounter{att}{7}%
  }%
  \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%
  \setcounter{ap}{\value{Speed}}%
  \addtocounter{ap}{3}%
  \addtocounter{ap}{-\value{encumbrance}}%
Malin Freeborn's avatar
Malin Freeborn committed
  \addtocounter{att}{\value{Dexterity}}%
  \addtocounter{att}{\value{weaponBonus}}%
  \setcounter{damage}{\value{Strength}}%
  \addtocounter{damage}{4}%
  \addtocounter{damage}{\value{weaponDamage}}%
  \addtocounter{covering}{\value{att}}
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}}%
  }%
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}%
  \iftoggle{verbose}{\par\hrulefill}{}%
  \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}}{}
\begin{center}
  \iftoggle{verbose}{\normalsize}{\large}%
  \scshape AP \ifnum\value{ap}<1 $\frac{1}{2}$ \else \arabic{ap}\fi%
Malin Freeborn's avatar
Malin Freeborn committed
  \ifnumcomp{\value{heft}}{>}{1}{ (AP Cost: \arabic{heft})}{},
Malin Freeborn's avatar
Malin Freeborn committed
  Att %
  \iftoggle{allyCharacter}{$2D6$\ifnum\value{att}>-1 +\fi}{}%
Malin Freeborn's avatar
Malin Freeborn committed
  \arabic{att}%
  \setcounter{enc}{\value{att}}, %
Malin Freeborn's avatar
Malin Freeborn committed
  \setcounter{damage}{4}% Remove
  \addtocounter{damage}{\value{Strength}}% Remove
  \addtocounter{damage}{\value{weaponDamage}}% Remove
  \mbox{Dam \dmg{damage}, }%
    \ifnumcomp{\value{dr}}{>}{0}{%
Malin Freeborn's avatar
Malin Freeborn committed
      \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%
Malin Freeborn's avatar
Malin Freeborn committed
  }{%
Malin Freeborn's avatar
Malin Freeborn committed
    \par%
    \showBoxes%
Malin Freeborn's avatar
Malin Freeborn committed
  }%
  \iftoggle{allyCharacter}{}{%
    \iftoggle{examplecharacter}{}{%
      \calculateXP%
      \outline{\glsentrytext{cr}: \showCR}%
    }%
Malin Freeborn's avatar
Malin Freeborn committed
  }%
\end{center}%
}
Malin Freeborn's avatar
Malin Freeborn committed
%
%
%% __  ______  
%% \ \/ /  _ \ 
%%  \  /| |_) |
%%  /  \|  __/ 
%% /_/\_\_|    
%%  
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
  \setcounter{attackXPtotal}{\value{att}}%
  \multiply\value{attackXPtotal} by \value{damage}%
  \addtocounter{Speed}{-\value{heft}}%
  \ifnum\value{Speed}>\value{mp}%
    \setcounter{enc}{\value{Speed}}%
    \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}%
  {}%
Malin Freeborn's avatar
Malin Freeborn committed
    \ifnumcomp{\value{xp}}{<}{73}%
      {\ifnumcomp{\value{xp}}{<}{40}%
Malin Freeborn's avatar
Malin Freeborn committed
        {\renewcommand\showCR{\arabic{xpbonus}}}{\renewcommand\showCR{$\frac{1}{2}$}}}%
            \addtocounter{xp}{-60}%
            \divide\value{xp} by 13%
            \addtocounter{xp}{\value{xpbonus}}%
Malin Freeborn's avatar
Malin Freeborn committed
            \renewcommand\showCR{\arabic{xp}}%
Malin Freeborn's avatar
Malin Freeborn committed
        }%
    % if the creature has a mind, print fate points (if any).
    \ifnum\value{fp}>3%
Malin Freeborn's avatar
Malin Freeborn committed
      \addtocounter{fp}{\value{Charisma}}%
      \ignorespaces\arabic{fp}~\glsentrytext{fp}%
      \iftoggle{genExamples}%
        {}%
Malin Freeborn's avatar
Malin Freeborn committed
        {~\boxStat{fp}}%
Malin Freeborn's avatar
Malin Freeborn committed
}
Malin Freeborn's avatar
Malin Freeborn committed

\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}
Malin Freeborn's avatar
Malin Freeborn committed
    \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}%
      & \\ %
Malin Freeborn's avatar
Malin Freeborn committed
    \end{tabularx}
Malin Freeborn's avatar
Malin Freeborn committed

    \normalfont
Malin Freeborn's avatar
Malin Freeborn committed
    \ifdefempty{\abilities}{}{%
Malin Freeborn's avatar
Malin Freeborn committed
      \textbf{Abilities:} \abilities
Malin Freeborn's avatar
Malin Freeborn committed
    }%
Malin Freeborn's avatar
Malin Freeborn committed
    \vspace{2em}
    \end{tcolorbox}%
Malin Freeborn's avatar
Malin Freeborn committed
    \null
Malin Freeborn's avatar
Malin Freeborn committed
%%%%%%%%%%%%%%%%%%%% Creature Abilities

\newcommand{\abilities}{}
Malin Freeborn's avatar
Malin Freeborn committed

\newcommand{\Abilities}{}

\newcommand{\addAbility}[1]{\edef\Abilities{\Abilities{}#1, }}

Malin Freeborn's avatar
Malin Freeborn committed
\newcommand\hide[1]{%
Malin Freeborn's avatar
Malin Freeborn committed
  \ifnum\value{dr}>#1%
    \setcounter{track}{#1}%
    \roundUp{track}%
  \else%
    \setcounter{track}{\value{dr}}%
    \setcounter{dr}{#1}%
  \fi%
  \roundUp{track}%
  \addtocounter{dr}{\value{track}}%
  \setcounter{covering}{\value{att}}%
  \addtocounter{covering}{5}%
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand\undead{%
  \addtocounter{Speed}{-1}%
Malin Freeborn's avatar
Malin Freeborn committed
  \ifnum\value{Brawl}<3%
    \setcounter{Brawl}{2}%
  \fi%
Malin Freeborn's avatar
Malin Freeborn committed
  \renewcommand\abilities{%
    Undead%
    \ifnum\value{dr}>1%
      \stepcounter{dr}%
    \else%
      \setcounter{dr}{2}%
    \fi%
  }%
}

\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}%
  \addAbility{acid spray (\glsentrytext{tn}~\arabic{age} to dodge or \showDam~Damage)}%
}

\newcommand{\acidBody}{%
  \setcounter{track}{3}%
Malin Freeborn's avatar
Malin Freeborn committed
  \global\toggletrue{perfectArmour}%
  \addtocounter{track}{\value{Strength}}%
Malin Freeborn's avatar
Malin Freeborn committed
  \dmg{track}%
  \addAbility{acidic Body (inflict \conDmg~Damage each turn of grappling)}%
}

\newcommand{\gelRegen}{%
Malin Freeborn's avatar
Malin Freeborn committed
  \setcounter{track}{\value{Strength}}%
  \addtocounter{track}{6}%
  \roundUp{track}%
  \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}{%
	\addAbility{amphibious}%
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\claws}{%
  \ifnum\value{Combat}>\value{Brawl}\else%
    \stepcounter{damage}%
  \fi%
Malin Freeborn's avatar
Malin Freeborn committed
  \addAbility{claws (+1~Damage)}%
Malin Freeborn's avatar
Malin Freeborn committed
\newcommand{\fireBreath}{%
Malin Freeborn's avatar
Malin Freeborn committed
  \setcounter{track}{4}%
  \conDmg{track}%
  \setcounter{enc}{\value{hp}}%
  \addtocounter{enc}{\value{hp}}%
  \addAbility{fiery breath (range: \arabic{enc} \glspl{step}, Dam: \showDam\ifnum\value{mp}>0\ plus 1 per \glsentrytext{mp} spent\fi)}%
Malin Freeborn's avatar
Malin Freeborn committed
% 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
  \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{Flight %
Malin Freeborn's avatar
Malin Freeborn committed
  \ifnum\value{enc}>\value{track}%
    (can glide, but not fly)
Malin Freeborn's avatar
Malin Freeborn committed
    \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}}%
Malin Freeborn's avatar
Malin Freeborn committed
  \addAbility{Stench (breathing in demands \roll{Strength}{Wyldcrafting} 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{\quadraped}{%
Malin Freeborn's avatar
Malin Freeborn committed
  \addAbility{Quadraped (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%
  \addtocounter{enc}{\value{track}}%
  \roundUp{enc}%
  \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
  \randomfourB%
  \conDmg{r4b}%
  \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}}%
  \addAbility{web (\roll{Strength}{Athletics}, \glsentrytext{tn} \arabic{track} to break free for 1~\glsentrytext{ap})}%
Malin Freeborn's avatar
Malin Freeborn committed

%%%%%%%%%%%%%%%%%%%%% Magic Path
Malin Freeborn's avatar
Malin Freeborn committed
\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%
}