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

XGtE Toll of the Dead, auto-detect correct die

So the above mentioned spell in Xanathar's Guide to Everything will A) roll a d8 if the target is unharmed or a d10 if HP|current&lt;HP|max and B) level up the number of dice rolled at lvls 5 (2), 11 (3), &amp; 17 (4). I've found the if/then area of the Useful Macros page and I know the formula to increase die as level increases, but I'm hoping to give two of my players a formula where they can click the spell attack, click a target foe, and it determine whether the hp|current&lt;hp|max and roll the correct (and correct # of) die. I thought I was smart enough to figure it out, but it's prompting multiple times to select a target and the one time I did get it rolling die it rolled 2d12+1d8, so apparently I'm waaaay over my head here. I could really use some magic from the forum geniuses! What I thought &nbsp;I had pieced together correctly is as follows: <span data-sheets-value="{&quot;1&quot;:2,&quot;2&quot;:&quot;[[{{@{target|Target1|HP|current},@{target|Target1|HP|max}} [[{{@{target|Target1|HP|current},@{target|Target1|HP|max}}&lt;[[@{target|Target1|HP|max}+1]]}*([[round((@{level} + 1) / 6 + 0.5)]]d8-[[round((@{level} + 1) / 6 + 0.5)]]d12) + [[round((@{level} + 1) / 6 + 0.5)]]d12]] I thought it was going to [[{{TargetsCurrentHP,TargetsMaxHP}&lt;[[TargetsMaxHP+1]]}*(DiePerPlayersLevel d 8 - 12) + 12]] but apparently not? I appreciate anyone who can help! -Agnati
1586421443
GiGs
Pro
Sheet Author
API Scripter
If you're only selecting one target, you don't need the target1 part. So&nbsp; @{target|Target1|HP|max} is @{target|HP|max} Also for current hp you dont need the current part so&nbsp; @{target|Target1|HP|current} would be @{target|HP} You can use floor() instead of round() when rounding down to avoid need need for +0.5 in your calculation. I'm not following how your formula matches the description. According to your description you roll 1d at 1-4th level, 2d at 5th, 3d at 11th, 4 at 17th. And the dice roll are d10 or d8 if target is at less than full hit points (weird, but okay). But in your expression, you have the multiple applying to the number of dice, and die type is both d8 and d12 (not d10). I would separate number of dice and hit die type, and caclulate them separately: [[ floor((@level}+1)/6)d[[8 + 4 * floor(@{target|HP}/@{target|HP|max}) ]] ]] So we have the number of dice calculation on the left side of the d, and the die size calculation on the right. I'm not sure what the die size should be, so I'll explain this: floor(@{target|HP}/@{target|HP|max}) rounds down, so if HP = max, the total is 1, for anything else it's 0. So die type is either 8 +0, or 8+4 = 12. Change the +4 to +2 if this is supposed to give d10s.
No, GiGs, you're spot on. Sorry, it was around 3am when I was typing that up and was a little foggy in the head. The spell does more damage if the target is already damaged (I agree it's weird... and a little OP in my first-time-DM opinion). The examples you gave and your time are most appreciated! &nbsp;wonder, though, if I could trouble you once more and admit that I neglected to mention (or realize when I was doing the formula myself) that all my bad guy tokens have unique HP rolled when I deploy them, numbers assigned to bar1 for current/max hp, so they're all a little unique. I've tried subbing bar1/bar1|max as well as bar1_value/bar1_max, each time getting an error pointing to the fact that on the actual character sheet for the token, the bar1 fields are blank... but I'm looking for the values assigned to the token (bar1 is unlinked from any sheet attribute). Have I made a false assumption that this can actually be done with how I use tokens currently? Regards, Agnati
1586454041

Edited 1586454061
GiGs
Pro
Sheet Author
API Scripter
This can be done. Each bar has a name, bar1, bar2, bar3, and you can see which it is when you open up the token settings (they aren't numbered in a sensible order - the middle one on the tabletop is bar1). You can use @{target|bar1} for the current score and @{target|bar1|max} for the max.
Thanks for your reply. I'm glad it's not just me then! That's what I had thought and tried, but I get&nbsp; No attribute was found for @{TARGET:bar1|max} even though the token I'm testing on is set to Bar1: 30 / 32&nbsp; None That's why (just an assumption on my part) I think it's looking at those fields on the character sheet (OGL D&amp;D 5e) rather than what's on the token. The tokens *are* linked to the Thug sheet. For grins and giggles (and trial/error) I unlinked it to the Thug sheet and it gave me&nbsp; No attribute was found for targeted token by the name of max . Sooooo... different is good, I suppose? -Agnati
1586455686
GiGs
Pro
Sheet Author
API Scripter
Interesting, I've just tested these. And it seems target|bar1|max doesnt work if the token isn't &nbsp;linked to a character. It does work if the token is linked to a character. It should work in both cases (@{selected|bar1|max} does), so this seems to be a bug. Note in your first error message, it seems you had a typo. You have&nbsp; No attribute was found for @{TARGET:bar1|max} &nbsp;but it should be&nbsp; @{TARGET|bar1|max} &nbsp;(a pipe (|) not a colon after target). So make sure your tokens are connected to a character, with the bars unlinked and you should be fine.
How much of a difference would it make if they were tied to an NPC character sheet (like currently) vs a PC character sheet? (Though I did try it against another PC as well with the same first error message. Also, that colon is only in the error message. The formula is correct:&nbsp; [[ floor((@level}+1)/6)d[[8 + 4 * floor(@{target|bar1}/@{target|bar1|max}) ]] ]] For grins and giggles, I did try [[ floor((@level}+1)/6)d[[8 + 4 * floor(@{selected|bar1}/@{selected|bar1|max}) ]] ]] with the caster, a different PC, and an NPC selected and... well it didn't give me an error , which I suppose is good, but it also didn't do anything else that I've been able to see. No errors in the API log or chat log. In case it's relevant, I'm still being asked to choose a target twice... first "Choose Target: Target" and then immediately after "Choose Target: Bar1" &nbsp;
1586498445
GiGs
Pro
Sheet Author
API Scripter
This might be the cause of your issue @level} It should be @{level}
One heck of a step in the right direction! I still get two target prompts, but I at least get this as an output: No attribute was found for @{TARGET:bar1|max} (To GM): DC 14 No damage Wisdom &nbsp; Save 0 necrotic 60 feet Toll The Dead Kerrera
1586499945
GiGs
Pro
Sheet Author
API Scripter
Looks like this was my mistake! Remember earlier who i said you dont need to use the middle parameter of target, when there is only a single target? Thats not true if you are using the |max part. Also, looks like the bit before the d isnt being treated as a number properly, so you need to coerce it into one, This is the corrected expression [[floor(1+(@{level}+1)/6)]]d[[8 + 4 * floor(@{target|target1|bar1}/@{target|target1|bar1|max}) ]]&nbsp; This will give text something like 2d8 or 2d12 If you need it to act like a roll, wrap another set of inline brackets around it, like so [[ [[floor(1+(@{level}+1)/6)]]d[[8 + 4 * floor(@{target|target1|bar1}/@{target|target1|bar1|max}) ]]&nbsp;]] I dont use the sheet you're using, so I dont know which version you need. Try both if the first one doesnt work :)
You're a genius, GiGs! That works 99% how it's supposed to!.... I reeeaaaly don't mean to seem picky...&nbsp; It's supposed to roll a d8 if they're at max HP and a d12 if they've been injured but it's rolling the&nbsp; opposite. I almost feel bad about bringing it up with all the miraculous help you've been so far! lol
1586502223
GiGs
Pro
Sheet Author
API Scripter
That's easy to fix :) Change this part d[[8 + 4 * to d[[12 - 4 *
Argh, I lost my edit to my last post. Yeah, it took me a couple minutes to figure out how the math worked, but I got that. Thank you, GiGs, you've been a miricle worker and this is going to save my players and myself a lot if time and headache! I hope you have a great and safe weekend and I hope this thread saves anyone else the time and effort of having to cook this up! Mad props!! GiGs provided: Toll of the Dead rolls 1d at 1-4th level, 2d at 5th, 3d at 11th, 4d at 17th. And the dice roll are d12 if the target is injured or d8 if target is at full hit points. [[ [[floor(1+(@{level}+1)/6)]]d[[12 - 4 * floor(@{target|target1|bar1}/@{target|target1|bar1|max}) ]]&nbsp;]]
1586502984
GiGs
Pro
Sheet Author
API Scripter
I'm glad we got there in the end, lol. And thank you :)