Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

exploit all the dice

hello i am testing a game and it consists of a 3d10 roll that when the value of the average die is 10, explode again the 3d10 and add the value of the average die.  3d10kh2dl1s I currently have this formula but only the middle die explodes, is it possible that when the average die value is 10, all the dice are rolled again and the central die is added?
1652887337
David M.
Pro
API Scripter
A scriptcard could easily do this. Do you sort the three d10's first, or just take them in order? Eg: if sorted, [4/10/5] will not explode because it becomes [4/5/10]. But if not sorted, it will explode.  If sorted, explosion will only happen if you have at least 3 10's rolled
1652887581

Edited 1652887722
Kinower
Sheet Author
the order is not important. what is important is that the central die is the main die, the lowest and the highest die are discarded. but when the central die explodes [4 /10 /10] = 10 then another die roll is made [2/ 5 /8] = 5 result= 10+5
1652889495

Edited 1652889561
David M.
Pro
API Scripter
And if no explosion, the total is just the central die? I'm assuming the left/right dice are used for some other game mechanic? EDIT - and explosions only happen once? or do they keep happening?
there is always explosion, the other two dice are discarded, only the central die counts.
1652890746
David M.
Pro
API Scripter
Does this work? Requires the Scriptcards api script. Recursively calls the RollDice function until the central die is not a 10. Adds up all the central dice. !script {{ --#title|3d10 exploding mechanic --=Total|0 -->RollDice| --+Total|[$Total] --X| End macro --:RollDice| --=Roll1|1d10 --=Roll2|1d10 --=Roll3|1d10 --=Total|[$Total] + [$Roll2] --+Rolls|[$Roll1] [$Roll2] [$Roll3] --?[$Roll2] -eq 10|[ -->RollDice| --]| --<| }} Example output:
it would really work like this. of the three dice, the highest and lowest die are discarded. it explodes if a 10 is rolled (two 10's because one is discarded as it is higher).
1652892491
David M.
Pro
API Scripter
Oops, I missed that in your follow-up. OK, I have a bubble sort algorithm somewhere I should be able to add in
sorry I didn't explain well
1652893487
David M.
Pro
API Scripter
Try this? I also had to disable the roll highlighting because it seemed to get wonky after the sorting (the green 10's would lose their color if sorted) !script {{ --#title|3d10 exploding mechanic --#nominmaxhighlight|1 --=Total|0 -->RollDice| --+Total|[$Total] --X| End macro --:FUNCTIONS| --:RollDice| --=Roll1|1d10 --=Roll2|1d10 --=Roll3|1d10 --/--------------------------------------------------------------------------- --:Perform Bubble sort| --=i|0 --=NumDice|3 --=max_i|[$NumDice] -1 --:OuterLoop| --=i|[$i]+1 --=j|[$i] --:InnerLoop| --=j|[$j]+1 --?[$Roll[$i.Raw]] -gt [$Roll[$j.Raw]] |>BubbleUp;[$i.Raw];[$j.Raw] --?[$j.Raw] -lt [$NumDice.Raw]|InnerLoop --?[$i.Raw] -lt [$max_i.Raw]|OuterLoop --/--------------------------------------------------------------------------- --=Total|[$Total] + [$Roll2] --+Rolls|[$Roll1] [$Roll2] [$Roll3] --?[$Roll2] -eq 10|[ -->RollDice| --]| --<| --:BubbleUp| accepts i, j as parameters. Swaps Roll[i] & Roll[j] --=Temp|[$Roll[%2%]] --=Roll[%2%]|[$Roll[%1%]] --=Roll[%1%]|[$Temp] --<| }}
Wow, thank you very much,  one doubt I am quite green in the script,  What do I have to put in the roll for this script to work? I currently use this value="&{template:default} {{result=[[3d10!!kl2dl1s]]}}"
1652894671

Edited 1652894869
David M.
Pro
API Scripter
You would just need to install the Scriptcards api script (available for 1-click install) and run the macro as written from a collections macro or character ability.  Scriptcards parses the macro line by line. The body of the macro is very short: --#title|3d10 exploding mechanic --#nominmaxhighlight|1 --=Total|0 -->RollDice| --+Total|[$Total] --X| End macro The macro also has two functions "RollDice" and "BubbleUp", that are called multiple times. The rolls and all the logic are handled by the scriptcards parser. For example, this line (found in the RollDice function) --=Roll1|1d10 ...assigns a d10 roll result to a roll variable named "Roll1". We do this three times, populating Roll1, Roll2, and Roll3. Then the results are sorted using a bubble sort algorithm. Then the value of the middle die is added to the total (which starts at 0) with this line: --=Total|[$Total] + [$Roll2] This part (also after sorting) checks if the middle die was a 10 and if so recursively calls the RollDice function and we repeat the above process. --?[$Roll2] -eq 10|[ -->RollDice| --]| When this is all done, we finally print out the total with this line --+Total|[$Total]
¡¡¡Estupendo muchas gracias!!!