Automating Treasure Table Rolls

Tags:

One of the first things I automated via a program was determining results on the treasure table.

There is a fair about of rolling to determine treasure. There is also several sub-tables that you could possibly have to roll on, multiple times.

Here is an excerpt of the treasure table from Hyperborea

screenshot of astonishing swordsmen and sorcerors of hyperborea treasure table

Let's use Treasure Class A as an example. This is probably the most rolling you have to do. Determining coin results are easy. Things get more tedious if there are sub-tables. Gems, Jewelry, and Magic have plenty of sub-tables to handle.

Here is the gems table.

screenshot of  astonishing swordsmen and sorcerors of hyperborea gems table

You can even do more rolling if you get the correct result.

screenshot of  astonishing swordsmen and sorcerors of hyperborea gems table

Jewellery has at least 2 sub-tables to roll on. The kind of jewellery.

screen shot of astonishing swordsmen and sorcerors of hyperborea jewellery table

And what it is made of and it's worth.

screen shot of astonishing swordsmen and sorcerors of hyperborea jewellery table 2

This is just the beginning for magic items. A veritable rabbit hole to go down.

screenshot of of  astonishing swordsmen and sorcerors of hyperborea magic items table

It can end after a couple tables.

screenshot of astonishing swordsmen and sorcerors of hyperborea wands table

Eventually you get to the far end of that tree and have to come back for more rolls as needed.

Thankfully, the DM for a game I was in, and Perl Pumpking for some time, also seemed to have a thing to automate tables.

There are lots of tables that can be referenced by a DM. So Rik Signes created Roland to help with automating the rolling on them

https://rjbs.manxome.org/rubric/entry/2013

Go ahead, give it a read. Rik does a good job explaining Roland. This post will be here waiting for you when you are done.

screenshot of roland blog post

It's not available on CPAN just yet, but I'm working on him. He's says it's bad software but I think it works just fine.

screenshot of roland github repo

Thankfully Roland can make all that rolling and referencing automated. That is assuming you are comfortable with the level of entropy and randomness a pseudo random number generator can give you

Really, go read Rik's blog post and then come back here when you are done.

Here is an example of the output of the program I created.

$ ./roll_treasure a
3500 cp
8000 gp
50 pp
  10,000 gp piece of jewelry
  5,000 gp piece of jewelry
  100 gp piece of jewelry
  750 gp piece of jewelry
  1,000 gp piece of jewelry
  200 gp piece of jewelry
  100 gp piece of jewelry
  100 gp piece of jewelry
  200 gp piece of jewelry
  100 gp piece of jewelry
  500 gp piece of jewelry
  200 gp piece of jewelry
  200 gp piece of jewelry
  200 gp piece of jewelry
  Staff of Withering
  Potion of Delusion (cursed)
  Quarterstaff +2

The program itself, when stripped down, is really quite simple.

my @rolls = @ARGV;
for my $roll ( @rolls ) {
  $roll =~ s/,| +|[()]//g;
  $roll = lcfirst $roll;
  my $count = 1;
  if ( $roll =~ m/\wx\w/ ) {
    ($roll, $count) = split('x', $roll);
  }
  my $path;
  my $roll_length = length($roll);
  if ( 1 == $roll_length ) {
    $path = qq(treasure/class_$roll);
  }
  else {
    $path = qq(treasure/$roll);
  }
  for (1 .. $count ) {
    my $result = qx(~/bin/roland $path);
    say $result;
  }
}

There is however data entry that must be done.

Each Treasure Class needs a table.

# treasure/class_a
- { file: treasure/a/cp }
- { file: treasure/a/sp }
- { file: treasure/a/ep }
- { file: treasure/a/gp }
- { file: treasure/a/pp }
- { file: treasure/a/gems }
- { file: treasure/a/jewelry }
- { file: treasure/a/magic }

Then each file

# treasure/a/cp
dice: 1d100
results:
  1-25: 
    dice: 2d6
    results:
      2: 1000 cp
      3: 1500 cp
      4: 2000 cp
      5: 2500 cp
      6: 3000 cp
      7: 3500 cp
      8: 4000 cp
      9: 4500 cp
      10: 5000 cp
      11: 5500 cp
      12: 6000 cp
      26-100: ~

Snippet of the gems table.

93-94: "Violet garnet, [[1d20x50]]gp"
95:
  dice: 1d100
  results:
    1-50: "Emerald, [[1d20x100]]gp"
    51-100: "Fire opal, [[1d20x100]]gp"
96:
  dice: 1d100
  results:
    1-50: "Opal, [[1d20x100]]gp"
    51-100: "Oriental amethyst, [[1d20x100]]gp"
97:
  dice: 1d100
  results:
    1-50: "Oriental topaz, [[1d20x100]]gp"
    51-100: "Sapphire, [[1d20x100]]gp"
98:
  dice: 1d100
  results:
    1-50: "Star ruby, [[1d20x100]]gp"
    51-100: "Star sapphire, [[1d20x100]]gp"

Here is the jewelry table

# treasury/jewelry
- { file: treasure/jewelry_type }
- { file: treasure/jewelry_value }

Jewelry type table snippet

# treasury/jewelry_type
dice: 1d20
results:
  1: anklet, no weight
  2: armband, 1 lb
  3: bracelet, no weight
  4: bracer, 1 lb
  5: broach, no weight
  6: chain, 1 lb
  7: circlet, no weight
  8: comb, no weight
  9: crown, 4 lb

Jewelry value table snippet

# treasury/jewelry
dice: 1d100
results:
  1:
    dice: 1d12
    results:
      1-6:
        - "  made of pewter, worth 1gp"
      7-10:
        - "  made of bronze, worth 1gp"
      11:
        - "  made of copper, worth 1gp"
      12:
        - "  made of silver, worth 1gp"

What the application runs like on the command line.

$ ./roll_treasure gems
Carnelian, 90gp

$ ./roll_treasure jewelry
crown, 4 lb
  made of electrum, worth 1,000gp

$ ./roll_treasure jewelry
armband, 1 lb
  made of bronze, worth 3gp

$ ./roll_treasure jewelry
mask, 1 lb
    made of copper set with gems, worth 400gp
  Deep blue spinel, 700gp

And that is basically it.