I'm making an enemy skill called "Goblin Punch" that does maximum damage if the user's HP is equal to the target's. How do I do this though damage formulas? Thanks!
Goblin Punch skill?
RPG Maker MV SupportIt kind of depends on how you want the damage to scale. Are you wanting to use a specific formula and then scale the percentage of that value to the percentage of HP the target currently has?
Example: a.atk * 4 - b.def * 2 <-- then do 50% of this value if the target's HP is at 50% and 100% of the value if the target's HP is at 100%?
You could find the difference of the target's HP and MHP and then use that difference as a multiplier.
Example: (b.hp / b.mhp) * 100 <-- I believe this will give you the percentage of HP the target has, then use that as the multiplier, so:
((b.mhp / b.hp) * 100) * damage formula
This is the easiest way I can think to do it.
edit: sorry I reversed, it should be current hp divided by the max HP so I changed the formula to reflect that, oops.
edit 2: damn, it's been a long time since math class... if you want to leave it in decimal form, to get a percentage multiplier then DO NOT multiply by the 100 because that will give you a whole number.
50 current hp divided by 100 max hp will give you the result of .5, so take that .5 and multiply it by your damage formula to give you a value of 50% of your damage forumula.
So: (b.hp / b.mhp) * damage formula is what you want.
Example: a.atk * 4 - b.def * 2 <-- then do 50% of this value if the target's HP is at 50% and 100% of the value if the target's HP is at 100%?
You could find the difference of the target's HP and MHP and then use that difference as a multiplier.
Example: (b.hp / b.mhp) * 100 <-- I believe this will give you the percentage of HP the target has, then use that as the multiplier, so:
((b.mhp / b.hp) * 100) * damage formula
This is the easiest way I can think to do it.
edit: sorry I reversed, it should be current hp divided by the max HP so I changed the formula to reflect that, oops.
edit 2: damn, it's been a long time since math class... if you want to leave it in decimal form, to get a percentage multiplier then DO NOT multiply by the 100 because that will give you a whole number.
50 current hp divided by 100 max hp will give you the result of .5, so take that .5 and multiply it by your damage formula to give you a value of 50% of your damage forumula.
So: (b.hp / b.mhp) * damage formula is what you want.
Goblin Punch from Final Fantasy generally deals avarage damage, or a ton of damage of the user and target's levels are the same, so I'm going to guess you mean "does extra damage" rather than "does maximum damage" since "extra damage" is a lot less work. Since enemy levels don't exist innately in RM, I'll go with your use of user hp vs enemy hp instead:
Just change the two things in caps to match what you want, such as:
Code:
a.hp === b.hp ? STRONG_DAMAGE_FORMULA : WEAK_DAMAGE_FORMULA
Just change the two things in caps to match what you want, such as:
Code:
a.hp === b.hp ? a.atk * 12 - b.def * 2 : a.atk * 4 - b.def * 2
@Aesica Thanks for the help! I did a little bit of messing around with the formula to get it how I want and created this. Will this work?
Thanks again for the help!
Code:
a.hp === b.hp ? 9999 : (a.atk - b.def)
Yes. That will deal 9999 damage if the attacker and target's HP value are the same, and atk - def otherwise.
Original thread: https://forums.rpgmakerweb.com/threads/goblin-punch-skill.124638/