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

Help with Rage Abilities and Macros (5e D&D)

1646300668

Edited 1646477990
Hi everyone. Thanks so much in advance for checking this question out, and double thanks if you end up helping me out! I've been getting pretty solid with macros over the past year in my 5e D&D game, but this one is stumping me. We're not using any Roll20 character sheets or APIs, but instead are using custom attributes to allow for customized Token Actions while running our character sheets off Beyond. (Most of us do not like the integration through Chrome, by the way, so that's off the table). I want to write a token action that rolls my barbarian's damage, and queries for critical hits, versatile weapons, and whether I'm raging or not. I have the following character sheet ability "%Longsword-Damage": /em deals [[?{Critical?|No,1|Yes,2}d?{One or Two Hands?|Two,10|One,8}+@{ModStr}[Str]+?{Raging?|No,&#8203|Yes,@{RageBonus}[Rage Bonus]}]] slashing damage! What I'd like to do is have @{RageBonus} automatically update with my Barbarian level, allowing me to have one manually-set variable cover a number of automatically-adjusting values (such as Divine Fury and any ability which references character level as well), rather than me having to manually set multiple related values. To that end I've written the following for @{RageBonus}, where @{LvlBarbarian} is manually set. This macro works, so we'll start from there. [[{2,floor(@{LvlBarbarian}**0.5)}kh1]] where "@{LvlBarbarian}" is manually set. If I manually call this version of @{RageBonus} it prints the correct value, for every level 1 through 20, so I know it works by itself . The problem is, when I use this version of @{RageBonus}, it breaks %Longsword-Damage. If the "Raging?" query is set to "no" it spits out incorrect variables and some junk ripped from after the attribute call, and if it's set to "Yes" the macro breaks entirely and doesn't resolve. Is there a way to "trick" the roller into resolving this the way I intend—maybe I'm missing some HTML replacements?—or is the Order of Operations or something else I'm unaware of completely buggering what I'm trying to accomplish? For the record I did try a version with the text from @{RageBonus} in the original macro: /em deals [[?{Critical?|No,1|Yes,2}d?{One or Two Hands?|Two,10|One,8}+@{ModStr}[Str]+?{Raging?|No,&#8203|Yes,[[{2,floor(@{LvlBarbarian}**0.5)}kh1]][Rage Bonus]}]] slashing damage! with and without the double brackets around the implanted text, to no success. This is what prompted me to look at the Order of Operations, and decide that I needed help to either fix it, or tell me it can't be done.
/em deals [[?{Critical?|No,1|Yes,2}d?{One or Two Hands?|Two,10|One,8}+4[Str]+?{Raging?|No,&#8203|Yes,[[{2,floor(5/2)}kh1]][Rage Bonus]}]] slashing damage!
I didn't have the custom sheet so I took out the attributes for base numbers.  
Just reinsert your custom attributes and it will work, you never replace the brackets in attributes anyway.  
1646477188

Edited 1646477235
It looks like your code is no different than mine, other than you substituting the attribute calls for an arbitrary number and doing... something  with the math code. When I try out your code it works, but as soon as I replace the arbitrary numbers/math code with the custom attributes everything breaks again. Here is where it breaks: For the "Raging?" query, if "No" is selected, this is what prints: None of the text between the dice box and "slashing damage" should be there, but the math functions. Here's what's inside the dice box: When "yes" is selected instead the macro doesn't resolve, and nothing is printed inside the chat window. Those extra characters have caused me to think I'm missing some HTML replacement somewhere. I have, while writing this post, replaced the second right-brace in @{RageBonus} such that it reads [[{2,floor(@{LvlBarbarian}**0.5)}kh1]] which prevents the junk text from printing, but selecting "Yes" on the query still results in the macro not resolving. I have done the following one at a time to see if I can make any additional progress, to no avail: placing double-brackets around the attribute call thinking it might separate it and force it to resolve doing the above while removing the double-brackets from the attribute itself removing the double-brackets from both the attribute call and the attribute code itself Removing the damage type tag Replaced the zero-width space in the ability code with a "0" Reversed the order of answers within the query Reversed the order of terms within the comparison function in the attribute code Done all manner of HTML replacements within the attribute code and the ability code, with no further measurable success. I am currently tinkering with new math code for the attribute. I've tested it with simpler code that still involves an attribute call and math, so perhaps the issue is in the floor function or the exponent (well, square root, but yes). This is particularly vexing because I have similar macros with similar levels of attribute calls, one of which is branching and is six layers deep, and those all seem to be functioning perfectly. I can post the text for this functional macro if anyone needs it for comparison's sake.