Skip to content
Snippets Groups Projects
magic.sty 6.44 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{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\spellRange{}
    \newcommand\setRange{%
      \iftoggle{distant}%
        {%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \ifcase\value{spellCost}\relax%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \renewcommand\spellRange{Error}%
          \or%
          \renewcommand\spellRange{Error}%
          \or%
            \renewcommand\spellRange{throwing distance}%
          \or%
            \renewcommand\spellRange{shouting distance}%
          \or%
            \renewcommand\spellRange{horizon}%
          \else%
            \renewcommand\spellRange{line of sight}%
          \fi%
        }%
        {%
          \setcounter{track}{20}%
    
    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}
    \newtoggle{distant}
      \settoggle{distant}{false}
    \newtoggle{duplicated}
      \settoggle{duplicated}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newtoggle{opposedSpell}
      \settoggle{opposedSpell}{false}
    
    \newcommand\calcSpell[7]{%
      \renewcommand\spellName{#1}%
      \setcounter{spellCost}{1}%
    
      \setcounter{spellTargets}{1}%
      \togglefalse{distant}%
      \togglefalse{duplicated}%
    
      \foreach \d in {#2}{%
    
        \ifdefstring{\d}{distant}{\global\toggletrue{distant}}{}%
        \ifdefstring{\d}{duplicated}{\global\toggletrue{duplicated}}{}%
    
        \stepcounter{spellCost}%
      }%
    
      \setcounter{spellPlusTwo}{\value{spellCost}}%
        \addtocounter{spellPlusTwo}{2}%
    
      \setcounter{spellPlusThree}{\value{spellCost}}%
        \addtocounter{spellPlusThree}{3}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \conDmg{spellPlusThree}%
    
      \renewcommand\spellEnhancements{#2}%
      \renewcommand\spellAction{#3}%
      \renewcommand\spellSphere{#4}%
    
      % What bonus does the caster receive?  Some spells will display the caster's current Bonus, so we must calculate it.  We start by setting it sky-high, then for each element in {Earth,Fire}, et c. we check if this is lower than the current castingBonus, if (if so), lower the bonus.
      \setcounter{castingBonus}{10}%
      \foreach \e in {#4}{%
        \ifnum\value{\e}<\value{castingBonus}%
          \setcounter{castingBonus}{\value{\e}}%
        \fi%
      }{}%
      \iftoggle{snapCaster}{%
        \addtocounter{castingBonus}{\value{Wits}}%
      }{%
        \addtocounter{castingBonus}{\value{Charisma}}%
      }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \renewcommand\spellResistance{#5}%
      \ifdefmacro{#5}{\toggletrue{opposedSpell}}{\togglefalse{opposedSpell}}%
      \renewcommand\spellSum{#6}%
      \renewcommand\spellNotes{#7}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \iftoggle{duplicated}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \foreach \i in {1,...,\arabic{spellCost}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          {\multiply\value{spellTargets} by \value{spellCost}\addtocounter{spellTargets}{0}}%
      }{}%
      \iftoggle{talisman}{%
        \index[talismans]{\textbf{#1} (\spellEnhancements\ \spellAction~\spellSphere) Range: \spellRange, Area: \arabic{spellTargets}, Resisted by: \detokenize{#5}, Bonus: \arabic{spellCost}. \spellSum|adfclosedflourishleft~p.~}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \index[spells]{\textbf{#1} (Cost: \arabic{spellCost}, \spellEnhancements\ \spellAction~\spellSphere) Range: \spellRange, Targets: \arabic{spellTargets}, Resisted by: \detokenize{#5}, \spellSum|adfclosedflourishleft~p.~}%
    
    \newcommand\fullSpell{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \needspace{4em}
      \begin{tabularx}{\linewidth}{YX}
      \adforn{24}~\textbf{\scshape\large\spellName}~\adforn{52}
      &
        \small
        \noindent
        \textbf{\scshape Requirements}
        \spellSphere
    
        \noindent
        \textbf{\scshape Cost}
        \arabic{spellCost} \glsentrytext{mp}
    
        \noindent
        \textbf{\scshape Range}
        \spellRange%
    
        \ifnumcomp{\value{spellTargets}}{>}{1}{%
          \noindent
          \textbf{\scshape Targets}
          \arabic{spellTargets}%
        }{}
    
        \noindent
        \textbf{\scshape Resisted~by:}
        \spellResistance
      \\
      \end{tabularx}
      \noindent
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \vspace{1em}
    
    \newcommand\shortSpell{%
    
      \spellSum.
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      (Cost: \arabic{spellCost},
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      Range:~\spellRange,
      \ifnum\value{spellTargets}>1%
        Targets:~\arabic{spellTargets},
      \fi%
      \iftoggle{opposedSpell}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \addtocounter{castingBonus}{7}%
        Resisted by: \spellResistance, \tn[\arabic{castingBonus}]%
      }{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        Roll: \absNum{castingBonus}, \gls{tn} set by \spellResistance.%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      })%
    
    \newcommand\spell[7]{%
    
      \togglefalse{talisman}
    
      \calcSpell{#1}{#2}{#3}{#4}{#5}{#6}{#7}%
    
      \iftoggle{fullSpells}{%
        \fullSpell%
      }{%
        \shortSpell%
      }%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\showStdSpells{
      \setcounter{enc}{0}
    
      \needspace{2em}
    
      \begin{center}%
      \textcolor{\pageSideColor}{\large\Pentagram} \textbf{Spells} \textcolor{\pageSideColor}{\large\Pentagram}
      \end{center}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \begin{description}
    
        \settoggle{fullSpells}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \foreach\n in {3,2,1}{
          \ifnum\value{enc}<3
    
            \foreach \s in {Light,Death,Life,Mind,Force,Earth,Air,Fire,Water,Fate}{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
              \ifnumcomp{\value{\s}}{=}{\n}{
                  \input{config/spells/\s\n.tex}
                  \stepcounter{enc}
              }{}
            }
          \fi
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \end{description}
    
      \textcolor{\pageSideColor}{\hrulefill\raisebox{-3pt}{\npcsymbol}}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand\showSpells[1]{
    
      \needspace{3em}
    
      \settoggle{fullSpells}{true}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \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}}%
      }{%
        \paragraph{\spellName}%
    
        \spellSum.
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \spellNotes
        \iftoggle{opposedSpell}{
          \addtocounter{castingBonus}{7}
          Resisted by: \spellResistance\ (\tn[\arabic{castingBonus}])
        }{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          Roll: \absNum{castingBonus}, \gls{tn} set by \spellResistance.
        }%
      }%
    
    }
    
    \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}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\explainTalisman{%
      \setcounter{treasure}{\value{track}}%
      \lootMagic%
    }