MZ Setting up a state that heals attackers

I'm definitely in well over my head for a first-time RPG Maker project, especially since it's been over a decade since I used Javascript, but here goes...

I would like to make a State that, when applied to an enemy, causes allies to heal when attacking that enemy. If you know the character Luocha from Honkai Star Rail, the concept is pretty similar - character uses skill, all allies regain HP when attacking based on that character's stats, and the effect ends after a few turns.

I've tried to explore a few ways of doing this, but from what I can tell the "simplest" would be to have a Common Event tied to all the skills the party has. My idea is that the Common Event would check if the target has this "Healing Sigil" State, and if they do, would heal the attacker based on the applying character's Attack (as an example). Problem is, for the life of me I can't figure out how to get it to heal whoever is currently attacking. And that's leaving alone all kinds of logic, like "did the attack hit?" and "What happens if a confused enemy attacks their ally?" Plus there's the tedium of adding the Common Event to every action the party can take, but that's definitely a lower priority problem...

My current (and failed) attempt is me trying to adapt the code from this tutorial on Leech Attacks, and looks like this:

Spoiler: Common Attempt
Screenshot 2025-06-06 210314.png

Knowing myself there's a non-zero chance it's all down to a stupid syntax error, but also I feel like I'm going insane so I figure there's no harm in asking. Any help would be appreciated, and if anyone can think of a better way to handle this I'm all ears!
Knowing myself there's a non-zero chance it's all down to a stupid syntax error, but also I feel like I'm going insane so I figure there's no harm in asking
does it crash, or does it just give the wrong console output? just a glance - youd want to be using actor($gamevariables.value(2)) in your conditional branch instead of 1, no? you have variable 1 the index of the enemy, not the id of the actor. then youd want to be checking if the enemy has the state, not the actor?

but also, if youve followed the guide and have the VS battle core installed, you can use one of their JS notetags to make the state heal the attacker of whoever has the state on.

I would like to make a State that, when applied to an enemy, causes allies to heal when attacking that enemy. If you know the character Luocha from Honkai Star Rail, the concept is pretty similar - character uses skill, all allies regain HP when attacking based on that character's stats, and the effect ends after a few turns.
Try putting this notetag into the notebox of the heal sigil state.

Code:
<JS Post-Damage As Target>
  if (this.isDamage() && value > 0) {
    user.gainHp(origin.atk);
    user.startDamagePopup();
  }
</JS Post-Damage As Target>
it should make it so that when a battler puts that state on a target and that target is attacked, the attacker will be healed by the atk of the battler that applied the state
I knew it was a stupid simple error, it was throwing the wrong console output - lesson learned, don't trust yourself to code when sick!

And your solution worked perfectly! I didn't know the VS Battle Core stored so much information, this will be perfect for other skill ideas going forward. Thank you very much, and consider this solved!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/setting-up-a-state-that-heals-attackers.178156/