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 .
×

Multiply everything in Attribute Call by a number taken from a Roll Query before the Attribute Call is calculated

1656827573

Edited 1656827818
So I've been working on a macro (5e) to calculate total damage my character does each turn. I play a fighter, and at my current level I can attack up to 6 times a round (with Action Surge). My DM is also looking to modify my macro for multiple people So how its supposed to work is: I roll a bunch of attack rolls, my DM tells me how many times I hit. I then click on the macro, it asks me for the number of hits, then the number of critical hits, and it'll calculate the damage. Currently my macro looks like this: &{template:simple} {{rname=@{weapon_name}}} {{mod=damage}} {{r1=[[ (?{Number of Hits|0}*@{weapon_dice_num})@{weapon_dice} + ?{Number of Hits}*[[@{weapon_stat}[MOD] + @{weapon_magic}[Magic]]] + [[?{Number of Hits|0}*(@{global_damage_mod_roll})]] + [[?{Number of Crits|0}*@{weapon_dice_num}]]@{weapon_dice} + ]]}} {{normal=1}} {{r2=0}} {{charname=? {Number of Hits}x hit : ?{Number of Crits}x crit. }} Using the following attributes to make updating the macro easier: weapon_dice_num: The number of dice I roll for each weapon hit. DM has given basically everyone weapons dealing more than one dice of damage. weapon_dice: The actual dice size (d8, d10, d12). The other attributes aren't important for my question but I'll put what they do here for reference: global_damage_mod_roll is from the sheet and it applies checked global damage modifiers like +10 damage from Great Weapon Mastery. weapon_stat is an user created attribute with a value like @{strength_mod}, this makes it easier for this macro to be used by other characters. For each character, I just create this attribute and drop in the appropriate stat mod: @{dexterity}, etc. weapon_magic is the magic bonus for my current weapon. Is there anyway to simplify this specific line, given a weapon that deals 2d6 damage (weapon_dice_num = 2. weapon_dice = d6): (?{Number of Hits|0}*@{weapon_dice_num})@{weapon_dice} With two hit this becomes (2*2)d6 , which is accurate. But what I really want is to have a single attribute with both the number of dice, and the dice . So something like a weapon_damage attribute = 2d6. I've tried: (?{Number of Hits|0}*@{weapon_damage} But this ends up with 2*2d6, which rolls the 2d6 and multiplies the result by 2. What I want is it to multiply 2*2 and roll 4d6 instead. Preferably while keeping the dice roll visible when I scroll over the roll. Essentially I want expansion to happen first if possible, so in a more general scenario (with a weapon that does an extra 1d8 + 5 on hit): 2*(2d6 + 1d8 + 5) would become 4d6 + 2d8 + 10 before being calculated.
You're experiencing the Roll20 Order of Operations . I haven't found any way to circumvent the order that Attributes are processed before Roll Queries. I haven't read through your entire post to see if there's a more elegant way of doing this, but my best guess is that what you can do is create 6 ability macros on your character sheet, one for each number of hits, and have an initial query that then inputs the corresponding ability macro. The other option would be to put the query inside the damage field itself, which could then in theory be calculated before the result of the damage roll. But I haven't tested that out to make sure it works.
1656833898

Edited 1656835228
GiGs
Pro
Sheet Author
API Scripter
Stann said: With two hit this becomes (2*2)d6 , which is accurate. But what I really want is to have a single attribute with both the number of dice, and the dice . So something like a weapon_damage attribute = 2d6. I've tried: (?{Number of Hits|0}*@{weapon_damage} But this ends up with 2*2d6, which rolls the 2d6 and multiplies the result by 2. What I want is it to multiply 2*2 and roll 4d6 instead. As Jarren says, you can't do this if the @{ global_damage_mod_roll } attribute contains a complete damage roll, like 2d6. There's a hacky way to do it. If the attribute was 2)d6 , or 1)d8 , etc - and have the open bracket earlier in the macro. This would mean the damage attribute dowsnt work independently. But you macro could then be: [[ ( ?{Number of Hits|0}*@{global_damage_mod_roll}]] + Adding the open bracket there, which is then completed inside global_damage_mod_roll. But of course, this doesn't work if the damage roll is something like d8+1, it only works for dice rolls without a modifier. You could use this: [[ ( ?{Number of Hits|0}*@{global_damage_mod_roll}* ?{Number of Hits|0} ]] + Which would work if global_damage_mod_roll included +0 fordice rolls without a bonus. So you 2d6 attack would become 2)d6+0. It wound work for multiple dice rolls, like d8+d6+5 though. As I said, it's a hacky solution, and one with drawbacks, but if you adjust every macro that uses @{ global_damage_mod_roll} it'll work. By the way, I wouldn't call this an order of operations problem. It doesnt matter what order things were called - the problem is the damage roll is entirely contained in the global_damage_mod_roll attribute, and there's no way to break that apart into its component parts (number of dice, die size, and possible modifier) without the Pro-level API. Jarren suggests putting the query inside the damage roll, and I think that's a clever solution. I don't see why that wouldn't work. It means you wouldn't be able to use global_damage_mod_roll without dealing with a query, but that might be okay. That said you critical damage line does appear to include the number of dice and die size separately. [[?{Number of Crits|0}*@{weapon_dice_num}]]@{weapon_dice} + If you do that with normal damage hits, there's your solution. (Though it doesnt solve the issue of rolling multiple dice of different sizes.) Honestly, the only solution that handles every situation is Jarren's suggestion of having 6 macros, one for each number of hits, but that means you'd need those 6 macros for each different weapon. Roll20's dice rolls are often very clunky! If your GM has a Pro subscription, he could install the ScriptCards script,and then you could build a macro that handles it a lot easier.
Thanks for the suggestions. I don't have access to scripts, so I'll probably stick to the hacky 2)d6 method.