#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Open Ended dice rolls

Hi, I use Rolemaster for my RPGing and they use percentile dice (1d100) and if you roll a 96 or above, you get to roll again and add the 2 results.

Actually, it goes on with dice roll after dice roll until you roll less than 96 and they're all added together.

How would I be able to simulate these types of rolls?

Thanks.

• edited October 2017

Without actually creating the code (which I'll probably try to do in the next few days), I'd structure it along these lines:

Set base_roll={1d100}

Set result = base_roll

Set next_roll={1d100} ... then create a loop

When base_roll >95 then Do
... result = result + next_roll
... set base_roll = next_roll
... set next_roll = {1d100}
Else end loop

Now that's not the IPP syntax, and I'm not even sure the loop is really possible (I haven't done much with When - Do statements). There should be a way to output each {1d100} to check what it's really adding. Please post if get some code to work.

• edited October 2017

I've more or less got it now. Here's the output for 10 tries, with rerolling on a 70 or higher:

Critical Roll is Greater Than 69, Rolls are 12, 36, Total score is 12 Final Score is 12

Critical Roll is Greater Than 69, Rolls are 96, 28, Total score is 124 , Next Roll is 61, Total score is 124 Final Score is 124

Critical Roll is Greater Than 69, Rolls are 79, 39, Total score is 118 , Next Roll is 66, Total score is 118 Final Score is 118

Critical Roll is Greater Than 69, Rolls are 56, 95, Total score is 56 Final Score is 56

Critical Roll is Greater Than 69, Rolls are 73, 40, Total score is 113 , Next Roll is 93, Total score is 113 Final Score is 113

Critical Roll is Greater Than 69, Rolls are 19, 51, Total score is 19 Final Score is 19

Critical Roll is Greater Than 69, Rolls are 87, 41, Total score is 128 , Next Roll is 7, Total score is 128 Final Score is 128

Critical Roll is Greater Than 69, Rolls are 98, 70, Total score is 168 , Next Roll is 80, Total score is 248 , Next Roll is 95, Total score is 343 , Next Roll is 87, Total score is 430 , Next Roll is 70, Total score is 500 , Next Roll is 49, Total score is 549 , Next Roll is 28, Total score is 549 Final Score is 549

Critical Roll is Greater Than 69, Rolls are 71, 70, Total score is 141 , Next Roll is 58, Total score is 199 , Next Roll is 87, Total score is 199 Final Score is 199

Critical Roll is Greater Than 69, Rolls are 54, 11, Total score is 54 Final Score is 54

Here's the code. Looks simple now, but there was a lot of trial and error getting it to run:

``````; OpenRolls.ipt
; created 10/22/2017 2:07:25 PM

Prompt: Enter d100 value to initiate a critical roll { } 96

Define:CRIT={{\$prompt1}-1}

Set:Basenumber={1d100}

Set:Bonusnumber={1d100}

Set:Result={Basenumber}

Table: Main
Critical Roll is Greater Than {\$CRIT}, Rolls are {\$Basenumber}, {\$Bonusnumber}, [@Total_Score]

Table: Total_Score
Total score is {@Total==[when] {\$Basenumber}>{CRIT} [do]{{\$Result}+{\$Bonusnumber}}[else] {\$Result} [end]} &
{@Total} [when] {@Total}>{\$Result}[do]{Basenumber=={\$Bonusnumber}}, Next Roll is {Bonusnumber=1d100}, {result=={@Total}} [@Total_Score] [else] Final Score is {@Total} [end]
``````

And, of course, the user is prompted to enter the threshold for when to add dice together and reroll.

Now that it works, could streamline the output to be silent on "Total Score is..." So it really just lists raw dice scores sequentially, then provides the Final Score. And yes, it does always roll one time too many the way I wrote it, but never adds in more rolls than intended.

• Here's the streamlined output:

Critical Roll is Greater Than 69, Rolls are 54, 20, Final Score is 54

Critical Roll is Greater Than 69, Rolls are 15, 33, Final Score is 15

Critical Roll is Greater Than 69, Rolls are 92, 29, Next Roll is 63, Final Score is 121

Critical Roll is Greater Than 69, Rolls are 56, 47, Final Score is 56

Critical Roll is Greater Than 69, Rolls are 79, 60, Next Roll is 53, Final Score is 139

Critical Roll is Greater Than 69, Rolls are 79, 73, Next Roll is 88, Next Roll is 78, Next Roll is 19, Next Roll is 53, Final Score is 337

Critical Roll is Greater Than 69, Rolls are 64, 48, Final Score is 64

Critical Roll is Greater Than 69, Rolls are 83, 60, Next Roll is 81, Final Score is 143

Critical Roll is Greater Than 69, Rolls are 96, 20, Next Roll is 58, Final Score is 116

Critical Roll is Greater Than 69, Rolls are 39, 1, Final Score is 39

And the code:

``````; OpenRolls.ipt
; created 10/22/2017 2:07:25 PM

Prompt: Enter d100 value to initiate a critical roll { } 96

Define:CRIT={{\$prompt1}-1}

Set:Basenumber={1d100}

Set:Bonusnumber={1d100}

Set:Result={Basenumber}

Table: Main
Critical Roll is Greater Than {\$CRIT}, Rolls are {\$Basenumber}, {\$Bonusnumber}, [@Total_Score]

Table: Total_Score
{@Total==[when] {\$Basenumber}>{CRIT} [do]{{\$Result}+{\$Bonusnumber}}[else] {\$Result} [end]} &
[when] {@Total}>{\$Result}[do]{Basenumber=={\$Bonusnumber}} Next Roll is {Bonusnumber=1d100}, {result=={@Total}} [@Total_Score] [else] Final Score is {@Total} [end]
``````
• Excellent - thanks. I can see it goes on beautifully.

Now, how do I apply this result to a Lookup Table?

• Well, I'd start by replacing the prompt input with a straight "96". Just dump the prompt, dump the "Define", and replace {CRIT} with a 96. And, "==" all the other stuff, if you want to suppress all output of any rolls or Total_Score.

Then, just try [#{@Total_Score} NewTable] to use the value of Total_Score in your new lookup table.

By removing the prompt, this could also be as standalone dice roll, located in the "Common" folder, and you could call it in a different generator using a "Use" command. Then it just creates the Total_Score and brings it into your new generator.

A few ways to make it happen, depending on the overall application.

• The crit is set to 96 always, but I'm not sure what you mean by '==' all the other stuff.

Sorry, I'm not so good at this - Your code works but I have no idea why,

• edited October 2017

When you use:
`{Bonusnumber=1d100}`
It outputs the rolled number - visibly on the generator results screen. If you want the roll silent (not output on the generator) then use:
`{Bonusnumber==1d100}`
That will set the variable "Bonusnumber" to whatever the d100 result is, but not output it to the screen.

The code in Table: Total_Score was kinda crazy. Not surprised if it's hard to follow. But in the end, it creates that variable {@Total} which is the final die roll result. Put double equal signs "==" everywhere there is a single equal sign, and the value will be silently calculated and saved in {@Total}

Then just use it when calling your lookup table. The code should be something like:

`[#{@Total} NewTable]` (I think I said {@Total_Score} earlier, which was wrong)

If the die roll result was, say, 214, then that table call would in effect be saying, "Lookup a die roll of 214 on table NewTable".

And take it slow and don't lose hope - I've only been at this for a few months now. There are some limitations in IPP, but what it can do is pretty amazing.

• This outputs just the final die roll value, {@Total}

``````; OpenRolls.ipt
; created 10/22/2017 2:07:25 PM

Define:CRIT=96

Set:Basenumber={1d100}

Set:Bonusnumber={1d100}

Set:Result={Basenumber}

Table: Main
[@Total_Score]

Table: Total_Score
{@Total==[when] {\$Basenumber}>{CRIT} [do]{{\$Result}+{\$Bonusnumber}}[else] {\$Result} [end]} &
[when] {@Total}>{\$Result}[do]{Basenumber=={\$Bonusnumber}} {Bonusnumber==1d100} {result=={@Total}} [@Total_Score] [else]{@Total} [end]
``````

This uses that value in a lookup table:

``````; OpenRolls.ipt
; created 10/22/2017 2:07:25 PM

Define:CRIT=96

Set:Basenumber={1d100}

Set:Bonusnumber={1d100}

Set:Result={Basenumber}

Table: Main
[@Total_Score]

Table: Total_Score
{@Total==[when] {\$Basenumber}>{CRIT} [do]{{\$Result}+{\$Bonusnumber}}[else] {\$Result} [end]} &
[when] {@Total}>{\$Result}[do]{Basenumber=={\$Bonusnumber}} {Bonusnumber==1d100} {result=={@Total}} [@Total_Score] [else] [#{@Total} NewTable] [end]

Table: NewTable
Type: Lookup
Default: Critical Hit! {@Total} Damage
1-25: Miss. Die Roll is {@Total}
26-95: Hit! {@Total} Damage
96-1000: Critical Hit! {@Total} Damage
``````
• Wow - thanks for your help with this, I still can't work out how it works; I understand the 'When/Else' commands but not how the variables work (which is the major part of the code).

Fortunately, the Treasure generator is just lots and lots of tables and subtables. It's not hard, just time-consuming copying and pasting and then I'll have to add the refs to the other tables instead of 'roll on table 14.47'.

However, I do see one problem - the Open-Ended dice roll code referenced your 'NewTable'. There is an option to add this code again and again but changing the Variable code names (as I know that Variables are set until you hit 'generate' again).

I'm still a long way off completing it and I've only pasted a few tables to show how there's a table referenced in a table in a table (and it goes deeper still). Not all tables go above 100 (so I can keep the 'Roll: 1d100' for those) but there are a lot of them still.

As you may notice, I'd used a 'Roll: 1d400' but this gives an equal possibility of getting something awesome when the difficulty should be so much harder in reality.

``````Prompt: Creature Code { } a

Table: Main
Set: CCode=[#{\$prompt1} Creature Code]
<b>Items</b> \n[#{CCode} T-14-1_Items]\n&
\n<b>Wealth</b> \n[#{CCode} T-14-1_Wealth]
Set: ItemQtVP=[@T-14-2_ItemComponant-VP]
Set: ItemQtP=[@T-14-2_ItemComponant-P]
Set: ItemQtN=[@T-14-2_ItemComponant-N]
Set: ItemQtR=[@T-14-2_ItemComponant-R]
Set: ItemQtVR=[@T-14-2_ItemComponant-VR]

Table: T-14-1_Items
Type: Lookup
1-5: <font color="grey">Very Poor</font>\n [!{ItemQtVP} T-14-4_RND_Items-VP >> implode]
6-10: <font color="grey">Poor</font> \n[!{ItemQtP} T-14-4_RND_Items-P >> implode]
11-15: <font color="grey">Normal</font> \n[!{ItemQtN} T-14-4_RND_Items-N >> implode]
16-20: <font color="grey">Rich</font> \n[!{ItemQtR} T-14-4_RND_Items-R >> implode]
20-25: <font color="grey">Very Rich</font> \n[!{ItemQtVR} T-14-4_RND_Items-VR >> implode]
26: <font color="red">Special</font>

Table: T-14-4_RND_Items-VR
Type: Lookup
Roll:1d100
1–10: [@T-14-13_RND_Gen_Items]
11–20: [@T-14-11_RND_Arm-Leather]
21–30: [@T-14-11_RND_Arm-Metal]
31–35: [@T-14-11_RND_Arm-Shield]
36–40: [@T-14-14_RND_Weapons-Leather]
41–45: [@T-14-14_RND_Weapons-Metal]
46–50: [@T-14-14_RND_Weapons-MetalWooden]
51–55: [@T-14-14_RND_Weapons-Wooden]
56–60: [@T-14-11_RND_Arm-Leather]
61–65: Herbs
66–70: Herbs
71–75: Herbs
76–80: [@T-14-16_RND_Master_Magic_Items]
81–85: [@T-14-16_RND_Master_Magic_Items]
86–90: [@T-14-16_RND_Master_Magic_Items]
91–94: [@T-14-16_RND_Master_Magic_Items]
95–97: [@T-14-16_RND_Master_Magic_Items]
98–99: [@T-14-16_RND_Master_Magic_Items]
100: [@T-14-16_RND_Master_Magic_Items]

Table: T-14-16_RND_Master_Magic_Items
Type: Lookup
Roll:1d400
1-10: [@T-14-17_RND_Arm_Items_I]
11-20: Daily and Constant Items Table I (T-14.28)
21-30: Potions Table I (T-14.39)
31-40: Runes Table I (T-14.44)
41-50: Weapons Table I (T-14.49)
51-55: [@T-14-18_RND_Arm_Items_II]
56-59: Charged Item Table I (T-14.23)
60-63: Daily and Constant Items Table II (T-14.29)
64-67: General Items Table I (T-14.34)
68-71: Potions Table II (T-14.40)
72-75: Runes Table II (T-14.45)
76-80: Weapons Table II (T-14.50)
81-82: [@T-14-19_RND_Arm_Items_III]
83-84: Charged Items Table II (T-14.24)
85-86: Daily and Constant Items Table III (T-14.30)
87-88: General Items Table II (T-14.35)
89-90: Potions Table III (T-14.41)
91-92: Runes Table III (T-14.46)
93-95: Weapons Table III (T-14.51)
96-111: [@T-14-20_RND_Arm_Items_IV]
112-125: Charged Items Table III (T-14.25)
126-139: Daily and Constant Items Table IV (T-14.31)
140-153: General Items Table III (T-14.36)
154-167: Potions Table IV (T-14.42)
168-181: Runes Table IV (T-14.47)
182-195: Weapons Table IV (T-14.52)
196-215: [@T-14-21_RND_Arm_Items_V]
216-235: Charged Items Table IV (T-14.26)
236-255: Daily and Constant Items Table V (T-14.32)
256-275: General Table IV (T-14.37)
276-295: Weapons Table V (T-14.53)
296-311: [@T-14-22_RND_Arm_Items_VI]
312-325: Charged Items Table V (T-14.27)
326-339: Daily and Constant Items Table VI (T-14.33)
340-353: General Items Table V (T-14.38)
354-367: Potions Table V (T-14.43)
368-381: Runes Table V (T-14.48)
382-400: Weapons Table VI (T-14.54)

Table: T-14-17_RND_Arm_Items_I
Type: Lookup
Roll:1d100
1-12: +5 Metal Armor <font colour”grey”>(Lvl 5, Time 9wks, Availability Medium, Base Cost 405gp, Adj Cost 405gp)</font>
13-24: +5 Leather Armor <font colour”grey”>(Lvl 5, Time 7wks, Availability Medium, Base Cost 245gp, Adj Cost 245gp)</font>
25-36: +5 Leather Shield <font colour”grey”>(Lvl 5, Time 7wks, Availability Medium, Base Cost 49gp, Adj Cost 49gp)</font>
37-48: +5 Metal Shield <font colour”grey”>(Lvl 5, Time 9wks, Availability Medium, Base Cost 81gp, Adj Cost 81gp)</font>
49-60: +5 Wooden Shield <font colour”grey”>(Lvl 5, Time 8wks, Availability Medium, Base Cost 64gp, Adj Cost 64gp)</font>
61-68: +5/+10 vs [@WeaponGroups] - Metal Armor <font colour”grey”>(Lvl 5, Time 19wks, Availability Hard, Base Cost 1,330gp, Adj Cost 1,330gp)</font>
69-76: +5/+10 vs [@WeaponGroups] - Leather Armor <font colour”grey”>(Lvl 5, Time 17wks, Availability Hard, Base Cost 1,020gp, Adj Cost 1,020gp)</font>
77-84: +5/+10 vs [@WeaponGroups] - Leather Shield <font colour”grey”>(Lvl 5, Time 17wks, Availability Hard, Base Cost 204gp, Adj Cost 204gp)</font>
85-92: +5/+10 vs [@WeaponGroups] - Metal Shield <font colour”grey”>(Lvl 5, Time 19wks, Availability Hard, Base Cost 266gp, Adj Cost 266gp)</font>
93-100: +5/+10 vs [@WeaponGroups] - Wooden Shield <font colour”grey”>(Lvl 5, Time 18wks, Availability Hard, Base Cost 234gp, Adj Cost 234gp)</font>
``````
• So this may not be to hard... You have:

76–80: [@T-14-16_RND_Master_Magic_Items]

Which says go roll on table T-14-16_RND_Master_Magic_Items. Once there, the table says to roll a d400.

Instead, insert the "open rolls" code. Then make your call look like:

`76–80: [#{@Total} T-14-16_RND_Master_Magic_Items]`

Which says, go to table T-14-16_RND_Master_Magic_Items and find me the item that matches up to number 214 (if 214 is the value saved in @Total when it is calculated). The "Roll:1d400" line should be removed from T-14-16_RND_Master_Magic_Items as well.

It might even work to ONLY change the Roll:1d400 to:

`Roll:{@Total}`

But in table T-14-16_RND_Master_Magic_Items, you always need a default statement, in the incredibly rare event that the "Open roll" returns a value greater than 400. So something like:

``````Table: T-14-16_RND_Master_Magic_Items
Type: Lookup
Roll:{@Total}
Default: 400
``````

That way if @Total exceeds 400, you get item 400 rather than an error or blank.

• This seems pretty sound, blending the "opens rolls" code with part of your tables. I'd certainly do the prompt1, prompt2 thing from the other thread rather than using 26 letters to determine quality of items and quality of wealth. Then, I think you're well on your way!

``````; OpenRolls.ipt
; created 10/22/2017 2:07:25 PM

Define:CRIT=95

Set:Basenumber={1d100}

Set:Bonusnumber={1d100}

Set:Result={Basenumber}

Table: Main
[@Total_Score] [@Items-VR]

Table: Items-VR
Type: Lookup
Default: Failed
Roll:1d100
1-10:RND_Gen_Items
11-20:RND_Arm-Leather
21-30:T-14-11_RND_Arm-Metal
31-35:T-14-11_RND_Arm-Shield
36-40:T-14-14_RND_Weapons-Leather
41-45:T-14-14_RND_Weapons-Meta
46-50:T-14-14_RND_Weapons-MetalWooden
51-55:T-14-14_RND_Weapons-Woode
56-60:T-14-11_RND_Arm-Leather
61-65:Herbs
66-70:Herbs
71-75:Herbs
76-80: [#{@Total} T-14-16_RND_Master_Magic_Items]
81-85: [#{@Total} T-14-16_RND_Master_Magic_Items]
86-90: [#{@Total} T-14-16_RND_Master_Magic_Items]
91-94: [#{@Total} T-14-16_RND_Master_Magic_Items]
95-97: [#{@Total} T-14-16_RND_Master_Magic_Items]
98-99: [#{@Total} T-14-16_RND_Master_Magic_Items]
100: [#{@Total} T-14-16_RND_Master_Magic_Items]

Table: T-14-16_RND_Master_Magic_Items
Type: Lookup
Default:  Weapons Tables VI (T-14.54)
1-10: [@T-14-17_RND_Arm_Items_I]
11-20: Daily and Constant Items Table I (T-14.28)
21-30: Potions Table I (T-14.39)
31-40: Runes Table I (T-14.44)
41-50: Weapons Table I (T-14.49)
51-55: [@T-14-18_RND_Arm_Items_II]
56-59: Charged Item Table I (T-14.23)
60-63: Daily and Constant Items Table II (T-14.29)
64-67: General Items Table I (T-14.34)
68-71: Potions Table II (T-14.40)
72-75: Runes Table II (T-14.45)
76-80: Weapons Table II (T-14.50)
81-82: [@T-14-19_RND_Arm_Items_III]
83-84: Charged Items Table II (T-14.24)
85-86: Daily and Constant Items Table III (T-14.30)
87-88: General Items Table II (T-14.35)
89-90: Potions Table III (T-14.41)
91-92: Runes Table III (T-14.46)
93-95: Weapons Table III (T-14.51)
96-111: [@T-14-20_RND_Arm_Items_IV]
112-125: Charged Items Table III (T-14.25)
126-139: Daily and Constant Items Table IV (T-14.31)
140-153: General Items Table III (T-14.36)
154-167: Potions Table IV (T-14.42)
168-181: Runes Table IV (T-14.47)
182-195: Weapons Table IV (T-14.52)
196-215: [@T-14-21_RND_Arm_Items_V]
216-235: Charged Items Table IV (T-14.26)
236-255: Daily and Constant Items Table V (T-14.32)
256-275: General Table IV (T-14.37)
276-295: Weapons Table V (T-14.53)
296-311: [@T-14-22_RND_Arm_Items_VI]
312-325: Charged Items Table V (T-14.27)
326-339: Daily and Constant Items Table VI (T-14.33)
340-353: General Items Table V (T-14.38)
354-367: Potions Table V (T-14.43)
368-381: Runes Table V (T-14.48)
382-400: Weapons Table VI (T-14.54)

Table: T-14-17_RND_Arm_Items_I
Type: Lookup
Roll:1d100
1-12: +5 Metal Armor <font colour”grey”>(Lvl 5, Time 9wks, Availability Medium, Base Cost 405gp, Adj Cost 405gp)</font>
13-24: +5 Leather Armor <font colour”grey”>(Lvl 5, Time 7wks, Availability Medium, Base Cost 245gp, Adj Cost 245gp)</font>
25-36: +5 Leather Shield <font colour”grey”>(Lvl 5, Time 7wks, Availability Medium, Base Cost 49gp, Adj Cost 49gp)</font>
37-48: +5 Metal Shield <font colour”grey”>(Lvl 5, Time 9wks, Availability Medium, Base Cost 81gp, Adj Cost 81gp)</font>
49-60: +5 Wooden Shield <font colour”grey”>(Lvl 5, Time 8wks, Availability Medium, Base Cost 64gp, Adj Cost 64gp)</font>
61-68: +5/+10 vs [@WeaponGroups] - Metal Armor <font colour”grey”>(Lvl 5, Time 19wks, Availability Hard, Base Cost 1,330gp, Adj Cost 1,330gp)</font>
69-76: +5/+10 vs [@WeaponGroups] - Leather Armor <font colour”grey”>(Lvl 5, Time 17wks, Availability Hard, Base Cost 1,020gp, Adj Cost 1,020gp)</font>
77-84: +5/+10 vs [@WeaponGroups] - Leather Shield <font colour”grey”>(Lvl 5, Time 17wks, Availability Hard, Base Cost 204gp, Adj Cost 204gp)</font>
85-92: +5/+10 vs [@WeaponGroups] - Metal Shield <font colour”grey”>(Lvl 5, Time 19wks, Availability Hard, Base Cost 266gp, Adj Cost 266gp)</font>
93-100: +5/+10 vs [@WeaponGroups] - Wooden Shield <font colour”grey”>(Lvl 5, Time 18wks, Availability Hard, Base Cost 234gp, Adj Cost 234gp)</font>

Table: Total_Score
{@Total==[when] {\$Basenumber}>{CRIT} [do]{{\$Result}+{\$Bonusnumber}}[else] {\$Result} [end]} &
[when] {@Total}>{\$Result}[do]{Basenumber=={\$Bonusnumber}} {Bonusnumber==1d100} {result=={@Total}} [@Total_Score] [end]
``````
• Here's the logic behind the open roll...

Initial (primary) die roll is Basenumber. It's a 1d100 in the opening SET commands.

Bonusnumber is the next d100, in case the first die roll is high enough to need a next die roll.

We also set Result equal to Basenumber (equal to the first d100 roll; this will be our Total if the first die roll does not exceed 95).

Now table Total_Score is called from Main with those variables above already set.

The first When-Do says... make the value of @Total = 1st die roll + 2nd die roll if the first roll is greater than 95, otherwise set @Total to just the first die roll. Simple enough if there is only ever 2 die rolls at most.

The second When-Do is where things get fun. If @Total is greater than Result (this is only ever the case if we were able to add the first two die rolls together, otherwise they would be equal - both equal to Basenumber) then...

Rerun (loop back again to the start of) Total_Score, but first before you do:
1. make Basenumber (the first die) equal to Bonusnumber (the second die value). We're shifting the dies up in priority, because if we're looping back, then we're ready to see if die two is greater than 95.
2. We set Bonusnumber equal to a new d100 roll. Here we're creating a third die roll, and placing it in the second position - the value that we will add if the new Basenumber (which was/is Roll_2) exceeds 95.
3. Set Result equal to @Total. Result is our running total. Remember, if Roll_2 exceeds 95, then we want to add Roll_3 to the sum of (Roll_1+Roll_2), not just add Roll_3 to Roll_2.
4. Now we can loop back with a [@Total_Score] table call.

We keep doing this to keep our running total increasing as long as the next die roll exceeds 95, always storing the running total in the variable @Total.

When we fail the check @Total>;Result (i.e. the new Total is the same as Result... we didn't add to it, because the latest die roll failed to exceed 95), then we END the loop and return to from Total_Score to Main with an accumulated dice roll value stored in @Total.

In all likelihood, Result could be eliminated completely and it could all be done with Basenumber, Bonusnumber, and Total. But, the code is working, so why bother messing with it.

Back in the day (and I mean seriously ancient times) we always had to use a line that went something like "set N = N +1" to increment our counter before looping back to the start of a routine. The second When-Do is just accomplishing something similar by incrementing the die rolls to the next higher priority (Roll_2 becomes primary, Roll_3 becomes bonus; if the rolls continue to exceed 95, then Roll_3 becomes primary and Roll_4 is made as the bonus, etc.) . It's a hack of creating a WHILE-Do or an UNTIL-Do statement.

• Thanks for the huge reply and explanation - I've not managed to read it yet, I suffer from chronic migraine and things have been bad but I didn't want you to think I'm ignoring you on purpose.