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

Is there a macro command that would show me how many sets of 5 over an AC an attack succeeded by?

I have instituted a form of the Momentum mechanic from Conan RPG into my 5e-based game by allowing players to acquire 1 point of Momentum for every 5 full points of attack roll that they achieve over the minimum necessary to hit a foe. So, if a foe's AC is 12, and the PC rolls a 17-21, they get 1 Momentum point in addition to their successful hit. If they roll a 22-26 on their attack roll, they get 2 Momentum points, etc. I am not finding a way to have a macro command that allows for comparisons between roll results and the requirements , only seeing commands for setting up what counts as a success or a failure on the dice itself . Does anyone know if there is a command line that I can use in my attack macros that would allow for that calculation (and resulting number of Momentum points to be awarded) to be done for me (and subsequently posted along with the results) instead of me having to remember to do it every time?  Thanks, in advance.
1599511628

Edited 1599511831
Ziechael
Forum Champion
Sheet Author
API Scripter
Something like: Bob gets [[ floor(([[1d20 + @{selected|various attack bonuses or whatever}]] - @{target|AC})/5) ]] Momentum Points! He rolled $[[0]] to hit as well... well done Bob! You can get fancier and have the results in a different order if you introduce a roll template: &{template:default} [[ floor(([[1d20 + @{selected|various attack bonuses or whatever}]] - @{target|AC})/5) ]] {{name=Attack}} {{attack=$[[0]]}} {{Momentum=$[[1]]}}
Thanks for the reply (and so quick as well!). I'm just a little confused here, I guess. What is the $[[0]] mechanic doing, exactly? (And likewise for the $[[1]] later on in your example). Thanks.
1599514422

Edited 1599514517
Ziechael
Forum Champion
Sheet Author
API Scripter
Since your desired calculation is part of a wider calculation we are exploiting the  Reusing Rolls  trick to get the attack roll AND the number of Momentum generated. In the first example we have to do it in reverse as you can't perform math on the inline roll calls ($[[0]] etc) but can call the nested inline roll of the attack itself. The second example exploits the behaviour of a roll template ignoring the actual roll since it is placed outside of the templates sections: &{template:default} [[ roll calculation ]] {{ foo }} {{ bar }} and by adding that second layer of inline nesting we are then able to call both the attack roll and the number of momentum in the desired order $[[0]] being the first inline roll made (from the deepest nesting upwards) and $[[1]] being the next inline roll. Hopefully that helps explain how we are bending the calculation to our will :)
Awesome! I did not know about the ability to reference the results of rolls like that. That pretty much is exactly what I was hoping for, then. Thanks for the help. Much appreciated!
1599521892

Edited 1599521909
David M.
Pro
API Scripter
One thing to note, because it will eventually come up in something you will try to do: Sadly, we are unable to do any math operations on the re-used rolls ( so no $[[0]] + 5 or anything). They will only display as text.
Yeah, I read the portion of the thread Ziechael referenced that said that. Thank you, though.
What Ziechael had posted was looking perfect, until I ran into a negative result in the Momentum calculation portion of the equation (e.g. an attack roll of 8 vs AC of 14 = -2 Momentum, but I would want that to say 0 Momentum instead, since no Momentum was gained). I'm sure it's something simple to fix, but I still have to figure it out, I guess.
1599526334
Oosh
Sheet Author
API Scripter
You just need a keep highest 1 operator to get rid of negative results: [[ { floor(([[1d20 + @{selected|various attack bonuses or whatever}]] - @{target|AC})/5) ,0}kh1 ]]
Oh, duh! LOL... I did say it was probably something simple, didn't I. Thanks, man.