D&D Advantage/Disadvantage dice rolling

Hi!

You can use Math.max and Math.min to get the higher/lower of two rolls:

<<set $roll to Math.min(random(1,100), random(1,100))>> --> this gives you the lower of 2 rolls

<<set $roll to Math.max(random(1,100), random(1,100))>> --> this gives you the higher of 2 rolls

Also, I don’t really know your story structure, so this may not be useful to you, but if there’s significant branching depending on the results of such tests (and not just different flavour text) doing all the testing inside the <<link>> macro and redirecting to different passages may help organise the things better. It lets you use temporary variables as well, which don’t clutter your Story History:

<<link "Test Strength">><<set _roll to Math.min(random(1,100), random(1,100))>><<if _roll gt $str>><<goto "lose">><<else>><<goto "win">><</if>><</link>>

2 Likes