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

[Request] Blood Mage Health Resource tracker script using percentiles

Hello everyone o/ I have a homebrew ability for one of my players that is essentially like Blood Mage, in that it uses a temporary health pool that can be used to cast certain spells via sacrificing a percentage of their current/max health or by a flat value (whichever is higher). For example: <spell> Sacrifices 10% of current hit points or 10 hit points. Now I've looked into the different kinds of dice rolling you can do, and I had an equation that would take the health value and calculate the percentage (say 25%, rounded up) and compare it to the flat number, then return which was the higher of the two. However, this would mean that the equation would have to be updated whenever the health would change, so that would be too much work for the player or myself as the DM to do on the side. Alternatively, I looked into automatic resource management/ammo counters that would do the subtraction but they only go down by flat increments of 1. I would try to write my own script for it, but I, unfortunately, don't know how to code :( Might anyone be able to help me?
1483944237

Edited 1483944445
Silvyre
Forum Champion
[[ {ceil(@{Cakelette|HP|max} * 0.10), 10}kh1 ]] This returns the higher value between 10% of an HP Attribute's Max value (rounded up) and 10. Documentation: ceil() and {}kh1 You can pair this with a script like ChatSetAttr to make it easier to apply these changes. e.g. /em sacrifices [[ {ceil(@{Cakelette|HP|max} * 0.10), 10}kh1 ]] HP and has [[ @{Cakelette|HP} - {ceil(@{Cakelette|HP|max} * 0.10), 10}kh1 ]] HP remaining. !modattr --charid @{Cakelette|character_id} --HP|-[[ {ceil(@{Cakelette|HP|max} * 0.10), 10}kh1 ]]
Thank you so much! It worked like a charm <3
1484015449
Silvyre
Forum Champion
Glad to hear it!