Gain MP from dealing damage

What the title says. I'm making a mechanic that applies to a specific armor where if the actor with the armor deals more than a quarter of an enemy's HP, it gives the actor 10% of their maximum MP.
I tried Yanfly's Convert Damage script but it just refuses to work. I tried all the solutions I could but it doesn't do anything.
I need this to work on a specific armor.
I think you could do this in the damage formula of the attack skill, but you'd probably need a script that would allow you to input longer formulas (like this one from Hime). You would assign a variable to the damage in the normal formula window, and then add in the notes a condition that if the user has the armor equipped and the damage (the variable) is bigger than enemy maxHP/4, 10% of user's MP will be added to them. So, something like the following (X is the variable ID, Y is the ID of the armor that needs to be equipped):

in damage window, for example: v[X]=a.atk * 5 - b.def * 2

in note window (if you use Hime's script):
<formula effect>
if (a.equips.include?($data_armors[Y])) && (v[X] > b.mhp/4)
a.mp+=a.mmp*0.1
end
</formula effect>

I THINK this is how it would work. I used brackets in the condition, not sure if they're necessary. Try to test it :LZSwink: I don't know what level scripter you are, so ask if something needs explaining (not that I'm of a particularly high level :LZSlol:).
in terms of object-oriented coding I suggest to create these classes ( armor -> magic armor ). Where "armor" is responsible for all regular armor props and functions. Then go ahead and create a specific method on magic armor. Let's call it "convertEnemyHealthToHeroMana". Arguments will be dealt dmg and enemy's hp. Then every time actor deals dmg, u have to check if mana should be replenished. If so, just add that 10% amount to actor's mana.

I know, that's not a complete tutorial for your case, but maybe u can use some general thoughts and apply them in the way u want.
I think you could do this in the damage formula of the attack skill, but you'd probably need a script that would allow you to input longer formulas (like this one from Hime). You would assign a variable to the damage in the normal formula window, and then add in the notes a condition that if the user has the armor equipped and the damage (the variable) is bigger than enemy maxHP/4, 10% of user's MP will be added to them. So, something like the following (X is the variable ID, Y is the ID of the armor that needs to be equipped):

in damage window, for example: v[X]=a.atk * 5 - b.def * 2

in note window (if you use Hime's script):
<formula effect>
if (a.equips.include?($data_armors[Y])) && (v[X] > b.mhp/4)
a.mp+=a.mmp*0.1
end
</formula effect>

I THINK this is how it would work. I used brackets in the condition, not sure if they're necessary. Try to test it :LZSwink: I don't know what level scripter you are, so ask if something needs explaining (not that I'm of a particularly high level :LZSlol:).
It needs to work on all forms of damage.
It needs to work on all forms of damage.
Well, you can copy it to all the skills that the actor/class would use, or is that a problem?

Original thread: https://forums.rpgmakerweb.com/threads/gain-mp-from-dealing-damage.178419/