Page 1 of 1

Dice Rollers for Godlike, Wild Talents, and REIGN

Posted: Mon Dec 15, 2008 2:24 pm
by Rumble
Hello all. I've been digging deep into MapTool lately to work on some D&D stuff, but I needed a break from polishing that particular...apple...and started working on a dice roller for the One-Roll Engine games.

I don't know if anybody plays them, or if any roller code has already been posted, but I thought I'd share. For those who don't know, the mechanic for those games is to roll a pool of 2 to 10 d10's, and then count matches. If you get a match (two dice coming up the same number), you have a set. Set have "width" - in other words, how many dice matched; and "height", or what number was matched.

So if you rolled and had two dice come up 10, you would have a set that was 2 wide and 10 high, or a "2x10" set.

Anyway, so I wrote a macro that rolls some number of d10s and figures out how many sets.

Code: Select all

[h:resList=""]
[h:outputList=""]

[h,count(dicepool),CODE:
{
[h:resList=setStrProp(resList,"roll"+roll.count,1d10)]
}]

[h:sets1=0]
[h:sets2=0]
[h:sets3=0]
[h:sets4=0]
[h:sets5=0]
[h:sets6=0]
[h:sets7=0]
[h:sets8=0]
[h:sets9=0]
[h:sets10=0]

[h,count(10),code:
{
   [h:sets1=sets1+if(getStrProp(resList,"roll"+roll.count)=="1",1,0)]
   [h:sets2=sets2+if(getStrProp(resList,"roll"+roll.count)=="2",1,0)]
   [h:sets3=sets3+if(getStrProp(resList,"roll"+roll.count)=="3",1,0)]
   [h:sets4=sets4+if(getStrProp(resList,"roll"+roll.count)=="4",1,0)]
   [h:sets5=sets5+if(getStrProp(resList,"roll"+roll.count)=="5",1,0)]
   [h:sets6=sets6+if(getStrProp(resList,"roll"+roll.count)=="6",1,0)]	
   [h:sets7=sets7+if(getStrProp(resList,"roll"+roll.count)=="7",1,0)]
   [h:sets8=sets8+if(getStrProp(resList,"roll"+roll.count)=="8",1,0)]
   [h:sets9=sets9+if(getStrProp(resList,"roll"+roll.count)=="9",1,0)]
   [h:sets10=sets10+if(getStrProp(resList,"roll"+roll.count)=="10",1,0)]
}]

[h,for(x,0,9),CODE:
{
   [h:setSlot=x+1]
   [h:sets=eval("sets"+setSlot)]
   [h:setString=if(sets>=2, sets+"x"+setSlot, "")]
   [h:outputList=if(setString!="", listAppend(outputList, setString), outPutList)]
 }]

[IF(outputList!=""),CODE:
{
   Rolling [r:dicepool+"d"]: [r:outputList]
};
{
   Rolling [r:dicepool+"d"]: No sets.
};]
   
Please feel free to critique, compliment, or borrow as you feel appropriate! It's not perfectly elegant, but there are some list functions that don't yet exist that would have made it simpler. Fortunately, you can never roll more than 10 dice, so there's a limit to possible sets, which makes this doable. Anyway, it seems to work, so enjoy.

Re: Dice Rollers for Godlike, Wild Talents, and REIGN

Posted: Sat Sep 12, 2015 5:10 pm
by yoshifanx
I Like it but is there any way it can show each individual roll?