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

Adding DMG based on lost HP%

March 10 (3 weeks ago)

Edited March 10 (3 weeks ago)

Hi, I'm new to the Roll20 system and I'm trying to arrange an extra line in my weapon attacks (which I've housed as Abilities in the system) to give my character the following feat: 

BERSERKING 1
Gain 1d6 physical DMG to melee hits for each 25% of character's Max HP (13= 3.25) they are currently missing. 


I'm having trouble figuring out how to get the percentage read- I've been browsing other examples of macro codes but nothing has clicked yet. Here is an example of another code I way trying to play with: [[ floor(@{selected|Hit Points|max} * [[1d6+25]]/100) ]], but I don't understand *how* to get my 25% value. What I think I want is an if/then read, where "If -25% health, then add 1d6 dmg".

I have no character sheet (homebrew game), but my character's hp is listed as an Attribute.

March 10 (3 weeks ago)

Edited March 10 (3 weeks ago)
Gauss
Forum Champion

1-X/Y will give % lost. 

Example: 1-50/75 = 1-0.6666 = 0.33333
Which we know is 1/3 lost from 75. 

So now we need to turn that into a check. 

[[{1-X/Y,0}>0.25]]d6

Where X = current health
and Y = maximum health. 
Not knowing the name of the attribute for your health, please replace X and Y with the appropriate attribute(s). (It might be @{hit points} as in your example but I'd rather have you fill it in.)

Edit: did some testing and it doesn't like fractions (0.25) so I fixed it by multiplying both sides by 100: 
[[{(1-X/Y)*100,0}>25]]d6

Edit2: I just noticed that this is for each multiple of 25%. Here is the solution for that: 
[[{(1-X/Y)*100,(1-X/Y)*100-25,(1-X/Y)*100-50}>25]]d6

Again noting that you need to replace "X" and "Y" with their appropriate attribute(s). 

Gauss said:

1-X/Y will give % lost. 
...

You can take that % lost and divide by 25% to get the number of increments of 25% lost. Simplflying the bonus d6's to

+[[ floor((1-HP/MAX)/0.25) ]]d6

Or assuming "Hit Points" as accurate

+[[ floor((1-@{selected|Hit Points}/@{selected|Hit Points|max})/0.25) ]]d6
March 10 (3 weeks ago)
Gauss
Forum Champion

I thought you might come along with a shorter version. :)