MV Yanfly Overkill Bonus Damage formula help

Hi All,

I would like the overkill bonus to show up when you drop an enemy 50% of their max hp below zero. Currently it just does 50% of their max hp and thats it. So I was wondering if anyone knew how to adjust the damage formula on this to make it include the current hp the enemy has left. For example if the enemies max hp is 100 and has 20 hp left the player would have to do 70 points of damage to cause an overkill.

I believe I could store a variable at the begining of every skill or in every troop turn, and call that, but I feel like it would be way simpler if I could write a function or call for the targets hp before damage is calculated directly in the js.

Any help would be greatly appreciated.
Without knowing how the formula can be set up... is it possible to have the overkill set as

Damage Needed = ((Enemy MaxHP / 2) + Enemy Current HP)

reasoning:
Damage Needed = (50% as requested) + (HP needed to reach 0)

Looked at the plugin and suggesting this to see if it meets the needs.
Code:
(enemy.mhp/2)+enemy.hp
Unfortunately, I can't do anything that direct in the overkill bonus formula because it checks for the overkill after the damage is calculated. So if I used that, "Enemy Current HP" would always return as zero.

So what I need is a way to store that data before damage is calculated and call it back afterwards. Like I said, I could have the game do this at the beginning of a skill with Yanflies action sequences. But i'd have to do that for every skill, while not impossible, I feel like there would be a better solution through directly editing the js. I just don't know how to write a function that would find and store the current hp before damage is calculated.
So what I need is a way to store that data before damage is calculated and call it back afterwards. Like I said, I could have the game do this at the beginning of a skill with Yanflies action sequences. But i'd have to do that for every skill, while not impossible, I feel like there would be a better solution through directly editing the js. I just don't know how to write a function that would find and store the current hp before damage is calculated.
Simple, create a passive state with the <Custom React Effect> tag containing this:
<Custom React Effect>
target._oldHP = target.hp;
</Custom React Effect>

And then reference that in your overkill thing. Make sure all units have this passive state on at all times. This state will save a unit's HP value right before damage calculations. You can then use that for w/e purposes you wish.
I did a bit of testing and I also just noticed that the Overkill bonus value is set at the start of battle, not changing when a target takes damage... I had the plugin send data to the console with every hit and was testing with a target with 150 HP, so overkill if able to be killed in 1 hit should have been 225. That part was working right, but I was hitting for ~75-80 damage a hit but the console value was only returning that 225 over and over.

So yeah, this might be a bit more complicated to setup than I initially thought o.o
Unfortunately, I can't do anything that direct in the overkill bonus formula because it checks for the overkill after the damage is calculated. So if I used that, "Enemy Current HP" would always return as zero.
Have you actually tried it? That shouldn't be true. The overkill requirement is checked as a part of executeHpDamage, which in turn goes through gainHp and setHp, none of which limit HP to 0.

So as far as I can see just from glancing at the code, without testing in the game, if an attack takes an enemy to negative HP that value should be reflected.

I did a bit of testing and I also just noticed that the Overkill bonus value is set at the start of battle, not changing when a target takes damage

That's easy to change - open the plugin in a text editor and comment out with /* */ lines 320-322.

Then you should be able to use the method Frostorm gave to check a variable.
The method that froststorm gave seemed to work perfectly for me. After setting up the passive state and setting it up as a global state on all enemies, I just had to do "(0.5 * enemy.mhp) + target._oldHP" in the overkill formula and it worked as I had hoped.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-overkill-bonus-damage-formula-help.149317/