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

Macros and Conditional Statements

1407437973

Edited 1407444759
Since you can't do a true conditional in Roll20, I'm trying to fake it with queries and multiplication, but the results aren't what I'd hoped. /me fires a bulbous-tipped arrow at her foe, the metal head expanding in flight before tripping up the target's appendages. Single Shot: [[1d20+?{Smite|0}*@{Cha-Mod}+@{Dex-Mod}+@{attk-ranged-misc}+@{class-0-bab}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(?{full-attk|0}*?{deadly-aim})-(?{full-attk|0}*@{rapid-shot})+1*?{Point-Blank|0}-1]] Attack /roll 1d20+@{class-0-bab}+?{Smite|0}*@{Cha-Mod}+(?{Point-Blank|0}*1)+@{Str-Mod}+@{attk-ranged-misc}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(?{full-attk|0}*@{deadly-aim|0}-(?{full-attk|0}*@{rapid-shot})+5 vs CMD. Result: [[0-(?{Point-Blank}*1)]] This macro should, based on how I'm looking at it, allow me to input a "1" for Smite, full-attk and Point-Blank when I want each of those attributes, and a "0" when I don't. In practice, however, Smite works fine but the others do not.
1407439438
Gauss
Forum Champion
For a query to input a default value when you do not put one in you should use ?{query name|default value}.
That's not the issue; for example, when I put in a '1' for Smite in the above macro, it correctly adds my Cha-Mod, 4. When I put in a '0', the resulting roll is 4 lower. When I do the same things for the full-attk variable, however, it doesn't work.
1407445060

Edited 1407445263
Gauss
Forum Champion
Please provide more information as to what happens when this does not work correctly. Also, what values are you putting in for ?{deadly-aim} and @{rapid-shot}? Finally, I suggest breaking down your macro into pieces to find out what is breaking it. Start with [[1d20+?{Smite|0}*@{Cha-Mod}]] and then add pieces until something breaks.
I finally got all of them working. I'm not entirely sure how I fixed it, but these are the final versions of the conditional macros, if anyone would like to see and finds this useful. I think only one query can be in any given polynomial term, and I think it must be the first variable being multiplied or divided. /me fires a bulbous-tipped arrow at her foe, the metal head expanding in flight. With any luck, it'd be tripping up the target's appendages. Single Shot: [[1d20+?{Smite|0}*@{Cha-Mod}+@{Dex-Mod}+@{attk-ranged-misc}+@{class-0-bab}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(@{deadly-aim}*?{full-attk|0})-(@{rapid-shot}*?{full-attk|0})+1*?{Point-Blank|0}]] Attack. [[1d20+?{Smite|0}*@{Cha-Mod}+@{Dex-Mod}+@{attk-ranged-misc}+@{class-0-bab}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(@{deadly-aim}*?{full-attk|0})-(@{rapid-shot}*?{full-attk|0})+1*?{Point-Blank|0}+5]] vs CMD. It's worth noting that I finally got all of my damage and attack rolls to line up for me, but when a friend with GM permissions tried using the macro from my token, he got weird results for damage with this macro when inputting 0 to all queries, like a -7 damage roll once. /me moves with supernatural speed as she fires a flurry of arrows; when they strike, each one slowly ignites. Double Shot: [[1d20+?{Smite|0}*@{Cha-Mod}+@{Dex-Mod}+@{attk-ranged-misc}+@{class-0-bab}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(?{full-attk|0}*@{deadly-aim})-(@{rapid-shot}*?{full-attk|0})+1*?{Point-Blank|0}-1]] Attack, [[1d8+(2d6*?{Holy|0})+@{class-0-level}*?{Smite}+@{class-0-level}*?{outsider|0}+@{Str-Mod}+@{bow-enh-attk}+?{Point-Blank|0}*1+(?{full-attk}*@{Deadly-Aim}*2)+@{morale-damage}+@{comp-damage})]] + [[1d8+(2d6*?{Holy|0})+@{class-0-level}*?{Smite}+@{Str-Mod}+@{bow-enh-attk}+?{Point-Blank|0}*1+(?{full-attk}*@{Deadly-Aim}*2)+@{morale-damage}+@{comp-damage})]] Damage. Slow Burn: [[2d6]]. Rapid Shot: [[1d20+?{Smite|0}*@{Cha-Mod}+@{Dex-Mod}+@{attk-ranged-misc}+@{class-0-bab}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(?{full-attk|0}*@{deadly-aim})-(@{rapid-shot}*?{full-attk|0})+1*?{Point-Blank|0}-1]] Attack, [[1d8+(2d6*?{Holy|0})+@{class-0-level}*?{Smite}+@{Str-Mod}+@{bow-enh-attk}+?{Point-Blank|0}*1+(?{full-attk}*@{Deadly-Aim}*2)+@{morale-damage}+@{comp-damage})]] Damage. Slow Burn: [[1d6]] Iterative A: [[1d20+?{Smite|0}*@{Cha-Mod}+@{Dex-Mod}+@{attk-ranged-misc}+@{class-0-bab}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(?{full-attk|0}*@{deadly-aim})-(@{rapid-shot}*?{full-attk|0})+1*?{Point-Blank|0}-6]] Attack, [[1d8+(2d6*?{Holy|0})+@{class-0-level}*?{Smite}+@{Str-Mod}+@{bow-enh-attk}+?{Point-Blank|0}*1+(?{full-attk}*@{Deadly-Aim}*2)+@{morale-damage}+@{comp-damage})]] Damage. Slow Burn: [[1d6]] Iterative B: [[1d20+?{Smite|0}*@{Cha-Mod}+@{Dex-Mod}+@{attk-ranged-misc}+@{class-0-bab}+@{bow-enh-attk}+@{haste-bonus}+@{comp-attk}-(?{full-attk|0}*@{deadly-aim})-(@{rapid-shot}*?{full-attk|0})+1*?{Point-Blank|0}-11]] Attack, [[1d8+(2d6*?{Holy|0})+@{class-0-level}*?{Smite}+@{Str-Mod}+@{bow-enh-attk}+?{Point-Blank|0}*1+(?{full-attk}*@{Deadly-Aim}*2)+@{morale-damage}+@{comp-damage})]] Damage. Slow Burn: [[1d6]] Slow Burn takes effect at start of my next turn. Only one arrow can crit (x3) in Double Shot. No attack can deal less than 1 damage before DR. However, on around 100 tests with different numbers, the macro will not give me these weird results. So. I have no clue what the heck is going on.
1408644539

Edited 1408644580
This is clever. I like this. I've been trying to figure out a way to imitate conditional statements.
1408656456
Lithl
Pro
Sheet Author
API Scripter
Cinder Skye said: It's worth noting that I finally got all of my damage and attack rolls to line up for me, but when a friend with GM permissions tried using the macro from my token, he got weird results for damage with this macro when inputting 0 to all queries, like a -7 damage roll once. From the macros you posted, that should only happen (getting negative damage when using 0 for all queries) if some of the attributes you're using have negative values. For example, "Iterative A" ends up with an effective damage roll of 1d8+@{Str-Mod}+@{bow-enh-attk}+@{morale-damage}+@{comp-damage} . You could only get a -7 on that roll if you have negative attributes. (Also, you've got an extra closing parentheses after @{comp-damage}, looks like) That said, Iterative A's attack roll does have a -6 modifier after setting the queries to 0, and Iterative B has a -11 modifier. Some of your queries also don't have default values (such as Smite), which could cause issues if your friend is running through them by hitting Enter instead of typing 0 each time.