MZ Drain Health DoT

So there was an effect I made in MV. When the DoT damage goes off, the caster is healed for the same amount of damage, like a drain effect. This was using Yanfly's plugins, and I'm using VisuStella's now.

Code:
<Reapply Reset Turns>

<Custom Apply Effect>
// Make sure the stack count exists.
target._vampireDrain = target._vampireDrain || 0;
// Increase the stack count.
target._vampireDrain += 1;
</Custom Apply Effect>

<Custom Remove Effect>
// Reset the stack count.
target._vampireDrain = 0;
</Custom Remove Effect>

<Custom Regenerate Effect>
// Check if the original caster isn't the target and that the original target is alive.
if (origin !== target && origin.isAlive()) {
  // Determine the damage dealt.
  var damage = origin.mat;
  // Round up the damage.
  damage = Math.ceil(damage);
  // Original caster gains HP.
  origin.gainHp(damage);
  // Show the HP gained.
  origin.startDamagePopup();
  // Clears the original caster's HP popup.
  origin.clearResult();
  // Damage the target's HP.
  target.gainHp(-damage);
  // Check if the target is dead.
  if (target.isDead()) {
  // If the target is dead, make it collapse.
    target.performCollapse();
  }
}
</Custom Regenerate Effect>

This is how the code looks in MV. Though there's a few problems in MZ I'm not sure how to get around.

For starters, the DoT formula now has to go in HP Slip Damage. So most of my DoT formulas look like this:

Code:
<JS HP Slip Damage>
damage = user.mat * ((100 - (target.mdf/2))/100) * ((1 + user.getDealtElementPlus(6)) * user.getDealtElementRate(6) + user.getDealtElementFlat(6)) * target.elementRate(6)
</JS HP Slip Damage>

The issue is that if I try to put the healing here, the code always breaks. Calling the Pre-Regenerate phase only seems to affect the target, so I can't use that either, and the Life Steal notetags are all for skills or items.

In short, I'm stuck. Is there anything I can do?
I just realized this would go in Plugin Support, my bad
I just realized this would go in Plugin Support, my bad
no worries

In short, I'm stuck. Is there anything I can do?
you dont actually have to use the slip dmg notetag. you could keep the code you already have and use the visustella equivalents for the yanfly notetags.
<Custom Regenerate effect> would be <JS Pre-Regenerate>, <Custom Remove Effect> would be <JS On Erase State>, and <Custom Apply Effect> would be <JS On Add State>. you might have to play around with the target/user references, but the content of the code should be fine

Edit:
copy-pasted your notetags, changed the names, and it works as expected. no need to change any references
1749598737290.png
no worries


you dont actually have to use the slip dmg notetag. you could keep the code you already have and use the visustella equivalents for the yanfly notetags.
<Custom Regenerate effect> would be <JS Pre-Regenerate>, <Custom Remove Effect> would be <JS On Erase State>, and <Custom Apply Effect> would be <JS On Add State>. you might have to play around with the target/user references, but the content of the code should be fine

Edit:
copy-pasted your notetags, changed the names, and it works as expected. no need to change any references
View attachment 342619
You know, considering how I thought of using Pre-Regenerate before, I don't know why changing the other two didn't register to me.

Thanks for the help

Original thread: https://forums.rpgmakerweb.com/threads/drain-health-dot.178247/