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

Colossus slayer as global dmg affect -- division syntax

1593738202

Edited 1593738334
I'm really struggling with this, and there are roughly one billion replies,but none of them seem to do the obvious. Colossus slayer (5E) is not a selectable thing, it's a global that is in affect anytime a target has less than max hitpoints.&nbsp; And yes I'm using the roll20 5E sheet.&nbsp; So I want to set this as a global damage modifier.&nbsp;&nbsp; I should be able to get either a 0 or 1 *&nbsp; 1d8 from the following [[ floor((@{target|foe|hp})/(@{target|foe|hp|max}))*1d8 ]] but instead I get SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but ")" found. I can get the number value from the target|foe|hp and the max.&nbsp;&nbsp; floor(hp/max) will be either 1 or 0 (unless the guy has an insane amount of temp hp, but I'll address that later).&nbsp;&nbsp; The thing killing me here is the syntax! I also tried adapting the approach here to getting a conditional: <a href="https://wiki.roll20.net/Useful_Macros#Conditional_Statements_.28Math_Only.29" rel="nofollow">https://wiki.roll20.net/Useful_Macros#Conditional_Statements_.28Math_Only.29</a> [[{{x,false-value-compared-to-A}&gt;A}*(F-T) + T]] is the example where if x (hp) is less than A (hp max) return a number.&nbsp; My version is [[{{(@{target|foe|hp}),0}&gt;(@{target|foe|hp|max})}]] which should at least return a 0 or 1.&nbsp; Same syntax error. I've been doing computer programming for 40 years, this shouldn't be that hard.&nbsp;&nbsp; And I'm really surprised there isn't already a standard answer to this -- heck, it should be draggable from the compendium!
I've tried escaping also -- [[{{(@{target|foe|hp})&amp;#44;0&amp;#125;&gt;(@{target|foe|hp|max})#125;*1d8]] still syntax error.&nbsp; URG!
1593751848

Edited 1593752158
Oosh
Sheet Author
API Scripter
Okay, so unless you're using homebrew: Colossus Slayer. Your tenacity can wear down the most potent foes. When you hit a creature with a weapon Attack , the creature takes an extra 1d8 damage if it’s below its hit point maximum. You can deal this extra damage only once per turn. Emphasis mine. This isn't really suitable (IMO) for a global effect since it can only be used once per turn. You'd be ticking it on and off constantly. I've only ever seen it activated manually (after extra attack at level 5, that is). If you're using a custom version that automatically hits all the time, that's obviously more suitable. Also below level 5 with only the one attack I guess it's effectively always on. As for the math, dividing the current HP by max HP will give you the opposite of what you want. This should do the trick though, -1 from the floor value to turn 0 to -1 and 1 to 0, then use abs to remove the negative: /r [[abs(floor(@{target|foe|hp}/@{target|foe|hp|max})-1)]]d8 But you still have another problem. Not all tokens will have HP on a character sheet. As mook tokens (generally) don't have their HP bar linked to the character sheet, they may not have any current HP at all, which will make the macro fail. If the sheet does have HP it is almost certainly on full anyway, so you will never deal damage. You can try using @{target|foe|bar1} and @{target|foe|bar1|max} instead, depending on how your DM has it set up. They may not be thrilled about you pulling token bar values either, unless they play with open HP and stats.
Oosh, appreciate the attempt, but I tried your macro and still get a syntax error (though a slightly different one): SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "/" found. That said, your point about it only being applicable once per turn makes a lot of sense; I'm actually the DM trying to set this up for a Ranger player, but yeah, the party is all lvl 3-4 at this point so within a few sessions the "every attack" approach I'd been trying for really won't work!
1593827521
Oosh
Sheet Author
API Scripter
That's odd. What happens if you just do a @{target|foe|hp} ? Do you get a number? It sounds like one of the calls is not getting an integer. I get exactly the same error on NPC tokens with no current HP set in their character sheet, but the code works on PC characters with current &amp; max HP properly set. One other option to consider for Colossus is to add it as either a clickable link on the damage roll of their weapons, or as a Query in either global mod where you were going to put it, or just in the normal weapon damage. It really depends on what the player prefers, and what output you prefer as GM since you have to deal with the damage to the NPCs. The damage link version is just a simple Ability macro saved on their character sheet called ColossusSlayer: &amp;{template:simple} {{rname=Colossus Slayer}} {{mod=1d8}} {{normal=1}} {{r1=[[1d8]]}} And then in their Attacks &amp; Spellcasting section you change the Damage Type field for their main weapon(s) to: [Piercing](~ColossusSlayer) Now when they roll damage with that weapon, the damage type is a clickable link to roll Colossus damage. This is generally my preferred options for things like Smite &amp; Colossus etc. as it reduces Query popups for regular attacks. The disadvantage is that the damage needs to be added manually by the DM, and the player has to remember to use it. You could also build a Query into the regular weapon damage in the Attacks &amp; Spellcasting sections. Just change Damage field for the weapon to: 1d6 + ?{Colossus?|Yes,1d8|No,0}[Colossus] By default, the crit field will reroll everything in the Damage section. If you do choose to add anything in here, manually put the 1d6 in the crit field so you don't get the Colossus rerolling. There's a couple of options, anyway. If the player doesn't mind the Query popup, that's probably a good option for you since you get the damage totaled for you, one less thing to do!
1593899207

Edited 1593899219
Oosh, thanks much -- I ended up going with setting this a Global Damage Modifier with the type "Colossus Slayer" [[?{Target Injured (once per turn)?|Yes,1d8|No,0}]] That popup is worth it I think for that player, and keeps a clear reminder in the chat of the necessary conditions for it to apply. I suspect your theory about a NaN return from hp|max is likely the syntax issue.
1593907747
Oosh
Sheet Author
API Scripter
You can always try @{target|foe|bar1}/@{target|foe|bar1|max} (or bar2 or bar3 depending on your setup) if you still want to try the math approach.