Masochism passive state

Hey sweets! I want to create a "Masochism" passive. In my head it looks like: 'Regenerate 1,5% HP after recieving any damage'.
I know how to make passive states, just wondering how to make it regenerate hp after recieving damage, maybe someone know how to do it.
Or maybe ya have better idea for 'Masochism' passive effect? I would love to hear about it and get inspired a bit (If ya don't mind of course).
Need help anyway. Thanks for your time!
You'll need Yanfly's buffs and states plugin for this.

Paste this inside the passive state:


<Custom Respond Effect>

if (value > 0) {

var HpHeal = Math.floor(target.mhp * 0.015);
target.gainHp(HpHeal);
}

</Custom Respond Effect>

Should work, holler if it doesn't 😉
It seems to work well, heal is there but damage is not shown - there is no damage sound and numbers (it occurs however - hp just dissapear).
I don't mind reversing it tho' (damage=visible/heal=not visible).
Yeah... I'm not sure how to fix that. For Masochism to work like this it needs to be a respond effect because deselect would activate even if the action against the actor failed. I think you can choose not to show the pop up. Alternatively, you could turn it into a end of turn effect, some kind of regeneration that only activates if the target was dealt damage during that turn.
I think the damage popup thing is because by default only one action result is considered per frame. In this case, that's the healing effect. 😴

I'd suggest Yanfly's Battle Engine Core:
It handles multiple action results in a single frame automatically, no extra config needed~ 🙏

Alternatively you could bypass the damage popup/result thing entirely, e.g.
Code:
<Custom Respond Effect>
if (value > 0) {
  var heal = Math.floor(target.mhp * 0.015);
  target.setHp(target.hp + heal);
}
</Custom Respond Effect>
Haven't tested but I think that'll do it. 😮‍💨

Original thread: https://forums.rpgmakerweb.com/threads/masochism-passive-state.122677/