From f2b1ded397762dd6a5dcde6837729e3b1e5cda77 Mon Sep 17 00:00:00 2001 From: Malin Freeborn <malinfreeborn@posteo.net> Date: Sun, 20 Aug 2023 02:01:37 +0200 Subject: [PATCH] show spell ranges --- docs.tex | 23 +++++++++++++++++++++-- layout.sty | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/docs.tex b/docs.tex index 102b5efa..b480d7eb 100644 --- a/docs.tex +++ b/docs.tex @@ -3,6 +3,8 @@ \date{\today} +\makeindex[name=spells,title={Spell Summaries},columns=2] + \begin{document} \chapter{How to Make Monsters} @@ -138,12 +140,29 @@ And you can list dice, with results, with the `\texttt{dlist}' environment. \subsubsection{Spells} Spells automatically calculate everything they can. +They also compile an optional index (this requires one spell index command). + +\begin{verbatim} +\makeindex[name=spells, +title={Spell Summaries},columns=2] + + +\spell{Quake}% Name + {Earth}% Spheres + {\ranged, Twisted}% Enhancements + {Caving}% Skill + {Ground shakes}% Description + +\printindex[spells] +\end{verbatim} + +After inputting that, you can get the spell, and the `printindex' command will create a spell-list by using a special index, just for spells. \spell{Quake}% Name {Earth}% Spheres - {Large, Twisted, Ranged}% Enhancements + {\ranged, Twisted}% Enhancements {Caving}% Skill - {GrrrrrrrrglllllllllllbrrrrrrrrrrrrrrBBBBBBB}% Description + {Ground shakes}% Description \subsubsection{Magical Items} diff --git a/layout.sty b/layout.sty index 627fc454..859c3006 100644 --- a/layout.sty +++ b/layout.sty @@ -823,16 +823,61 @@ interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west) % 4 = Skill % 5 = Description + \newcommand{\spell}[5]{ \setcounter{spelllevel}{1} \foreach \s in {#3}{ \stepcounter{spelllevel} } \subsubsection[\textbf{#1}: #5. (\textit{#4})]{#1} - \index[spells]{\textbf{#1}: #5. (Cost: \arabic{spelllevel}, Spheres: #2, Skill: #4)} - {\small\it Spheres: #2, \glsentrytext{mp} Cost: \arabic{spelllevel}, Enhancements: #3, \underline{Skill: #4}} + Spheres: #2, + Enhancements: #3, + \glsentrytext{mp} Cost: \arabic{spelllevel}, + \showRange, + \underline{Skill: #4} \vspace{.5em}\afterparnoindent + \index[spells]{\textbf{#1}: #5. (Cost: \arabic{spelllevel}, Spheres: #2, Skill: #4, \showRange)} + \settoggle{ranged}{false}% +} + +\newcounter{spellRange} + +\newcommand\showRange{% + Range: + \iftoggle{ranged}% + {% + \ifcase\value{spelllevel}\relax% + Error% + \or% + Error% + \or% + throwing distance% + \or% + shouting distance% + \or% + horizon% + \else% + line of sight% + \fi% + }% + {% + \setcounter{track}{6}% + \addtocounter{track}{-\value{spelllevel}}% + \ifnum\value{track}<1% + touch% + \else% + \arabic{track} steps% + \fi% + }% +} + +\newtoggle{ranged} +\settoggle{ranged}{false} + +\newcommand\ranged{% + Ranged% + \settoggle{ranged}{true}% } \newcommand{\magicitem}[7]{% -- GitLab