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

How to include Global Damage Modifiers in a Macro?

Hi everyone!


I am using the standard character sheet for 5e.


My character has 3 attacks, and 4 different independently-toggled global damage modifiers, based on type of ammunition, if sharpshooter, etc. I would like a macro that can total up the damage for all attacks that hit.


I am currently using "?{HITS}d8+(?{HITS}*5)" for just the bow attack, where {HITS} is number of attacks that hit, and 5 is my Dex mod. I want to know if there is a way to use a field that adds damage from a Global Damage Modifier, but only if it is toggled on in the sheet. Is there a way to do this?


Thanks so much!

August 30 (4 years ago)

As far as I'm aware, the API for the sheet only adds in the output(s) for global damage modifiers when they are turned on. Without your own API there's no way to copy that into a custom macro unless you were to query an on/off for each modifier on your sheet, which would be rather cumbersome and not at all the time/effort saver you're looking for.

August 30 (4 years ago)

Edited August 30 (4 years ago)
Oosh
Sheet Author
API Scripter

The Attribute you want is @{bob|global_damage_mod_roll}, replacing bob with your character name. An example damage macro for bob:

@{bob|wtype}&{template:dmg} {{rname=Club}} 0 {{range=}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4 + @{bob|strength_mod} + @{bob|global_damage_mod_roll}]]}} {{dmg1type=Bludgeoning}} 0 {{dmg2=[[0]]}} {{dmg2type=}} 0 {{desc=}}  {{spelllevel=}} {{innate=}}

This is just the damage macro for a Club ripped straight from the sheet, with the global damage property removed from its own field and added into the main damage roll, so it all gets added together.

Is this what you meant?


edit - @{bob|global_damage_mod_crit} is the Attribute for a crit

Oosh, that field is exactly what I was looking for! But now I have another issue: I need the macro to roll that field for as many times as attacks that hit, or in other words, "?{HITS}" number of times. Doing something like "(?{HITS}*(@{bob | global_damage_mod_roll}))" just multiplies the initial roll by the number of hits, it doesn't actually roll the field more times. Is there a way to make that happen


August 31 (4 years ago)

Edited August 31 (4 years ago)
Oosh
Sheet Author
API Scripter

There are no loops in Roll20 macros, so you can't do this easily. You could save your attack as an Ability macro, then call it three times with

%{bob|BowAttack}
%{bob|BowAttack}
%{bob|BowAttack}


There's also a way to build a multi-attack macro in this post which doesn't rely on Query nesting.


Another option is to put a repeat attack button at the bottom of your macro. This would need to go on your sheet as an Ability macro as BowAtk, and would link to the custom damage macros:

@{Bob|wtype}&{template:atk} {{mod=Bow +6}} {{rname=[Damage](~BowDmg)/[Attack](~BowAtk)}} {{rnamec=[Damage](~BowDmgCrit)/[Attack](~BowAtk)}} {{r1=[[@{Bob|d20}cs>20 + @{dexterity_mod}[DEX] + @{pb}[PROF]]]}} @{Bob|rtype}cs>20 + @{dexterity_mod}[DEX] + @{pb}[PROF]]]}} {{range=}} {{desc=}} {{spelllevel=}} {{innate=}} {{globalattack=@{Bob|global_attack_mod}}} ammo= @{Bob|charname_output}


That gives you a Damage button for a damage roll, and an Attack button to fire another arrow (the button just runs this macro again).


Anyway, there's a few options, it really depends what works for you. If you need to switch globals in between arrows, the last option is your best bet.

Thanks Oosh. I actually found a way using pseudo-boolean logic to toggle whether or not another attack damage is rolled. Here is what I did:

"?{HITS}d8+(?{HITS}*@{Bob|dexterity_mod}) + (@{Bob|global_damage_mod_roll}) + ((@{Bob|global_damage_mod_roll})*(((?{HITS}) - 2) / 1))"


This is a very convoluted method but I will try my best to explain. The first section just adds up the base bow attack damage. Simple! The second section is more messy. First, I figured if I ever only hit 1 attack, I would just roll damage the normal way, and I wouldn't use the macro. Second, the global damage modifier is already added at the top of the template whenever you roll damage for an attack. This means that if I need to roll damage for 2 attacks, I only need to add 1 more set of rolls for the Global Mods. And if I need to roll for 3 attacks, I only need to add 2 more sets. The way that "(((?{HITS}) - 2) / 1)" works is that if I input 2 for {HITS}, it will equal 0, which will make that entire second set of rolls also equal 0, which means it will only roll 1 additional set. If I input 3 for {HITS}, it will equal 1, which will then add the second set of rolls as well as the first.


I hope that was coherent at all lol, and thanks so much for your help!!

August 31 (4 years ago)
Oosh
Sheet Author
API Scripter

Nice!

Yeah, sorry, for some reason I thought you were talking about multi-attack for the attack and for the damage. The way you've done it, using a Query input value for number of successful attacks, is probably the cleanest way to do it since you can reuse the Query as many times as you like.

Trying to squeeze attack rolls, advantage, crit and damage all into one automated multiattack macro is where it gets wobbly!

Hey, sorry one last problem. "@{bob|global_damage_mod_crit}" isn't working for me, for some reason. It correctly rolls the crit damage, but only for one of the 4 fields, regardless of how many are turned on. It's strange since "@{bob|global_damage_mod_roll}" works perfectly and adds all of the modifiers. Any ideas on what could be causing this?

August 31 (4 years ago)
Oosh
Sheet Author
API Scripter

Yeah, I think it's actually a current bug in the sheet - the global crit fields are not working correctly. Hopefully it's fixed in the tomorrow's sheet updates.


Well, that's slightly frustrating. Where can I find the sheet updates?


August 31 (4 years ago)
Oosh
Sheet Author
API Scripter

Over in this thread, there's been a few changes recently to the global section. Note that this is just discussion of the character sheet, you don't need to do anything to receive the actual updates - they are not optional and they are applied server-side.