Skip to content
Snippets Groups Projects
magic.sty 10.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Malin Freeborn's avatar
    Malin Freeborn committed
    % 
    %  __  __             _      
    % |  \/  | __ _  __ _(_) ___ 
    % | |\/| |/ _` |/ _` | |/ __|
    % | |  | | (_| | (_| | | (__ 
    % |_|  |_|\__,_|\__, |_|\___|
    %               |___/        
    
    
    \makeindex[name=talismans,title={Talisman Summaries},columns=2]
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    % Some spells inflict X fatigue, where X is the spell level plus 2.
    
    \newcounter{spellCost}
    
      \setcounter{spellCost}{1}
    
    \newcounter{spellPlusOne}
      \setcounter{spellPlusOne}{1}
    
    \newcounter{spellPlusTwo}
      \setcounter{spellPlusTwo}{1}
    
    \newcounter{spellPlusThree}
      \setcounter{spellPlusThree}{1}
    
    \newcounter{castingBonus}
      \setcounter{castingBonus}{1}
    
    
    \newcommand\spellName{}
    \newcommand\spellEnhancements{}
    \newcommand\spellAction{}
    \newcommand\spellSphere{}
    \newcommand\spellResistance{}
    \newcommand\spellSum{}
    \newcommand\spellNotes{}
    
    
    \newcounter{spellTargets}
    \setcounter{spellTargets}{1}
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\showOnset{%
      \ifcase\value{spellCost}\relax%
      Error%
      \or%
      Error%
      \or%
      \gls{interval}%
      \or%
      day%
      \or%
      week%
      \or%
      season%
      \else%
      \gls{cycle}%
      \fi%
    }
    
    
    \newcommand\setSpellDamage{%
      \iftoggle{Divergent}{%
        \ifnum\value{encnum}=2
          \conDmg{spellPlusTwo}%
        \else%
          \conDmg{spellPlusOne}%
        \fi%
      }{%
        \ifnum\value{encnum}=1
          \conDmg{spellPlusTwo}%
        \else%
          \conDmg{spellPlusOne}%
        \fi%
      }%
    }
    
    
    \newcommand\setLongRange[1][spellCost]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \ifcase\value{spellCost}\relax%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \or%
    
          \renewcommand\spellRange{20 \glspl{step}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \or%
    
            \renewcommand\spellRange{greeting distance}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \or%
    
            \renewcommand\spellRange{yelling distance}%
    
            \renewcommand\spellRange{an arrow's reach}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \or%
    
            \renewcommand\spellRange{walking distance}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \else%
    
            \renewcommand\spellRange{the horizon}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \fi%
    
    }
    
    \newcommand\spellRange{}
    \newcommand\setRange{%
      \iftoggle{Distant}%
        {%
          \setLongRange%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        }%
        {%
    
          \setcounter{track}{24}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \Repeat{\arabic{spellCost}}{\addtocounter{track}{-4}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \ifnum\value{track}<1%
            \renewcommand\spellRange{touch}%
          \else%
            \renewcommand\spellRange{\arabic{track}~steps}%
          \fi%
        }%
    }
    
    
    %%%
    
    \newtoggle{fullSpells}
      \settoggle{fullSpells}{true}
    
    \newtoggle{talisman}
      \settoggle{talisman}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newtoggle{insubstantial}
      \settoggle{insubstantial}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newtoggle{Devious}
      \settoggle{Devious}{false}
    
    \newtoggle{Distant}
      \settoggle{Distant}{false}
    
    \newtoggle{Divergent}
      \settoggle{Divergent}{false}
    
    \newtoggle{Duplicated}
      \settoggle{Duplicated}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newtoggle{opposedSpell}
      \settoggle{opposedSpell}{false}
    
    \newcommand\setTargetsIfDuplicated{%
      \setcounter{spellTargets}{1}%
      \iftoggle{Duplicated}{%
        \foreach \i in {1,...,\arabic{spellCost}}%
          {\multiply\value{spellTargets} by \value{spellCost}\addtocounter{spellTargets}{0}}%
      }{}%
    }
    
    \newcommand\calcSpell[7]{%
      \renewcommand\spellName{#1}%
      \setcounter{spellCost}{1}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \togglefalse{Devious}%
    
      \togglefalse{Distant}%
    
      \togglefalse{Divergent}%
    
      \togglefalse{Duplicated}%
    
      \foreach \d in {#2}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \ifdefstring{\d}{Devious}{\global\toggletrue{Devious}}{}%
    
        \ifdefstring{\d}{Distant}{\global\toggletrue{Distant}}{}%
    
        \ifdefstring{\d}{Divergent}{\global\toggletrue{Divergent}}{}%
    
        \ifdefstring{\d}{Duplicated}{\global\toggletrue{Duplicated}}{}%
    
        \stepcounter{spellCost}%
      }%
    
      \setcounter{spellPlusOne}{\value{spellCost}}%
        \addtocounter{spellPlusOne}{1}%
    
      \setcounter{spellPlusTwo}{\value{spellCost}}%
        \addtocounter{spellPlusTwo}{2}%
    
      \setcounter{spellPlusThree}{\value{spellCost}}%
        \addtocounter{spellPlusThree}{3}%
    
      \ifstrequal{#2}{}{\renewcommand\spellEnhancements{}}{\renewcommand\spellEnhancements{#2,\space}}%
    
      \renewcommand\spellAction{#3}%
      \renewcommand\spellSphere{#4}%
    
      % What bonus does the caster receive?  Some spells will display the caster's current Bonus, so we must calculate it.  We start by setting it sky-high, then for each element in {Earth,Fire}, et c. we check if this is lower than the current castingBonus, if (if so), lower the bonus.
    
      \setcounter{encnum}{0}%
    
      \setcounter{castingBonus}{10}%
      \foreach \e in {#4}{%
        \ifnum\value{\e}<\value{castingBonus}%
          \setcounter{castingBonus}{\value{\e}}%
        \fi%
    
        \stepcounter{encnum}%
    
      % This encnum just counts how many elemental spheres were used.
      % If we're using more than one element, and the spell is not Divergent, it means that the spell is using a high sphere, which changes the standard bonus from +2 to +1.
      \setSpellDamage
    
      \iftoggle{snapCaster}{%
        \addtocounter{castingBonus}{\value{Wits}}%
      }{%
        \addtocounter{castingBonus}{\value{Charisma}}%
      }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \renewcommand\spellResistance{#5}%
      \ifdefmacro{#5}{\toggletrue{opposedSpell}}{\togglefalse{opposedSpell}}%
      \renewcommand\spellSum{#6}%
      \renewcommand\spellNotes{#7}%
    
      \setTargetsIfDuplicated%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \iftoggle{talisman}{%
    
        \index[talismans]{\textbf{#1} (\spellEnhancements\ \spellAction~\spellSphere) Range:~\spellRange, \ifnumcomp{\value{spellTargets}}{>}{1}{Area:~\arabic{spellTargets}, }{} \iftoggle{Devious}{Onset:~1~\showOnset, }{} Resisted by: \detokenize{#5}, Bonus:~\arabic{spellCost}. \spellSum|adfclosedflourishleft~p.~}%
    
        \iftoggle{fullSpells}{%
    
          \index[spells]{\textbf{#1} {\sffamily (\spellEnhancements \spellAction~\spellSphere)} \textit{Cost:~\arabic{spellCost}, Range:~\spellRange, \ifnumcomp{\value{spellTargets}}{>}{1}{Area:~\arabic{spellTargets}, }{} \iftoggle{Devious}{Onset:~1~\showOnset, }{} Resisted by: \detokenize{#5}.} \spellSum|adfclosedflourishleft~p.~}%
    
    \newcommand\fullSpell{%
    
      \vspace{1em}
    
      \begin{tabularx}{\linewidth}{m{.28\linewidth}X}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \hiderowcolors
    
      \raggedright
      \textbf{\titleFont\large\spellName}
    
      \iftoggle{examplecharacter}{}{\par\footnotesize\hint{\spellEnhancements\ \spellAction}}
    
      \label{\spellName}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      &
        \small
    
        \textbf{\scshape Requirements:}
        \spellSphere~\arabic{spellCost}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
        \textbf{\scshape Resisted~by:}
        \spellResistance
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
        \textbf{\scshape Range:}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \spellRange%
    
        \ifnumcomp{\value{spellTargets}}{>}{1}{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \par
    
          \textbf{\scshape Area:}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \arabic{spellTargets}%
        }{}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \iftoggle{Devious}{%
          \par
          \textbf{\scshape Onset Time:}
          1~\showOnset%
        }{}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \\
      \end{tabularx}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \par%
      \nobreak%
    
      \spellSum.
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \vspace{\baselineskip}
    
    \newcommand\shortSpell{%
    
      \textit{\spellSum}.
    
      Spend \arabic{spellCost}~\glsentrytext{mp},
      \iftoggle{opposedSpell}{%
        \addtocounter{castingBonus}{7}%
        \ifnum\value{spellTargets}>1\glspl{pc} resist \else target \gls{pc} resists\fi\  with \spellResistance~(\tn[\arabic{castingBonus}])%
      }{%
        \name\ rolls with \absNum{castingBonus} (\gls{tn} set by \spellResistance)%
      }. %
    
      \textbf{Range:}~\spellRange,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \ifnum\value{spellTargets}>1%
    
        \textbf{Area:}~\arabic{spellTargets},
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \fi%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \iftoggle{Devious}{%
    
        \textbf{Onset:} 1~\showOnset%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      }{}%
    
    \newcommand\spell[7]{%
    
      \togglefalse{talisman}%
      \stepcounter{enc}%
    
      \calcSpell{#1}{#2}{#3}{#4}{#5}{#6}{#7}%
    
      \iftoggle{fullSpells}{%
        \fullSpell%
      }{%
        \shortSpell%
      }%
    
    \newcommand\showStdSpells[1][]{
    
      \ifnum\value{noAppearing}>1\renewcommand\name{caster}\fi% We don't want to display "3 elves rolls with +3 to do X"
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{enc}{0}
    
      \setHighSpheres
    
      \needspace{2em}
    
      \begin{center}%
    
      \needspace{4em}
    
      \textcolor{\pageSideColor}{\glsentrysymbol{alchemy}} \textbf{Spells} \textcolor{\pageSideColor}{\glsentrysymbol{alchemy}}
    
      \end{center}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \begin{description}
    
        \settoggle{fullSpells}{false}
    
        \foreach \n in {4,3,2,1}{
    
          \foreach \s in {Light,Death,Life,Mind,Force,Earth,Air,Fire,Water,Fate}{
            \ifnumcomp{\value{\s}}{=}{\n}{
              \ifnum\value{enc}<3
                \input{config/spells/\s\n.tex}
              \fi
            }{}
          }
    
      \textcolor{\pageSideColor}{\hrulefill\raisebox{-3pt}{\npcsymbol}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand\showSpells[1]{
    
      \settoggle{fullSpells}{true}%
      \foreach \s in {#1}{%
        \input{config/spells/\s.tex}%
      }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    \newcommand\showTalisman{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \iftoggle{creatureBox}{%
        \spellName\ talisman%
        \setcounter{track}{\value{treasure}}%
      }{%
    
        \vspace{1em}
        \noindent
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \begin{minipage}{\linewidth}
    
        \paragraph{\adforn{25}~\spellName~\adforn{53}}%
    
        \spellSum.
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \spellNotes
    
        \par
        \noindent
        {\it(\iftoggle{opposedSpell}{%
          \addtocounter{castingBonus}{7}%
          Resisted by: \spellResistance\ (\tn[\arabic{castingBonus}]), %
        }{%
          Roll: \absNum{castingBonus}, \gls{tn} set by \spellResistance, %
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        Range: \spellRange%
        \ifnum\value{spellTargets}>1%
    
          , Area of Effect:~\arabic{spellTargets}
        \else%
        \fi)}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \end{minipage}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      }%
    
    }
    
    \newcommand\talisman[7]{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \toggletrue{talisman}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{Charisma}{0}%
    
      \calcSpell{#1}{#2}{#3}{#4}{#5}{#6}{#7}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{castingBonus}{\value{spellCost}}%
    
      \setcounter{Charisma}{\value{attackXPtotal}}% Return Charisma to old value
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\explainTalisman{%
      \setcounter{treasure}{\value{track}}%
      \lootMagic%
    }
    
    \newcommand\artefact[9][3]{
    
      \renewcommand\npcsymbol{\E}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \settoggle{fullSpells}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \foreach \s in {Air, Fire, Earth, Water, Fate}%
        {\setcounter{\s}{0}}
    
      \setcounter{Intelligence}{#4}
      \setcounter{Wits}{#5}
      \setcounter{Charisma}{#6}
      #9
    
      \ifglsentryexists{#2}{
        \paragraph{\adforn{54}~\Glsfmttext{#2}~\adforn{26}\hspace{1em}}
    
        \label{#2}%
        \renewcommand\name{\gls{#2}}
    
        \index{Artefacts!\Glsfmttext{#2}}
    
      }{
        \paragraph{\adforn{54}~#2~\adforn{26}\hspace{1em}}
        \label{#2}
    
        \renewcommand\name{#2}
    
        \index{Artefacts!#2}
      }
    
      #3 \hint{\gls{weight} #1}
    
      \noindent
      \begin{tabularx}{\linewidth}{rX}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \hiderowcolors
    
      \textbf{Mission:} & \emph{#7!} \\
      \textbf{Base Spell:} & #8 \\
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \textbf{Mind:} & 
        Intelligence \arabic{Intelligence}, Wits \arabic{Wits}, Charisma \arabic{Charisma}
          \\
      \textbf{Spheres:} & 
        \foreach \s in {Air, Fire, Earth, Water, Fate}%
    
          {\ifnum\value{\s}>0%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
            \s~\arabic{\s},
    
            \addtocounter{mp}{3}%
          \fi}%
          \\%
    
        \textbf{Skills:} & \showSkills \\
    
        \textbf{\glspl{mp}:} &
        \ifnum\value{mp}>0
    
          \glsentrysymbol{alchemy}-\boxStat{mp}
    
        \else
          0
        \fi \\
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \end{tabularx}
    
      \setcounter{wounds}{0}