Best way to program a variable dieroll modifier for multiple table results

Hello. I have been reviewing past threads for a couple weeks now and just haven't found a solution to my issue. I have a set of table encounters that I would like to add for IPP and fully automate. The issue I have is that the table results have a modifier for the die roll depending on given external criteria. Ideally, I would like to make a single roll and have the output include all the possible options. for instance;

table blah
Die roll 1d10
1-2 orc
3-5 goblins
6-9 wolves
10 kobolds
11 ogre and kobolds
12 ghosts
13 dire wolves
14 vampire

Obviously a d10 roll will not get 11 - 14 for results but I want to have the following applied for the roll. a +2 for wilderness and a +2 for nighttime which are cumulative. And I want it all based on a single die roll and not 4 different die rolls. So when I run the table check is would get the following

Encounter test 1
Die Result: 7
Daytime: Wolves (from the 7 result)
Daytime wilderness: Wolves (from the 7 result +2 for wilderness=9)
Nighttime: (from the 7 result +2 for nighttime=9)
Nighttime wilderness: Ogre and kobolds (from the 7 result +2 for wilderness +2 for nighttime=11)

Encounter test 2
Die Result: 2
Daytime: orc (from the 2 result)
Daytime wilderness: goblins (from the 2 result +2 for wilderness=4)
Nighttime: goblins (from the 2 result +2 for nighttime=4)
Nighttime wilderness: wolves (from the 2 result +2 for wilderness +2 for nighttime=6)

Encounter test 3
Die Result: 10
Daytime: kobolds (from the 10 result)
Daytime wilderness: ghosts (from the 10 result +2 for wilderness=12)
Nighttime: ghosts (from the 10 result +2 for nighttime=12)
Nighttime wilderness: vampire (from the 10 result +2 for wilderness +2 for nighttime=14)

Any suggestions on how I do this would be appreciated


  • edited December 2019

    Here's a quick answer. The code should show how to set a die roll as a constant, then call the same constant several times, adding various modifyers to it. I have a more complex solution to work out (where the generator would determine day/night and normal/wilderness or the user would select from a prompt), but I'm short on time right now. I may upload more later.

    ; TestRoll2.ipt
    ; created 12/21/2019 3:32:42 PM
    Set: Roll ={1d10}
    Table: Main
    Die Result is {Roll}\nDaytime is [#{Roll} DieRoll]\n Nighttime is [#{{Roll}+2} DieRoll]\n Wilderness Night is [#{{Roll}+4} DieRoll]
    Table: DieRoll
    Type: Lookup
    1-2: orc
    3-5: goblins
    6-9: wolves
    10: kobolds
    11: ogre and kobolds
    12: ghosts
    13: dire wolves
    14: vampire
  • This was helpful. One issue I am having is that sometimes I get no result. If I set the generator to say 1 and run sometimes I get results and sometimes I get nothing. Is this an error with my table and rolls?

    This is what I have done to adapt what you suggested:

    Set: Roll ={1d10}

    Table: SeaCoastRoadWanderingMonsters
    Die Result is {Roll}\nDaytime is [#{Roll} SeaCoastRoad]\n Wilderness Daytime is [#{{Roll}+2} SeaCoastRoad]\n Nighttime is [#{{Roll}+2} SeaCoastRoad]\n Wilderness Night is [#{{Roll}+4} SeaCoastRoad]

    Table: SeaCoastRoad
    Type: Lookup
    Roll: 1d10
    1-2:Merchant Caravan
    3-5:Foot Patrol
    8-9:Cavalry Patrol
    10-11:{1d3} worgs and {1d12} wolves
    12:Ogre and {2d4} bugbears
    13:{2d6} shadows (or No Encounter; see description)
    14:Vampire and {2d6} worgs

    Running this, sometimes I get the expected number of results(setting to 5 for instance gives 5 sets of the 4 results) but then a rerun may only give 2 sets of results or in a few instances none.

  • In your Table: SeaCoastRoad take out the line Roll: 1d10. You're already sending the die roll value to the table in your callout above. I'm guessing that might be confusing the table, and it's unnecessary (you can just REM out the line with a ; (semicolon) at the start and see if it acts right.

    Also, maybe try to insert a space after the : (colon), like
    6-7: Brigands instead of
    it really shouldn't matter, but I wonder if it doesn't like 10-11:{1d3} without a space between the : and the {. Maybe those are the times you generate a null result. That leading space after the : is always eliminated in the output result, so no harm to try putting the space in.

  • Did everything suggested and you are right that the extra roll was useless(in fact was probably messing up the results anyways) in any case removing the extra die roll and adding spaces made no difference on the number of results it gets. Setting the generators to 5 and running 5 tests I got for the main die roll:
    Basing the results on the shaded rows

    blank, blank, 3, 4, blank
    blank, blank, 5, 9, blank
    4, 5, 1, blank, blank
    blank, 1, blank, blank, 7
    6, blank, 10, 10, blank

    In all, it took 34 presses of Go! to finally generate 5 roll results.

    Here is my current table code:
    `Set: Roll = {1d10}

    Table: SeaCoastRoadWanderingMonsters
    Die Result is {Roll}\nDaytime is [#{Roll} SeaCoastRoad]\n Wilderness Daytime is [#{{Roll}+2} SeaCoastRoad]\n Nighttime is [#{{Roll}+2} SeaCoastRoad]\n Wilderness Night is [#{{Roll}+4} SeaCoastRoad]

    Table: SeaCoastRoad
    Type: Lookup
    1-2: Merchant Caravan
    3-5: Foot Patrol
    6-7: Brigands
    8-9: Cavalry Patrol
    10-11: {1d3} worgs and {1d12} wolves
    12: Ogre and {2d4} bugbears
    13: {2d6} shadows (or No Encounter; see description)
    14: Vampire and {2d6} worgs

  • I copy/pasted your code and it works everytime for me. Here's a screenshot of the output. Let me know if the output looks as expected. Sorry I can't seem to find any other suggestions (There is a space in your Set: Roll line between the = and the {1d10}, but that doesn't seem to matter - works either way for me). Output of your code as you posted it:

  • Thanks for the help. I have no idea why I get different results then unless its PC or OS related. here is what I just got running it 3 different times:

  • If you sometimes get nothing, that must be because Table SeaCoastRoadWanderingMonsters sometimes returns nothing. As shown here, it has only a single line which will always return text, so that would never happen. You must have an additional line or lines which are effectively blank but which are being treated as part of that table. I can get the same results as you by adding an additional line after that table and just including a space on that line.

    Check the blank line after that table and make sure there are no spaces or other whitespace characters.

    If this is the issue, it makes sense that Levendor and I would not see the problem, because Markdown will strip that meaningless whitespace. If you had pasted it as Code, the space would have been preserved and we'd have the same symptom.

  • Yes, that makes sense. Sometimes it is a trailing space at the end of a line.

  • Hey.

    I can't help but feel interested in expanding this one myself. I'm thinking about making it be level specific and roll based on the chosen level, sort of like the Treasure Gen that comes with IPP.

    Is this okay with you?

  • Thanks guys. that did fix the issue. trailing spaces on several lines in fact. I just removed them all.

    @nimbus2000HP I don't have any issue with you using this table to do other stuff. I am doing work for a specific module but you could adapt it to generic stuff easily enough.

  • I appreciate it, jlong05. I'll look into how to get options for the rolls like the Treasure Gen has.

  • Am i right in thinking that {Roll} is only rolled once and returns the same numbber not a random number each time as i have a simmilar table but I require 3 seperate results

  • Yes. In this case jlong05 wanted to roll a d10, preserve that number (say a 6), and then use it to lookup 3 values on a table... 6, 6+2, and 6+4. Using "Set: Roll ={1d10}" creates a variable (really in my mind, a constant) called {Roll} that can be used throughout the generator with a fixed value of that initial d10 roll.

    Rolling a new d10 each time you enter the lookup table is simpler. Just use [#{1d10} tablename] each time you call the table, without bothering to create the set variable. Or, just simply call the table and have Roll: line in the table itself if it's always the same roll with no modifiers.

Leave a Comment