Trying to make a state to have two origins.

Hello!

I'll explain what I am trying to do.
I'm basically trying to recreate Beacon of Light from World of Warcraft.
With the help of a friend I have made a skill (beacon) that adds a state onto the target and onto self.
The state that the user is having on has an on establish effect which every heal the user makes the target with the other state gets too.
So for example, we have 3 members, A is casting Beacon on B. A is affected with stateID5 and B is affected with stateID6.
A heals C and B gets half of that heal's value.

Up to that point everything works BUT if two members have learned beacon and they both cast it on the same target only the last member to cast beacon will heal the target and the other will not.

So my question is how can I stack the effects so two members can have beacon on the same target?
What you could do is tie B onto A as the beacon skill is being casted.
Try this. On the Beacon skill, use the notetag:

Code:
<Post-Damage Eval>
user._beacon = target;
</Post Damage Eval>

Now, in the beacon state that affects the user (actor A), use the notetag:

Code:
<Custom Establish Effect>
if (this.isHpDamage() && value < 0) {
  var healRatio = 0.5;
  var heal = Math.floor(healRatio * -value);
  if (user._beacon && user._beacon.isAlive() && target != user._beacon)
    user._beacon.gainHp(heal);
}
</Custom Establish Effect>

<Custom Remove Effect>
user._beacon = undefined;
</Custom Remove Effect>

Note that if actor A casts beacon on two targets, only the last target will be considered the beacon. This will allow multiple actors to have the same beacon though.
I'm also assuming you do not want the beacon to receive the bonus healing if the beacon is the one being healed.
You technically don't need a state for B, but you could have one so that the player knows who the beacon is.
It works, thanks!
Btw do you know a way to make a state control the mana cost of certain skill types?
The only way I can think of is to make a state and if the user has that state then on the skill notetags make the mp cost check if the user has that state and then modify it. But what I'm looking for is a state that does that for a skill type.
That way I don't need to add the same code to each skill individually.
You can't do that with lunatic code alone as the engine doesn't check for skill type when determining mp cost. You will need to add it to each skill individually or overwrite the base code to factor in skill type when determining mp cost.
I see, well at least there's a way to do it.
Thank you so much for your help!

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-a-state-to-have-two-origins.93075/