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

Drop dices based on target number

Hi, I try to write an ability in a character sheet. My idea was to put all in one calculation, dropping the successes and subtract the failures delta from the ability value but I couldn't find a way to get it working that way. Example: A character needs to evade an attack. For that he got an "evasion" ability with a certain level. To perform this ability he got to roll 3d20 against certain attributes. In this case those attributes would be agility, courage and intuition. A success is when the dice throw is equal to the attribute or lower (1 critical success, 20 critical failure). If he fails a dice throw, he needs to compensate the difference of the throw to his attribute, with the level of his ability. Since I'm not much of a mathematician, I'll write the logic in pseudo code. //dice throws; d20s d1 = 11 d2 = 15 d3 = 8 //attributes a1 = 13 (agility) a2 = 12 (courage) a3 = 12 (intuition) //ability evasion = 4 if(d1 > a1) evasion += d1 * (-1) + a1 //(11 > 13) false if(d2 > a2) evasion += d2 * (-1) + a2 //(15 > 12) true -> 15 * (-1) + 12 -> evasion += -3 if(d3 > a3) evasion += d3 * (-1) + a3 //(8 > 12) false //evasion == 4 -3 == 1 // ability check passed My current code in roll20 is as follows: " Evasion AG [[d20 *-1 + @{Character|Agility}]] CU [[d20 *-1 + @{Character|Courage}]] IN [[d20 *-1 + @{Character|Intuition}]] Ability value [[@{Character|Evasion}]] " Is this even possible with standard macro/ability functionalities or is this only possible with API access? Thanks in advance for the help :)
1614786574
David M.
Pro
API Scripter
Unfortunately that kind of conditional logic is only going to be possible with api access.
However the conditional logic can be removed. So instead of if(d1 > a1) evasion += d1 * (-1) + a1 It can be rethought as evasion += min(a1-d1,0) Since when   (d1 > a1)   it will perform  a1 - d1   but otherwise it will return a zero effectively doing nothing. This kind of min function can be implemented using group roll kl1 modifier. So the macro could look like this - &{template:default} {{name=Evasion}} [[ @{Character|Evasion}[Evasion] + {[[@{Character|Agility}-1d20cs1cf20]],0}kl1[Agility] + {[[@{Character|Courage}-1d20cs1cf20]],0}kl1[Courage] + {[[@{Character|Intuition}-1d20cs1cf20]],0}kl1[Intuition] ]] {{AG=$[[0]]}} {{CU=$[[1]]}} {{IN=$[[2]]}} {{Ability value=[[@{Character|Evasion}]]}} {{Success?=$[[3]]}}
1614797432
David M.
Pro
API Scripter
Slick!
Thx for the replies guys! @RainbowEncoder Your solution works like a charm! I didn't understand it entirely yet, but I'm reading further into the topic and it gets clearer ^^ Have a great day guys!