About Me

My photo
Denver, Colorado, United States
I'm an old time roleplayer who became a soldier who became a veteran who became a developer who became a dba who became a manager who never gave up his dream of a better world. Even if I have to create it myself.

Sunday, March 11, 2012

Macro for Exploding Tier Dice

MapTool has a built in dice interpreter, so you can type things like [d20] into the chat panel and it will kindly obey.  Phoenix RPG uses exploding dice for most rolls, and MapTool supports this with the 'e' suffix: [d20e].

However, it doesn't show component dice involved in that roll, so if you roll [2d6e], and get a 9, it is impossible to tell whether that roll was 5/4, or 6/1/2.  (School me if you know a way around this.)  Also, it's pure text, and I prefer seeing the dice imagery.

I'm not trying to take away from the very awesome job the devs have done on this product, but for my game I would like to see all the individual dice - graphically - and have the explosions displayed in all their extra-dice glory.  The excitement of getting a die explosion is very important to the Phoenix experience, and I want virtual play to get as close as possible to the same fun!

No problem - MapTool has a macro language, so it's a good time to try it out.

Here is a macro I made which rolls mortal tier dice - 2d10e.  Or 2d*10 if you use Dicenomicon, as all good gamers should.

First, I made a table called D10, which simply has for a Range the value of the face (1-10), and then as an image, the matching die face from MapTool's default image library.

Here's the code that goes along with that table.

[h: roll1=1d10]
[h: roll2=1d10]
[h: total=roll1 + roll2]


<image src='[r: tableImage("D10", roll1)]'></image>
<image src='[r: tableImage("D10", roll2)]'></image>


[while(roll1==10), code:
{
  [h: roll1=1d10]
  [h: total = total + roll1]
  <image src='[r: tableImage("D10", roll1)]'></image>
}]


[while(roll2==10), code:
{
  [h: roll2=1d10]
  [h: total = total + roll2]
  <image src='[r: tableImage("D10", roll2)]'></image>
}]


<br /><b>Total: [r: total]</b>



Revised and simplified below:

[h: rollcount = 2]
[h: total = 0]

[r, while(rollcount > 0, ""), code:
{
  [h: roll = 1d10]
  [h: total = total + roll]
  <image src='[r: tableImage("D10", roll)]'></image>
  [h, if (roll != 10): rollcount = rollcount - 1]
}]

<br /><b>Total: [r: total]</b>



IT'S ALIVE!

Pretty easy!  They did a good job making this an easy language to learn.

5 comments:

  1. Nice, looks like a pretty flexible language. I wonder if you can do more than just dice rolls with it.

    That said, the programmer in me wonders why you hard coded it for 2 dice, instead of n.

    Here's some code I came up with, just based on your code - I assume there's some sort of do-while loop in this macro language.

    http://pastebin.com/YXuidikj

    And yes, I'm bored at work.

    ReplyDelete
    Replies
    1. Awesome. The biggest reason was that I wanted to display the original 2 dice, followed by the exploding dice from either of those. Your code would make them appear after the exploding die and not at the end after the "base roll".

      That being said proper programming for this would involve a simple data structure, sorted for display, but I was too lazy for that. MapTool does support JSON style arrays and objects, and when I need to support Heroic/Demigod tiers it's going to make sense to use some more advanced modularization.

      MapTool can indeed do a lot more than roll dice - stay tuned...

      And if you have lots of extra time, maybe I should put you to work!

      Delete
    2. Hmm actually I guess I could just have an explosion counter...

      Delete
    3. Heck I missed the obvious way to do it. Check out the revision in the main post. Pretty similar to your idea, actually.

      Been getting better with this language over the last couple of days... will post more complex stuff soon.

      Delete
  2. You lot make my brain hurt. I just want to push a button and have it go.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...