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 .
×

Macro to IF/THEN roll certain dice based on result of other dice

I have been searching for a perfect macro for a wild dice system within 5e in a one shot I'm running, and I haven't been able to make it work between roll tables and queries. Making each step of the logic into separate checks/attacks on the sheet would be the simplest, but a one button solution for my "based on result of roll X, roll option Y" is more what I'm looking for. The system goes like this: Step 1: Roll 1d6 Step 2: Based on the result of the d6, roll 2d? or 4d? if "empowered". The "?" dice is found via: 1 = d4 2 = d6    3 = d8    4 = d10 5 = d12 6 = d20 From my searching around on the forums there doesn't seem to be a simple syntax for an if/then check, but does anyone have any ideas on how to handle this in one single macro button/effect/attack?
1658391820
GiGs
Pro
Sheet Author
API Scripter
You can't do if/then statements at all in macros, it's explicitly not designed for them. If you can think of a way to turn a query or roll result into an arithmetic expression it can be done. Your roll would be possible, except for the jump that at 6. A two-macro solution is the only way I can think of doing it.
The "empowered" conditional can be a query returning 2 or 4. As for the dice progression that can be handling with a group roll with target number to count up to the die size based on the initial d6 &{template:default} {{Step 1=$[[0.computed]]}} {{Step 2=[[ ?{Empowered?|No,2|Yes,4}d[[ 2*{1,1,2,3,4,5,6,6,6,6}<[[1d6]] ]] ]]}}
1658404154

Edited 1658404206
GiGs
Pro
Sheet Author
API Scripter
Can you explain how this bit works? [[ 2*{1,1,2,3,4,5,6,6,6,6}<[[1d6]] ]] Edit: nvm, I figured it out. Neat.
1658404660

Edited 1658404719
David M.
Pro
API Scripter
EDIT - ninjalol Wanted to make sure I understand what is happening here.  [[ 2*{1,1,2,3,4,5,6,6,6,6}<[[1d6]] ]] d6 roll    #successes (# items in group less than or equal to target number) 1            2  - {1,1} 2            3  - {1,1,2} 3            4  - {1,1,2,3} 4            5  - {1,1,2,3,4} 5            6  - {1,1,2,3,4,5} 6            10 - {1,1,2,3,4,5,6,6,6,6} #successes gets multiplied by 2 and that result is the final die size. Correct?
Yep. You've got it. It's pretty much my go-to for encoding sequences since it can handle any non-decreasing sequence. If the target number is replicable (such as a 'level' attribute) you can sum a positive one and a negative one to handle any arbitrary sequence.
1658406516
David M.
Pro
API Scripter
Slick.
This works beautifully! Very creative solution given the limitations. Thanks a lot RainbowEncoder for the logic and David for the explainer code block.