I’m beginning to like Twitter.

Wednesday evening, I happened to check Twitter just before heading to bed. I was just in time to see an exchange between @NewbieDM (aka Enrique of NewbieDM.com) and @MarkMeredith (aka Dice Monkey). They had just finished trying to play some Star Wars d6 via Google+ hangouts, and it hadn’t worked all that well. Enrique was about to show Mark some MapTool stuff. I chimed in, and they invited me to join them on Skype.

Even though he hasn’t been using MapTool very long, Enrique has already built some extensive stuff for his Neverwinter campaign (using my MapTool framework as a base, I’m humbly proud to say). He started showing Mark the ropes, and it soon became clear that Star Wars d6 was a little bit different in terms of the way die rolling works. I knew nothing about the game, so Mark explained it.

The basic dice mechanic is this (as I understand it, this is the mechanic for all OpenD6 games):

- You roll a certain number of six-sided dice, depending on your skill at the task at hand. For this example, we’ll say you have a skill of 3, so you’re rolling 3d6.
- One of the dice is the wild die; the other dice are rolled normally.
- If you roll a 6 on the wild die, it “explodes”. That is, you roll it again and add both rolls together. If you roll
*another* 6, you keep on going.
- However, if you roll a 1 on the wild die, it counts as a zero, and it also
*cancels out* the highest non-wild die that you rolled. So, if you roll a 2 and a 3 on your normal dice and a 1 on the wild die, your total is just 2 (because the 1 on the wild die cancels out the 3 from your best normal die).

I knew that MapTool had a built-in roll option to handling exploding dice, but I don’t know of any roll options to have a certain die cancel another die roll. So, I wrote a macro:

[h: x=input("NumDice|0|How many dice are you rolling?")]
[h: abort(x)]

This brings up a prompt for the user to tell the program how many dice to roll. If they hit Cancel, the macro stops.

[h: RegTotal=0]
[h: RegMax=0]

I establish starting values of zero for the total of the regular (non-wild) dice and the maximum of any regular die.

Regular dice:
[for(i, 0, NumDice-1), CODE:
{

I display the words “Regular dice: ” in the chat window, then start a loop. Note that loops begin with 0 rather than 1 in MapTool by default, so I go with that. I want to loop through all of the dice except the wild die, so I stop at NumDice-1. I then open a CODE block with a curly bracket; everything in this block will be executed a number of times equal to the number of dice minus one.

[NewRoll=d6]

First, I roll a d6 and store the value as NewRoll. Note that I didn’t use the h: roll option here as I do in most lines of code. This is because I don’t want the value of NewRoll to be hidden (the h:). Since this is a FOR loop, MapTool will put a comma between the iterations. So, if this was the only thing in the CODE block, MapTool would display “Regular dice: 2, 4” if it rolled a 2 and then a 4 on the two iterations.

[h: RegTotal=RegTotal+NewRoll]
[h: RegMax=if(NewRoll>RegMax,NewRoll,RegMax)]
}
]

I add this new die roll to the running total of the regular dice (which started at zero). I then check to see if this new roll is higher than any of the previous regular die rolls. If it is, I set the value of RegMax to equal the new die roll; otherwise, I leave RegMax where it was. I then close the FOR loop.

[h: WildResult=d6e]
<br>Wild die=[WildResult]

Now I roll the wild die and store the result as WildResult. I use an “e” on the end of the die roll expression to represent “exploding” which MapTool already has built in. Nice! I then put in a line break (the <br>) in the chat window and then display the words “Wild die=” followed by the result of the exploding die roll.

[h: FinalTally=if(WildResult==1, RegTotal-RegMax, RegTotal+WildResult)]
<br>Total=<b>[FinalTally]</b><br>

I now figure out and display the final result of the whole roll. If the wild die was a 1, the total for the roll is whatever I rolled on the regular dice, minus the highest regular die (the 1 from the wild die is not added). Otherwise, the total for the roll is the total of the regular dice plus the result of the wild die (including any explosions). I pop in another line break and display the final result in bold (the <b> and </b> surrounding the value of FinalTally).

The result will look something like this:

Regular dice: 2 , 3
Wild die=2
Total=**7** |

There you have it – the basic Star Wars d6 dice macro! Now I just need to learn to play the game.

-Michael, the OnlineDM (@OnlineDM1 on Twitter)

**Complete macro**:

[h: x=input("NumDice|0|How many dice are you rolling?")]
[h: abort(x)]
[h: RegTotal=0]
[h: RegMax=0]
Regular dice:
[for(i, 0, NumDice-1), CODE:
{
[NewRoll=d6]
[h: RegTotal=RegTotal+NewRoll]
[h: RegMax=if(NewRoll>RegMax,NewRoll,RegMax)]
}
]
[h: WildResult=d6e]
<br>Wild die=[WildResult]
[h: FinalTally=if(WildResult==1, RegTotal-RegMax, RegTotal+WildResult)]
<br>Total=<b>[FinalTally]</b><br>