The monster comes back


In the previous post, We left a \LaTeX table representing a Vargouille monster like this:

Monster definition basic

Monster definition basic and attackless

And we want it more threatening. In this post I will add the different attacks, base stats, languages and maybe equipment. All are optional, it is decoration to our dangerous monster


As already described in the original monster post, apart from the ddmonster environment there is a lot of commands to be used for: Section, attacks, powers, stats etc..

== My ideal design

D&D is a complex game with various definitions of Actions, Effects, Powers etc. But everything boils down to:

  • Name
  • type (daily, encounter, at will)
  • Attack roll Throw a dice
  • What if Hit

And then there are optional parts of the attack like:

  • What if Miss
  • Permanent effects

My ideal design would be \ddmAction with named parameters: attack, hit, miss. But with trial and error (and a lot of reading) I learnt that ifthenelse and others inside tables is very troublesome, I’ll avoid these multiple problems.

== My current design


Instead of a single \ddmAction command. A range of commands is used to represent all the possible outcomes. If there’s a missing outcome I will just add the new command.

The following table presents all the commands, the number of parameters and a description. Some of the commands are almost the same, changing just the predefined text that will appear.

Command #P Description
\ddmActionS 3 “Simple” action.
name, type, definition
\ddmActionAH 4 Attack and hit
name, type, attack, hit
\ddmActionAHM 5 Attack Hit and Miss
name, type, attack, hit, miss
\ddmEffect 3 Monster Trait
name, type, effect definition
\ddmTrigger 4 Triggered Action
name, type, Trigger, effect definition
\ddmAura 3 Monster Aura
name, Aura distance, Aura definition
\ddmPower 2 Monster special power
name, power definition
it has no type


The Monster sections are just multicolumns, with different background color. Just use a command with one parameter.



The monster has 6 ability values (Strength, Constitution, Dexterity, Intelligence, Wisdom and Charisma) with 6 modifiers. I will calculate the modifiers with \LaTeX fp. The values will be presented with a table within a table.
Instead of using named parameters I will keep unnamed ordered parameters.

Command #P Description
\ddmStats 8 Monster stats and modifiers
Str., Dex., Wis., Con., Int., Cha., level, extra habilities


Languages, Alignments and Equipment. Just simple table rows.

Command #P Description
\ddmAlignLang 2 Monster alignment and language
\ddmEquip 1 Equipment list



All the actions are implemented the same way. I will write and explain here one of those, the \ddmActionAHM.

%An action with name-type. Attack and hit and miss
    {#1} & {#2} \\
    \multicolumn{2}{p{0.9\linewidth}}{Attack: #3} \\
    \multicolumn{2}{p{0.9\linewidth}}{Hit: #4} \\
    \multicolumn{2}{p{0.9\linewidth}}{Miss: #5} \\

As a convention a new action has to define an upper rule \midrule if it expects to be separed. No bottom rule is issued (to avoid double rules).

The action writes a first row with two columns containing the two first parameters ({#1} and {#2}). That is the Action Name and the action type.

After that, three multicolumns write the attack, the hit and the miss. This is very easy, there is nothing weird in the code. Just note how I force the multicolum to a 90% of the width, If I don’t define that, long lines will be split in multiple lines until reaching the end of the paper.

Sections and Others

Those two follow exactly the same style as the defined action. If you want the full code, just check my github.


The stats provide a table with the monster abilities, plus its modifier.

The modifier is something related to D&D 4E, and you can find the values googling “d&d 4e ability modifiers“.

Value Modifier
00-01 -5
02-03 -4
04-05 -3
06-07 -2
08-09 -1
10-11 0
11-12 1
34-35 12

You see the pattern right?
-5 + \lfloor \frac{ABILITY}{2} \rfloor

This is the basic modifier. Then, by the rules, I have to add half the level (rounded down)
-5 + \lfloor \frac{ABILITY}{2} \rfloor + \lfloor \frac{LEVEL}{2} \rfloor

Unfortunately, the package fp does not have a floor function. It provides \round and trunc. The round function is what we will use with a little trick.
I know that all the fractions will end in something like X.5. To get the floor value, I just have to substract a little to get X.4, and then round.

    %Get the half value rounded down
    \FPeval{\hab}{round(#1/2 -0.1,0)}
    \FPeval{\hlvl}{round(#2/2 -0.1,0)}
    \FPeval{\mod}{ trunc( -5 + \hab + \hlvl ,0)}

This is how I would like to do it. But apparently FPeval is inserting horizontal spaces. So after three evals the result is not nice. I join everything into a single line, avoiding multiple horizontal spaces.

    \FPeval{\abmod}{trunc(-5 + round(#1/2 -0.1,0) + round(#2/2 -0.1,0) ,0)}

With that small command my \ddmStats is easy to perform

% Print a table of Ability values and modifiers according 
% to ability values and level. 
% Additionally add skills if defined
% Str, Dex, Wis, Con, Int, Cha, Level, Extra skills
        \textbf{skills:} {#8}
    } \\

            \textbf{Str}  #1  \emph{\abilityeval{#1}{#7}}
            \textbf{Dex}  #2  \emph{\abilityeval{#2}{#7}}
            \textbf{Wis}  #3  \emph{\abilityeval{#3}{#7}}
            \textbf{Con}  #4  \emph{\abilityeval{#4}{#7}}
            \textbf{Int}  #5  \emph{\abilityeval{#5}{#7}}
            \textbf{Cha}  #6  \emph{\abilityeval{#6}{#7}}

Because this is something so specific I also provide \ddmStatsNoMod, that will take one less parameter (level) and won’t compute the modifiers.


We finally have all the ingredients to write the complete Vargouille monster.

        name = Vargouille, role = Controller,lvl=2,
        keywords = small immortal Magical Beast,xp=125,
        speed=2 (volar 6),vision=Darkvision,
        %resist=10 fire,

    {+7 vs AC (1 creature)}
    {1d6 +4 damage. Ongoing poison damage 5 (save ends).}

    %\ddmActionAH{Shriek (fear)}{Recharge \ding{196},\ding{197}}
    \ddmActionAH{Shriek (fear)}{Recharge 5,6}
    {Close Blast 3: +5 vs Will}
    {1d6 damage. The target is immobilized until the end of its next turn.}

    {+7 vs AC. Against an immobilized target.}
    {2d8 +5 damage. And ongoing 5 posion damage (save ends).}

    \ddmStats{10}{13}{12}{14}{5}{8}{2}{Stealth +7}

Final Vargouille monster

Final Vargouille monster

A kissing Vargouille.

This is how this monster looks like.


Wuff, that was a lot of work. But now we can write a monster in a somewhat easy and consistent way. You can even create your own database of monsters to include :-D. At least it has been useful for me when preparing a couple of adventures.

There are still some things that I find unpleasant to work with.

The Table will have the width of the line. I am working following the style of A4 pages with two columns found in D&D 3e adventures. But if you want a full page with single column, well, it will be ugly.

If you are reading so far, maybe you realized the commented code \ding{196}, this is pifont package, to print nice characters for “recharge” powers. I would like to change those characters to something more similar to dice.

TrueType font files with the attack icons of Dungeons and Dragons 4E exist. I would like to implement that in my monster.


Oh, \LaTeX! I love Poirot!

This error message was generated by an \errmessage
command, so I can’t give any explicit help.
Pretend that you’re Hercule Poirot: Examine all clues,
and deduce the truth by order and method.
– running pdflatex


xkeyval documentation ⇒GO
xkeyval package at CTAN ⇒GO
D&D 4E conversion wikia ⇒GO
\LaTeX ifthenelse ⇒GO
\LaTeX fp ⇒GO


1 Comment

Filed under code, documents

One response to “The monster comes back

  1. Pingback: The monster environment | Castells

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s