Been working on my game for a while, and playing others to get inspiration. I'm wanting to create a damaging item, like a bomb, that deals damage based on a percentage of the enemies max hp. But I'd like to create a formula that takes into consideration what type of enemies I'm using the item on, so for example maybe the bomb will do about 25% of a normal enemies health, but on a boss, it'd deal significantly less like about 5-10% to prevent cheese. How would I go about the damage formula for this?
Percentage based damage
RPG Maker MV SupportHello!
You can check this thread, it contains a lot of info for Damage Formulas.
Basically, with a variable named boss, add 1 to that variable in the event page of the boss's troop page, and set it to turn 0.
Then, in your formula, you can do this
if (v[ID of the "boss" variable] > 0) { b.mhp * 0.05(for 5% damage, or 0.1 for 10% } else { b.mhp * 0.25 }
Then in another page, set the condition to when your boss's hp is less than 1% and set the "Boss" variable to 0 to avoid always having it set to 5% damage.
You can check this thread, it contains a lot of info for Damage Formulas.
Basically, with a variable named boss, add 1 to that variable in the event page of the boss's troop page, and set it to turn 0.
Then, in your formula, you can do this
if (v[ID of the "boss" variable] > 0) { b.mhp * 0.05(for 5% damage, or 0.1 for 10% } else { b.mhp * 0.25 }
Then in another page, set the condition to when your boss's hp is less than 1% and set the "Boss" variable to 0 to avoid always having it set to 5% damage.
I believe another working syntax for this would be...
Replace x with the variable ID you want to use.
What I normally do is just add a function to
Then you can simply just use
if ($gameVariables.value(x) === 1) ? b.mhp * 0.05 : b.mhp * 0.25;Replace x with the variable ID you want to use.
What I normally do is just add a function to
Game_Battler and call it another way.Game_Battler.prototype.percentageDamage = function(a, b) { if ($gameVariables.value(X) === 1) { // Replace X with Variable ID damageValue = b.mhp * 0.05; } else { damageValue = b.mhp * 0.25; }; return damageValue;};Then you can simply just use
a.percentageDamage(a, b) in the Damage Formula box and it would run the function above.This thread is being closed due to being reported as solved. If you need it reopened, let us know. Thank you!
Original thread: https://forums.rpgmakerweb.com/threads/percentage-based-damage.168219/