MZ damage based on how low hp is

hi, I'm here again.

I want to make a skill damage based on how low hp actor, more damage dealt based on how low current actor hp is.


I tried this but it doesn't work a.hp < 0.7 ? 10; a.hp < 0.5 ? 13; 5;

can someone help?
it didn't work because a.hp is an absolute number. a.hp< 0.7 can only work if the skill user has zero HP remaining, because even a single HP is more than 0.7 HP.

what you want is the rate between current HP and max HP.
or in other words

if a.hp/a.mhp < 0.7 then
So, you want to do more damage the lower the HP?
How about this?
Code:
a.atk * ( 1 + ( 100 - ( b.hp / b.mhp * 100 ) / 100 ) )

This does attackers ATK damage when target is at full health, and for each % of HP it is missing, is does 1% extra damage.

When the target is at 100 % HP, the skill does normal damage.
When it is at 90% HP, it does 10% extra damage.
when it is at 50% HP, it does 50% extra damage.

You can replace a.atk with any value you want to use as base damage.
it didn't work because a.hp is an absolute number. a.hp< 0.7 can only work if the skill user has zero HP remaining, because even a single HP is more than 0.7 HP.

what you want is the rate between current HP and max HP.
or in other words

if a.hp/a.mhp < 0.7 then
it work, but I don't know how to apply for two or more condition, I wrote this :

b.hp/b.mhp < 0.7 ? 5 : b.hp/b.mhp < 0.3 ? 10 : 3
So, you want to do more damage the lower the HP?
How about this?
Code:
a.atk * ( 1 + ( 100 - ( b.hp / b.mhp * 100 ) / 100 ) )

This does attackers ATK damage when target is at full health, and for each % of HP it is missing, is does 1% extra damage.

When the target is at 100 % HP, the skill does normal damage.
When it is at 90% HP, it does 10% extra damage.
when it is at 50% HP, it does 50% extra damage.

You can replace a.atk with any value you want to use as base damage.
Awesome! that's what I'm looking for.


You can replace a.atk with any value you want to use as base damage.
how about based on TP? just changed a.atk to a.tp?
Phew... You can try, but to be honest, I don't know if a.tp is indeed a valid option.
You can just try it out, if that it results in 0 damage, then a.tp is not working, if it results in any actual value, then it is.
Phew... You can try, but to be honest, I don't know if a.tp is indeed a valid option.
You can just try it out, if that it results in 0 damage, then a.tp is not working, if it results in any actual value, then it is.
I just tested it, work with a.tp

I need a help. I'm currently using Visustella Battle core, and changed the damage style to Moba and it use float values. This means 250% is typed out as 2.50

I tested your code without change anyting and it does a million damage, so If you don't mind I need explanation about your code :
a.atk * ( 1 + ( 100 - ( b.hp / b.mhp * 100 ) / 100 ) )

for example I want the damage multiplier is just 200%, how to apply it?

Thank you in advance.
It does a million damage? 😮 Then I might have made a mistake.

a.atk is the total ATK value of the user of the skill. (So, their ATK + the ATK of their equipment)

( b.hp / b.mhp * 100 ) is the % of the remaning HP of the target.

100 - ( b.hp / b.mhp * 100 ) is the % of target that is lost.

When we do that / 100 and then +1, we get the multiplier. (If the HP lost is 10% the multiplier would be 1.1)

So, lets set up the formula in the same order as I just explained it.

Code:
( ( ( 100 - ( b.hp / b.mhp * 100 ) ) / 100 ) +1 ) * a.atk

This should give the same result, though...

How high is the users ATK value?

Edit: I did re-calculate the new formula 5 times and this one should work. If not, then I'd love to see the ATK of the user, and the HP and MHP of the target.
It does a million damage? 😮 Then I might have made a mistake.

a.atk is the total ATK value of the user of the skill. (So, their ATK + the ATK of their equipment)

( b.hp / b.mhp * 100 ) is the % of the remaning HP of the target.

100 - ( b.hp / b.mhp * 100 ) is the % of target that is lost.

When we do that / 100 and then +1, we get the multiplier. (If the HP lost is 10% the multiplier would be 1.1)

So, lets set up the formula in the same order as I just explained it.

Code:
( ( ( 100 - ( b.hp / b.mhp * 100 ) ) / 100 ) +1 ) * a.atk

This should give the same result, though...

How high is the users ATK value?

Edit: I did re-calculate the new formula 5 times and this one should work. If not, then I'd love to see the ATK of the user, and the HP and MHP of the target.
I think your code is working propely!

I test it with enemy def 25, and max hp 110
user atk is 22. And it deals ~400 damage wich is over damage.

sorry I'm dumb at math -_-


EDIT: I changed a.atk to damage value and it works

Code:
this : ( ( ( 100 - ( b.hp / b.mhp * 100 ) ) / 100 ) +1 ) * a.atk

to this : ( ( ( 100 - ( b.hp / b.mhp * 100 ) ) / 100 ) +1 ) * 10

your code is Awesome! Thankyou for your time and effort. Much appreciated
I think your code is working propely!

I test it with enemy def 25, and max hp 110
user atk is 22. And it deals ~400 damage wich is over damage.

sorry I'm dumb at math -_-


EDIT: I changed a.atk to damage value and it works

Code:
this : ( ( ( 100 - ( b.hp / b.mhp * 100 ) ) / 100 ) +1 ) * a.atk

to this : ( ( ( 100 - ( b.hp / b.mhp * 100 ) ) / 100 ) +1 ) * 10

your code is Awesome! Thankyou for your time and effort. Much appreciated
That is good, but this way, no matter how much ATK the user has, the damage will always be the same. (Well, depending on how much ATK they got)

22 ATK should still not deal 400 damage though...It would be 22 a minimum and 44 at the absolute max Which is already impossible, unless the target has less than 1% HP. 😛

But glad you like it the way it is. 🙂 No problem, I like this kind of thing.

Original thread: https://forums.rpgmakerweb.com/threads/damage-based-on-how-low-hp-is.144979/