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

Lost with what should hopefully be a simple macro

Hey folks! I was looking to start messing with macros for a few custom abilities and the more I look around trying to find a solution for this, the more information I'm getting and the more confused I'm becoming. I've got a more manual version working, but if someone can help automate it just a touch more I would appreciate it.  So the ability is an augmented Divine Smite. Basically I have an item that grants me an extra 1d8 for every 40HP I'm missing, not to exceed double the dice of the base smite for that level. So if I used a 2nd level divine smite with 10/260HP, it would be 3d8 (normal smite) + 3d8 (250 missing HP would grant 6 extra dice, but caps out at double the base) + 1 optional 1d8 for undead. Currently, I'm doing most of this manually, which as far as I know, all I can automate would be the health bonus to save a tiny bit of brain power or math hiccups. Please note I have very  little experience with this. I know I need to incorporate a ceiling value in there, but not entirely sure if I can have the spell slot level feed this info with the single manual input? This is what I'm working with for the manual version. /roll 2d8+?{Injury Bonus?|1|2|3|4|5}d8 +?{Spell Level Above 1st?|1|2|3|}d8 +?{Undead Bonus?|0|1|}d8 Any help would be appreciated! Thanks!
1674544920

Edited 1674544993
Which character sheet are you using? The attribute references are going to be dependent on that. But assuming the 'D&D 5E by Roll20' sheet, it would look something like this: !?{Spell Level?|1,0|2,1|3,2|4,3|5,4} ?{Undead Bonus?|No,0|Yes,1} /roll [[ {[[2 + ?{Spell Level?} + floor((@{selected|hp|max}-@{selected|hp})/40)]] + 0d0, [[{[[[[?{Spell Level?}+1]]*2]] + 0d0, 2 + 0d0}kh1]] + 0d0}kl1 + ?{Undead Bonus?}]]d8 If you want an inline roll it could look like this: !?{Spell Level?|1,0|2,1|3,2|4,3|5,4} ?{Undead Bonus?|No,0|Yes,1} Spell Level [[?{Spell Level?}+1]]: [[[[ {[[2 + ?{Spell Level?} + floor((@{selected|hp|max}-@{selected|hp})/40)]] + 0d0, [[{[[[[?{Spell Level?}+1]]*2]] + 0d0, 2 + 0d0}kh1]] + 0d0}kl1 + ?{Undead Bonus?}]]d8]] Those require you to select the token that the attribute is referring to. You could 'hard code' it to your character by replacing both of the 'selected' references with your character name. E.g.:    @{selected|hp|max}  would become   @{John Doe|hp|max}  It's very possible that the dice formula I came up with could be done much simpler!  And it's also possible that I've made a mistake with my math... but I tested it out a bit and it seems to be producing the correct rolls from what I can tell.
Using the D&D 5e sheets. I think I got it hammered out after a bit. Seems to be working in my testing. /roll 2d8+?{Spell Level Above 1st?|0|1|2|3|}d8 +?{Undead Bonus?|0|1|}d8 + {[[floor(@{Selected|Smiter})]]d8, 2d8+?{Spell Level Above 1st?|0|1|2|3|}d8}kl1 Where Smiter is a custom attribute that reads: ((@{Selected|HP|Current}-@{Selected|HP|Max})/-40) I'll also give yours a shot in a second here to see which I like better! Thanks!
Alrighty. Borrowed from your examples and I think I've got it streamlined and fully functional. Worked through multiple tests, and I taught myself what the heck was happening with it. Thanks again for the help! So finished result is: !?{Smite Level?|1,0|2,1|3,2|4,3|5,3} ?{Undead Bonus?|No,0|Yes,1} Smite Level [[?{Smite Level?}+1]]: [[[[{2+?{Smite Level?}} +?{Undead Bonus?} + {{floor((@{CharacterName|HP|Current}-@{CharacterName|HP|Max})/-40)}, {2+?{Smite Level?}}}kl1}]]d8]]
Great! A couple things: 1. Is the Undead bonus supposed to be included in the 'Twice Smite Level' cap?  The way you have it coded it is, but from your description above it made it seem like it should add an additional 1d8 regardless of the cap. 2. Good catch on a 5th level smite being capped at an additional 3d8 (max 5d8 for smite), however being coded the way you have means that the 'Smite Level: #' output will be wrong for a level 5 Smite (it will display 'Smite Level: 4'), and the Double Smite Level cap will also be wrong for level 5. You're using  {2+?{Smite Level?}}}kl1} for your comparison, which would cap your maximum smite roll to be 5.
In my testing, the Undead bonus is not being included in the doubling when I roll it. A max power smite against non-undead does 10d8, where against undead it is doing the correct 11d8.  So just to lay out my understanding (which is highly likely flawed, but is getting me intended results), casting a level 3 smite with 240 missing health against an undead would calculate as follows: (2+2)[Base] + 1[Undead] + (6 > 2+2 therefore 4)[Missing Health]=9d8 If it was at full health against a non-undead, it instead calcs as: (2+2) + 0 + (0 < 2+2, therefore 0)=4d8 As for the level displaying wrong, yeah. Didn't notice that. I might just change the dropdown to 4 or 5 and whisper the result to myself. Not sure how I would approach fixing that to display correctly and I don't think that's worth the headache. Changed it to  !?{Smite Level?|1,0|2,1|3,2|4 or 5,3} and it calculates correctly, though does still display level 4, which makes sense. The damage cap for a level 5 smite should still be an extra 5d8, same as a level 4 smite.
I think what would help me (or anyone else who wants to take a stab at a dice macro) make sure that we're getting the correct results would be to verify this is correct:        Smite Level         Amount of Damage         1d8 per 40 damage         Undead Bonus         +1d8 if 'Yes'         Max d8s         (2x Smite Level)          Total d8s 1 - 2d8 0 - 0d8 No - 0d8 1*2=2d8 2d8 1 - 2d8 0 - 0d8 Yes - 1d8 1*2=2d8 2d8 (not 3d8) 1 - 2d8 40 - 1d8 No - 0d8 1*2=2d8 2d8 (not 3d8) 1 - 2d8 40 - 1d8 Yes - 1d8 1*2=2d8 2d8 (not 4d8) 2 - 3d8 0 - 0d8 No - 0d8 2*2=4d8 3d8 2 - 3d8 0 - 0d8 Yes - 1d8 2*2=4d8 4d8 2 - 3d8 40 - 1d8 No - 0d8 2*2=4d8 4d8 2 - 3d8 40 - 1d8 Yes - 1d8 2*2=4d8 4d8 (not 5d8) 3 - 4d8 0 - 0d8 No - 0d8 3*2=6d8 4d8 3 - 4d8 0 - 0d8 Yes - 1d8 3*2=6d8 5d8 3 - 4d8 40 - 1d8 No - 0d8 3*2=6d8 5d8 3 - 4d8 40 - 1d8 Yes - 1d8 3*2=6d8 6d8 3 - 4d8 80 - 2d8 No - 0d8 3*2=6d8 6d8 3 - 4d8 80 - 2d8 Yes - 1d8 3*2=6d8 6d8 (not 7d8) 4 - 5d8 0 - 0d8 No - 0d8 4*2=8d8 5d8 4 - 5d8 0 - 0d8 Yes - 1d8 4*2=8d8 6d8 4 - 5d8 40 - 1d8 No - 0d8 4*2=8d8 6d8 4 - 5d8 40 - 1d8 Yes - 1d8 4*2=8d8 7d8 4 - 5d8 80 - 2d8 No - 0d8 4*2=8d8 7d8 4 - 5d8 80 - 2d8 Yes - 1d8 4*2=8d8 8d8 4 - 5d8 120 - 3d8 No - 0d8 4*2=8d8 8d8 4 - 5d8 120 - 3d8 Yes - 1d8 4*2=8d8 8d8 (not 9d8) 5 - 5d8 0 - 0d8 No - 0d8 5*2=10d8 5d8 5 - 5d8 0 - 0d8 Yes - 1d8 5*2=10d8 6d8 5 - 5d8 40 - 1d8 No - 0d8 5*2=10d8 6d8 5 - 5d8 40 - 1d8 Yes - 1d8 5*2=10d8 7d8 5 - 5d8 80 - 2d8 No - 0d8 5*2=10d8 7d8 5 - 5d8 80 - 2d8 Yes - 1d8 5*2=10d8 8d8 5 - 5d8 120 - 3d8 No - 0d8 5*2=10d8 8d8 5 - 5d8 120 - 3d8 Yes - 1d8 5*2=10d8 9d8 5 - 5d8 160 - 4d8 No - 0d8 5*2=10d8 9d8 5 - 5d8 160 - 4d8 Yes - 1d8 5*2=10d8 10d8 5 - 5d8 200 - 5d8 No - 0d8 5*2=10d8 10d8 5 - 5d8 200 - 5d8 Yes - 1d8 5*2=10d8 10d8 (not 11d8)
1674598927

Edited 1674599046
Rell
Pro
I think I'm seeing some of the confusion there.  1- The undead bonus is wholly separate from this feature. It is a tack-on calculated separate from  everything else, including the max dice rule. So regardless of any missing health or smite level, using it against undead will always provide a singular bonus 1d8.  2- For the double the base damage, it's up to doubling the dice not the level , so at 1st level since the base is 2d8, a maximum of 2d8 may be provided from missing health (80HP) even if more is missing. 4th and 5th level smite both have a base of 5d8, and can therefore have the same maximum bonus of 5d8 from missing health. Mathematically they'll stay identical just like the base smite. (Skipping Levels 2 and 4 for readability) Smite Level - Base Damage Missing HP -  Bonus Damage Max HP Bonus Dice Total Roll (vs. Not Undead) Total Roll (vs. Undead) +1d8 1 - 2d8 0 - 0d8 2d8 2d8 3d8 1 - 2d8 40 - 1d8 2d8 3d8 4d8 1 - 2d8 80 - 2d8 2d8 4d8 5d8 1 - 2d8 120+ - 3d8+ 2d8 4d8 (not 5d8+) 5d8 3 - 4d8 0 - 0d8 4d8 4d8 5d8 3 - 4d8 40 - 1d8 4d8 5d8 6d8 3 - 4d8 80 - 2d8 4d8 6d8 7d8 3 - 4d8 120 - 3d8 4d8 7d8 8d8 3 - 4d8 160 - 4d8 4d8 8d8 9d8 3 - 4d8 200+ - 5d8+ 4d8 8d8 (not 9d8+) 9d8 5 - 5d8 0 - 0d8 5d8 5d8 6d8 5 - 5d8 40 - 1d8 5d8 6d8 7d8 5 - 5d8 80 - 2d8 5d8 7d8 8d8 5 - 5d8 120 - 3d8 5d8 8d8 9d8 5 - 5d8 160 - 4d8 5d8 9d8 10d8 5 - 5d8 200 - 5d8 5d8 10d8 11d8 5 - 5d8 240+ - 6d8+ 5d8 10d8 (not 11d8+) 11d8
Alright I'm 99% sure this formula is correct: !?{Smite Level?|1|2|3|4|5} ?{Undead Bonus?|No,0|Yes,1} [[ [[ [[{[[2 + [[{[[?{Smite Level?}-1]],3}kl1]] + [[floor((@{selected|hp|max}-@{selected|hp})/40)]] ]],[[ [[{[[?{Smite Level?}+1]],5}kl1]]*2]]}kl1 ]] + ?{Undead Bonus?} ]]d8]] And here's a little bonus code to make it easier to see what your modifiers are with the hoverable inline label tooltip: !?{Smite Level?|1|2|3|4|5} ?{Undead Bonus?|No,0|Yes,1} [[ [[ [[{[[2 + [[{[[?{Smite Level?}-1]],3}kl1]] + [[floor((@{selected|hp|max}-@{selected|hp})/40)]] ]],[[ [[{[[?{Smite Level?}+1]],5}kl1]]*2]]}kl1 ]] + ?{Undead Bonus?} ]]d8[%NEWLINE%Smite Level: ?{Smite Level?}%NEWLINE%Undead Bonus: ?{Undead Bonus?}%NEWLINE%HP Bonus: @{selected|HP|Current}/@{selected|HP|Max}]%NEWLINE%]] Unfortunately there's no way to include a calculated roll inside the roll label, so I don't think you'll be able to directly put the HP Bonus into the tooltip, but you can show the current/max hp.
That works like a charm. Thanks for the help, Jarren!