Biblyon the Great

This zine is dedicated to articles about the fantasy role-playing game Gods & Monsters, and other random musings.

Gods & Monsters Fantasy Role-Playing

Beyond here lie dragons

Constructing encounter tables using Nisus

Jerry Stratton, January 2, 2009

If you use the method in the Adventure Guide’s Handbook for creating encounter tables, you’ve probably sometimes made mistakes totting up the ranges. What I usually do is work out the percentages first, using my word processor’s “sum column” function to make sure the sum of the percentages is always 100. Then, I manually create the d100 roll ranges; if I make a change to the percentages, I end up having to manually change the ranges.

It recently occurred to me that it should be easy to automate this in Nisus Writer Pro; turns out, it is. Let’s say I have the following table:

Animals34%
Dinosaurs25%
Insects21%
Saurians (1d20)18%

After I run the macro on it, I’ll have:

01-34Animals34%
35-59Dinosaurs25%
60-80Insects21%
81-98Saurians (1d20)18%

And I’ll know immediately that I’m missing 2% in the percentage totals. If I add one to animals and one to insects, I can re-run the macro to get:

01-35Animals35%
36-60Dinosaurs25%
61-82Insects22%
83-00Saurians (1d20)18%

Here’s the macro. If you have Nisus Writer Pro, you can copy this and then save it in your Macros folder as something like “Calculate Encounter Rolls.nwm”.

[toggle code]

  • # check if there is a table selection
  • $document = Document.active
  • $tableSelection = $document.tableSelection
  • If Defined $tableSelection
    • $table = $tableSelection.table
    • If $table.columnCount < 2
      • Prompt "Encounter tables must have a creature column and a percentage column."
      • Exit
    • End
    • #Add the third column if it doesn't exist yet.
    • If $table.columnCount < 3
      • Select Table Cell 1, 1
      • Menu "Table:Insert:Column to the Left"
    • End
    • $currentRow = 0
    • $bottomOfRange = 0
    • While $currentRow < $table.rowCount
      • $percentage = $table.textAtRowAndColumn $currentRow, 2
      • If $percentage == ""
        • Prompt "Found empty cell. Exiting."
        • Break
      • End
      • $topOfRange = $bottomOfRange + $percentage
      • $bottomOfRange = $bottomOfRange + 1
      • $cell = $table.textAtRowAndColumn $currentRow, 0
      • $replacementRange = Range.new(0, $cell.length)
      • #Handle single-digit numbers and 100s
      • If $bottomOfRange < 10
        • $bottomOfRange = "0$bottomOfRange"
      • Elsif $bottomOfRange == "100"
        • $bottomOfRange = "00"
      • End
      • If $topOfRange < 10
        • $topOfRange = "0$topOfRange"
      • Elsif $topOfRange == "100"
        • $topOfRange = "00"
      • End
      • If $bottomOfRange == $topOfRange
        • $range = $bottomOfRange
      • Else
        • $range = "$bottomOfRange-$topOfRange"
      • End
      • $cell.replaceInRange $replacementRange, $range
      • $bottomOfRange = $topOfRange
      • $currentRow = $currentRow + 1
    • End
    • Menu "Table:Fit to Contents"
  • Else
    • Prompt "Select inside an encounter table to use this macro."
  • End
  1. <- Verve
  2. Twisting History ->