Skip to content
Snippets Groups Projects
magic.sty 7.26 KiB
Newer Older
  • Learn to ignore specific revisions
  • Malin Freeborn's avatar
    Malin Freeborn committed
    % 
    %  __  __             _      
    % |  \/  | __ _  __ _(_) ___ 
    % | |\/| |/ _` |/ _` | |/ __|
    % | |  | | (_| | (_| | | (__ 
    % |_|  |_|\__,_|\__, |_|\___|
    %               |___/        
    
    
    
    \newcounter{spellCost}
    \setcounter{spellCost}{1}
    
    \newcommand\spellName{}
    \newcommand\spellEnhancements{}
    \newcommand\spellAction{}
    \newcommand\spellSphere{}
    \newcommand\spellResistance{}
    \newcommand\spellSum{}
    \newcommand\spellNotes{}
    
    \newcommand\calcSpell[7]{%
      \renewcommand\spellName{#1}%
      \setcounter{spellCost}{1}%
      \foreach \d in {#2}{%
        \stepcounter{spellCost}%
      }%
      \renewcommand\spellEnhancements{#2}%
      \renewcommand\spellAction{#3}%
      \renewcommand\spellSphere{#4}%
      \renewcommand\spellResistance{#5}
      \renewcommand\spellSum{#6}
      \renewcommand\spellNotes{#7}
    }
    
    
    
    \newcommand\fullSpell{%
    
      \paragraph{\spellName}
    
      Cost: \arabic{spellCost},
      \spellEnhancements,
      \spellAction~
      \spellSphere
    
      Resisted by: \spellResistance
    
      \spellSum \ 
      \spellNotes
    }
    
    
    
    \newcommand\spellIndex{\index[spells]{\textbf{\spellName} Cost: \arabic{spellCost}, \spellEnhancements, \spellAction~\spellSphere Resisted by: \detokenize{\spellResistance} \spellSum \spellNotes }}
    
    
    % We use spellPotency to track spell effects which are typically larger than the spell's level.
    \newcounter{spellPotency}
    
    
    % spellResTN is the TN to resist spells, used only in specified spells beneath creatures. For example, if someone had Air 2, resisting their spells would be TN (7 + 2) 9.
    \newcounter{spellResTN}
    
    
    \newcommand\mFate{%
      Fate%
      \global\settoggle{insubstantial}{true}%
      \ifnum\value{spellResTN}<8%
        \addtocounter{spellResTN}{\value{Fate}}%
      \fi%
    }
    \newcommand\mEarth{%
      Earth%
      \ifnum\value{spellResTN}<8%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \addtocounter{spellResTN}{\value{Earth}}%
    
      \fi%
    }
    \newcommand\mAir{%
      Air%
      \global\settoggle{insubstantial}{true}%
      \ifnum\value{spellResTN}<8%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \addtocounter{spellResTN}{\value{Air}}%
    
      \fi%
    }
    \newcommand\mFire{%
      Fire%
      \ifnum\value{spellResTN}<8%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \addtocounter{spellResTN}{\value{Fire}}%
    
      \fi%
    
      \addtocounter{spellPotency}{-1}%
    
    }
    \newcommand\mWater{%
      Water%
      \ifnum\value{spellResTN}<8%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \addtocounter{spellResTN}{\value{Water}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % 1 = Name
    % 2 = Spheres
    % 3 = Action
    % 4 = Enhancements
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    % 6 = Description
    
    % 7 = Longer notes
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    \newcommand{\spell}[7]{
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \global\settoggle{distant}{false}%
      \global\settoggle{duplicated}{false}%
    
      \global\settoggle{insubstantial}{false}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \setcounter{spelllevel}{1}%
      \foreach \s in {#4}{%
        \stepcounter{spelllevel}%
      }%
    
      \setcounter{spellPotency}{\value{spelllevel}}%
    
        \addtocounter{spellPotency}{3}%
    
      \setcounter{spellResTN}{7}%
    
      \iftoggle{genExamples}{
    
        \subsubsection{#1}%
        \label{#1}%
    
    
        {\sffamily(#4%
        \ifnum\value{spelllevel}>1~\fi #3
    
        \gls{mp} Cost:~\arabic{spelllevel},
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        Resisted by: #5,
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        Range:~\spellRange
    
        \setArea%
        \iftoggle{duplicated}{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \ignorespaces, Targets:~\spellArea, %
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        \afterparnoindent
    
        \vphantom{\dmg{spellPotency}}
    
        \index[spells]{\textbf{#1}: #6 (Cost: \arabic{spelllevel}, Range:~\spellRange, Resisted by: #5\iftoggle{duplicated}{, Targets: \spellArea}{})|needspace{2em} --- Page }
    
        \item[\textbf{#1}]%
    
        \vphantom{\dmg{spellPotency}}%
    
        \vphantom{#2}%
    
        \setArea%
        \setRange%
    
        \ifdefparam{#5}{%
          Roll #5, \tn[\arabic{spellResTN}], or #6.
    
        }{
          \MakeUppercase#6.
        }
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        (Spheres:~#2, Cost:~\arabic{spelllevel}, Range:~\spellRange\iftoggle{duplicated}{, Targets:~\spellArea}{})
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    }
    
    \newcommand\spellRange{}
    \newcommand\setRange{%
      \iftoggle{distant}%
        {%
          \ifcase\value{spelllevel}\relax%
          \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%
        }%
        {%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \setcounter{track}{20}%
          \Repeat{\arabic{spelllevel}}{\addtocounter{track}{-4}}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \ifnum\value{track}<1%
            \renewcommand\spellRange{touch}%
          \else%
    
            \renewcommand\spellRange{\arabic{track}~steps}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
          \fi%
        }%
    }
    
    
    %%%
    \newcommand\spellArea{}
    \newcounter{spellArea}
    
    \newcommand\setArea{%
      \setcounter{spellArea}{\value{spelllevel}}%
      \multiply\value{spellArea} by \value{spelllevel}%
      \iftoggle{insubstantial}{%
        \multiply\value{spellArea} by \value{spelllevel}%
        \addtocounter{spellArea}{0}%
      }{}%
      \renewcommand\spellArea{%
        \arabic{spellArea}%
      }%
    }
    
    %%%
    
    \newtoggle{insubstantial}
      \settoggle{insubstantial}{false}
    \newtoggle{distant}
      \settoggle{distant}{false}
    \newtoggle{duplicated}
      \settoggle{duplicated}{false}
    
    \newcommand\detailed{Detailed}
    
    \newcommand\duplicated{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \global\settoggle{duplicated}{true}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      Duplicated%
    }
    
    \newcommand\divergent{Divergent}
    
    \newcommand\distant{%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \global\settoggle{distant}{true}%
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      Distant%
    }
    
    
    \newcommand\rollConv{\arabic{numberofdice}D6\ifnum\value{damagebonus}<0\arabic{damagebonus}\else\ifnum\value{damagebonus}>0+\arabic{damagebonus}\fi\fi}
    
    
    \newcommand\magicItem[7]{
    
      \global\settoggle{distant}{false}%
      \global\settoggle{duplicated}{false}%
      \global\settoggle{insubstantial}{false}%
      \setcounter{spelllevel}{1}%
    
      \foreach \s in {#3}{%
    
        \stepcounter{spelllevel}%
      }%
      \setcounter{spellPotency}{\value{spelllevel}}%
        \addtocounter{spellPotency}{3}%
      \setcounter{spellResTN}{7}%
      \vphantom{\dmg{spellPotency}}%
    
      \vphantom{#3}%
    
      \setArea%
      \setRange%
      \needspace{3em}
      {\center\decoone~\textbf{\large #1}~\decoone}
      \noindent
      \begin{description}
    
        \item[Item:] #7
    
        \item[Activation:]
    
          When #3,
          #6
        \raggedright
    
        \item[Stats:]
    
          Potence:~\arabic{spelllevel}, Range: \spellRange\iftoggle{duplicated}{, Targets: \spellArea}{}
          \item[Resisted~by:]
          #4
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand{\magicitem}[7]{%
      \vspace{1em}\needspace{1em}\noindent\textbf{#1}%
      \index{Magical Item!#1}
    
      \noindent
      \textit{Spells: #2, }%
      \textit{Path: #3, }%
      \textit{Duration: #4, }%
      \textit{Type: #5, }%
      \textit{Potency: +#6, }%
      \textit{MP: #7}%
      % Type can be 'Pocket Spell', 'Talisman', or 'Artefact'.
      \needspace{2em}%
    }
    
    \newcommand{\manalake}[8]{
      \subsection{#1 (Level #8)}
    
      \textit{Spells: #2, }\textit{Path: #3, }\textit{Duration: #4, }\textit{Type: #5, }\textit{Potence: #6, }\textit{#7 MP}% Type can be 'pocket spell', 'magical item', or 'artefact'.
      \index{Mana Lakes!#1}
      \vspace{.3em}
    }
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\creatureSpells[2][]{
    
      \begin{description}
    
        \settoggle{genExamples}{false}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
        #1
        \foreach \s in {#2}{
          \IfFileExists{config/spells/\s.tex}{
            \input{config/spells/\s.tex}
          }{}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    \newcommand\showStdSpells{
      \setcounter{enc}{0}
      \begin{description}
        \settoggle{genExamples}{false}
        \foreach\n in {3,2,1}{
          \ifnum\value{enc}<3
            \foreach \s in {Earth,Air,Fire,Water,Fate}{
              \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}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
      \settoggle{genExamples}{true}
      \foreach \s in {#1}{
        \input{config/spells/\s.tex}
      }
    
    Malin Freeborn's avatar
    Malin Freeborn committed