MZ Change enemy target if actor has a state (Visustella)

I was wondering how would I change an enemy's target if an actor has a state.
For example Actor 1 puts a state on themself (Shield) and another state in Actor 2 (The actor they will be taking damage for)
Bump
You might get responses if your request was described more clearly.

I don't know from reading it how this is supposed to work - if actor 2 has the state, what determines actor 1 as taking the damage instead of anyone else in the party?

Why is it called Shield if it's doing the opposite and tossing damage onto other people?

Why would anyone confuse it with a taunt?
You might get responses if your request was described more clearly.

I don't know from reading it how this is supposed to work - if actor 2 has the state, what determines actor 1 as taking the damage instead of anyone else in the party?

Why is it called Shield if it's doing the opposite and tossing damage onto other people?

Why would anyone confuse it with a taunt?
Sorry, about not describing it very well. Actor 1 puts a state on themself (Shield) and a state on actor 2. (The actor they will be taking damage for)
You may be able to find substitution plugins that do this more automatically. But just with VisuStella...

The VisuStella documentation isn't clear whether the origin variable is present outside of the Skills and States notetags.

So I'd want to do this with one notetag, but to be sure, we'll do this.
The shielded state would have:
Code:
<JS On Add State>
target.shielding = origin;
</JS On Add State>

<JS On Erase State>
delete target.shielding;
</JS On Erase State>

<JS Pre-Damage as Target>
if (!target.shielding.isDead())
{
    target.shielding.gainHp(-value);
    target.shielding.startDamagePopup();
    if (target.shielding.hp <= 0)
        target.shielding.performCollapse();
    value = 0;
}
</JS Pre-Damage as Target>
You may be able to find substitution plugins that do this more automatically. But just with VisuStella...

The VisuStella documentation isn't clear whether the origin variable is present outside of the Skills and States notetags.

So I'd want to do this with one notetag, but to be sure, we'll do this.
The shielded state would have:
Code:
<JS On Add State>
target.shielding = origin;
</JS On Add State>

<JS On Erase State>
delete target.shielding;
</JS On Erase State>

<JS Pre-Damage as Target>
if (!target.shielding.isDead())
{
    target.shielding.gainHp(-value);
    target.shielding.startDamagePopup();
    if (target.shielding.hp <= 0)
        target.shielding.performCollapse();
    value = 0;
}
</JS Pre-Damage as Target>
I put the notetag in the state and works like a charm.

Original thread: https://forums.rpgmakerweb.com/threads/change-enemy-target-if-actor-has-a-state-visustella.171031/