
Is there a way to conditionally call a macro?
I want to only add sneak attack damage for certain attacks.
I understand I will need a prompt that tells me to call the sneak attack macro, assuming this can work.
Is there a way to conditionally call a macro?
I want to only add sneak attack damage for certain attacks.
I understand I will need a prompt that tells me to call the sneak attack macro, assuming this can work.
The macro language does not support conditional statements. You best bet would probably be to add a chat button somewhere in the template of your attack macro(s). KeithCurtis does a good job explaining these here.
Optionally, if your character sheet supports it (like 5e by Roll20 does), you could always add it as a secondary damage instance/type, and just ignore it when it does not apply.
Another option is to put a button into the description field of the attacks you want to have the sneak attack option. Create an ability on your abilities tab that rolls Sneak Attack damage. Name it ex., "Sneak-Attack". Then in the description field of the chosen attacks add the line:
[Sneak Attack](~Sneak-Attack)
You'll get something like this, a button you can push whenever you want to add sneak attack damage (the separate box below).
Can I do this if I use macros, but I don't use character sheets? I'm asking because I can't get it to work. Is there is a Youtube video? It's about a 5/10 on the importance scale so if not then I'll just add the sneak attack damage, and just have the GM ignore it.
I'd have to see the macro to give advice on the best placement, but almost certainly. Putting that button code in will cause the button to appear in chat regardless. You can even put it in all by itself. But remember, for that particular button to do anything, you must use an ability (macro written on the abilities tab of a character journal) named "Sneak-Attack".
I'm just seeing your reply. This is the code for one of my weapons.
Sap <---I have this in the macro code area so the GM know which weaoon I'm using.
Attack
[[1d20+11]]
Damage
[[1d4+1]]
[Sneak Attack](~Sneak-Attack)
The ability is named "Sneak-Attack"<--copied and pasted
The code I use to roll the sneak attack damage for the ability is
[[2d6]]
-----
When I press the button inside of the "Sap" macro I get "TypeError: Cannot read property 'substring' of undefined"
It fails because the ~ is looking to run an ability from a character sheet. If you aren't using one, you might be best off with a simple query driven conditional:
Sap
Attack
[[1d20+11]]
Damage
[[1d4+1]] ?{Sneak Attack|No, |Yes,+ [[2d6]] Sneak}
or
Sap
Attack
[[1d20+11]]
Damage
[[1d4+1 + ?{Sneak Attack|No,0|Yes,2d6[Sneak]} ]]
or
Sap
Attack
[[1d20+11]]
Damage
[[ [[1d4+1]] + ?{Sneak Attack|No,[[0]]|Yes,[[2d6]][Sneak]} ]] total ($[[0]] Base and $[[1]] Sneak)
Just an example I got help with in an AD&D2 game, posted in hopes that it might prove helpful to other neophytes like me. It's not a conditional macro code, not quite, but it does enough of that work for me at the moment. It's one macro that calls another.
A lot of the special combat tricks from the Complete Fighter's Handbook are based on called shots with the standard -4 penalty, which can just be inserted manually into an attack roll. Some have an additional -4, like Sap (p. 72), the chance to knock out a foe with a precise blow. Because you're not using the weapon's business end in the way the gods intended, magical bonuses do not apply.
My elven swashbuckler is specialized in the rapier and main-gauche as well as the two-weapon style, so having recently picked up a long sword +1, flame tongue, he's now using that along with his rapier. He's not specialized in it, but does get the +1 species bonus with it. My usual attack macro has me picking out which pluses to use against particular opponents, which go up to +4 versus undead, but that's irrelevant here.
This macro I call Sap offers me a choice of three weapons to use in an attack, rolls a d20, then tells me what AC I managed to hit and the damage done. Sap can only be used against man-sized critter and smaller, so L damage doesn't need to be accounted for.
/me attempts to knock out his opponent!
Using his ?{which--|Rapier, rapier Tragedie's hilt as a club he swings hitting AC [[ @{thac0}-1d20-1 [STR] -1 [spec] +8 [Ludicrous Called Shot] ]] and inflicting [[ 1d6+1 [weap] +1 [STR] +2 [spec] ]] damage…..|Flame, Flame Tongue Wildfire he strikes with its hilt hitting AC [[@{thac0}-1d20-1 [STR] -1 [elf] +8 [Ludicrous Called Shot] ]] and inflicting [[1d8+1 [STR] ]] damage..... |Main-gauche, trusty main-gauche Kindness he surprises his opponent with the pommel hitting AC [[@{thac0}-1d20-1 [STR] -1 [spec] +8 [Ludicrous Called Shot] ]] and inflicting [[1d4+1 [STR] +2 [spec] ]] damage...}
/w Lameth [Knock out](~Lameth O'Clurichaun|Knock-Out)
&{template:2Edefault} {{name=Knock Out}}{{subtitle=attempt}}{{Knock Out Chance=[[?{Damage done|0}*10 ]] }}{{ My Roll=[[1d100cs<[[?{Damage done|0}*10]] ]] }} {{Temp Dmg=[[ceil(?{Damage done|0}*.75) ]]}}