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

Macro help request – force result to return "0" not a negative

1588772923

Edited 1588774383
Hello, Can a macro be made to return a result of "0" instead of a negative number, when subtracting two values? I've written a macro to calculate damage for a Werewolf The Apocalypse game. In the mechanics, the player rolls a dice pool of d10s against a difficulty level to inflict damage, and their opponent rolls a dice pool of d10s against a difficulty level to reduce the damage they take (soaking). My macro calculates the player's damage successes (Strength+Damage dice), calculates the target's soak successes (Stamina+Armor), and subtracts the soak successes from the damage successes, to give the total damage. @{selected|token_name} inflicts [[(@{selected|Strength}+?{Attack|Bite,1|Claw,1})d10>6-((@{target|Foe|Stamina}d10>6)+(@{target|Foe|armor-Rating}d10>6))]] So is it possible to force the macro to return a result of "0" if there are soak successes than damage success? It'll save me have to constantly tell my players, "No, -2 damage does not mean you heal your opponent". Thanks. EDIT: I have tried variants using "kh1", like below, but the macro either breaks or still returns negative numbers. @{selected|token_name} inflicts [[[[(@{selected|Strength}+?{Attack|Bite,1|Claw,1})d10>6-((@{target|Foe|Stamina}d10>6)+(@{target|Foe|armor-Rating}d10>6))]],[[0d0]]kh1]] - Richard
1588774629
The Aaron
Roll20 Production Team
API Scripter
Try this: @{selected|token_name} inflicts [[{[[(@{selected|Strength}+?{Attack|Bite,1|Claw,1})d10>6-((@{target|Foe|Stamina}d10>6)+(@{target|Foe|armor-Rating}d10>6))]],[[0d0]]}kh1]]
Thanks for the help: I've never been good at maths, and I haven't done any coding since writing stuff in BASIC in the 1980s. Your suggestion didn't work either. The roll always comes out as "0". The calculations on test rolls were show as: {-1,0}kh1 = {-1,0} or {-2,0}kh1 = {-2,0}
1588785733
The Aaron
Roll20 Production Team
API Scripter
That looks like it's working correctly.  If you pull the formula out and run it, is it always less than 0?
It took five rolls for the result to come out as 1. What threw me is my macro would display the full dice roll results (like "10+7+1+8"). I think there's a flaw in my original formula. I'll have to check it properly later, when I'm not at work. Thanks for the assist.
1588789052
The Aaron
Roll20 Production Team
API Scripter
No problem!
I think I've got it working. I corrected my formula, and used your "kh1" amendments. I say "think" because the result still comes up as "{X,0}kh1 = {X,0}", rather than the actual dice roll. Thanks for the assist. @{selected|token_name} inflicts [[{[[(@{selected|Strength}+?{Attack|Bite,1|Claw,1}+?{Attack bonus|0})d10>6)-(@{target|Foe|Stamina}+@{target|Foe|armor-Rating})d10>6]],[[0d0]]}kh1]] damage.
1588797875
The Aaron
Roll20 Production Team
API Scripter
That's extremely odd.  But as long as it works for you!
1588799694

Edited 1588806482
The Aaron said: That's extremely odd. Well, if there's an obscure and strange bug in any software, you can be guaranteed that I'll find it. EDIT: Full macro, if anyone reading this wants to use it. &{template:default} {{Damage= @{selected|token_name} inflicts **[[{[[(@{selected|Strength}+?{Attack|Bite,1|Hispo bite,2|Claw,1|Kick,1|Punch,0|Body tackle,0|Grapple,0}+(?{Attack successes|0}-1)+?{Other modifier|0})d10>6)-(@{target|Foe|Stamina}+@{target|Foe|armor-Rating})d10>6]],[[0d0]]}kh1]]** levels of **?{Damage type|bashing|lethal|aggravated}** damage.}} {{Note= *Includes target’s soak roll*}}