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

Multi Option Macro

As we know there are no built in IF statements.  A while ago I placed a multi level spell macro can work with a pseudo IF setup.  Starting a new character, with two feats both for archery presented a problem, this is how it sits.  The PC is a Human (Werewolf) Fighter 5 / Rogue 4.  He's a bounty hunter, and mad as a cut snake.  Anyway, he also has the feats Sharp Shooter, and Vital Striker (from the D&Dwiki).  Both require a -5 to the attack roll, but one applied a flat 10 points, the other applies an effect and 1d6 damage.  As a fighter he is a archery specced fighter with the battle master archtype.  But here is where it gets nuts.  In one action per round I can attempt a sneak attack if conditions are right.  I also have the two feats.  I also have the assassinate option as I went assassin for rogue.  I can also as a fighter apply a maneuver as well.  So I was originally going to make a macro for each, and then call them from another macro.  But I had loads of problems with doing it, so I forced myself to come up with a single macro that replaces the 50 odd I needed (counting most combinations of shots) with a single one. I went back to basic code, binary.  On and off.  Setting a value for On at 5, and off at 0.  I was then able to apply them with some maths to generate a desired result. &{template:5eDefault} {{title=@{xxx|rangedweaponname1}}} {{weapon=1}} {{subheader=@{xxx|character_name}}} {{subheaderright=Ranged attack}} {{emote=Code: ?{SharpShooter|Yes,5|No,0}?{VitalStrike|Yes,5|No,0}?{SharpShooter|Yes,5|No,0}?{VitalStrike|Yes,5|No,0}?{Maneuvour|Yes,1|No,0}?{SneakAttack|Yes,2|No,0}?{Fire|Yes,1|No,0}?{Poison|Yes,1|No,0}}} {{showclassactions=1}} {{Attack Rolls= Hits AC [[ [[1d20]] + [[@{xxx|rangedtohit1}]] + [[@{xxx|global_ranged_attack_bonus}]] -?{SharpShooter} -?{VitalStrike} ]] Hits AC [[1d20 + [[@{xxx|rangedtohit1}]] + [[@{xxx|global_ranged_attack_bonus}]] -?{SharpShooter} -?{VitalStrike} ]] }} {{Range=600'}} {{Damage=[[[[1d8]] + [[[[?{SharpShooter}]]*2]] + [[[[?{VitalStrike}/5]]d6]] + [[[[?{Maneuvour}]]d8]] + [[[[?{SneakAttack}]]d6]]]] }} {{Poison= [[[[?{Poison}]]d4]] poison damage.}} {{Fire= [[[[?{Fire}]]d4]] fire damage. }} {{Critical Damage=[[1d4]] extra for critical damage.}} {{Notes=If damage is poison, then DC10 save or be poisoned.}} So the key things to note, I use the emote box to generate a code, this is just me being lazy, but you can hide this output easily, but you don't have to.  To play with this, or to try and do your own, I will explain how I did this.  As normal, do a find replace and replace "xxx" (without the quotes) with your character's full name as per the name field of the character sheet. Prompts:  the prompts are all in the Emote section: {{emote=Code: ?{SharpShooter|Yes,5|No,0}?{VitalStrike|Yes,5|No,0}?{SharpShooter|Yes,5|No,0}?{VitalStrike|Yes,5|No,0}?{Maneuvour|Yes,1|No,0}?{SneakAttack|Yes,2|No,0}?{Fire|Yes,1|No,0}?{Poison|Yes,1|No,0}}} As you can see, most of the answers are either with a value of 5 or 1.  Quite simply all it does, is as you are asked a question, it uses that same value in the maths below.  So if for example it is one of the two feats, then this is how it is applied if the answer 'Yes' is selected for either of them.  Yes has a value of 5 in this case so here is how I apply it: [[ [[1d20]] + [[@{xxx|rangedtohit1}]] + [[@{xxx|global_ranged_attack_bonus}]] -?{SharpShooter} -?{VitalStrike} ]] adding the 5 to the formula above generates a -5 value for the attack, taking the overall bonus from +10 to +5. if BOTH are applied, the both end up being -5, and the total bonus to attack is 0. + [[[[?{SharpShooter}]]*2]] in the damage field.  since the value for Yes is 5, we substitute it in the formula and you get this: + [[5*2]] + [[[[?{VitalStrike}/5]]d6]] in the damage field. again with a value of 5 for Yes, substituted into the formula we get this: + [[[[5/5]]d6]] Since the order of operation means the inside division is handled first, the formula then gets updated to: + [[1d6]] Those other questions set a value of 1 for yes, and 0 again for no.  In these cases, they are represented as is: + [[[[?{Maneuvour}]]d8]]  + [[[[?{SneakAttack}]]d6]]]] [[[[?{Fire}]]d4]] [[[[?{Poison}]]d4]] I list fire and poison damage separately in case of DR or immunities etc. Hope someone finds this helpful. Bear.
1524472610
Ziechael
Forum Champion
Sheet Author
API Scripter
Nice tutorial, and easy to follow too... Thanks for taking the time to write it up, I can see a lot of users getting some good use out of this :)
You are welcome...