MV Skill to boost HP of other enemies when one dies

So I am making a boss fight as I mentioned in another post. Thanks for the plugin suggestions for that! I decided to use the yanfly HP gauges to have HP gauges on all 3 bosses because although Jeremy's version works, it does not work with the yanfly battle cameras. Interesting Mog's boss HP bars, although it only shows one bar at a time, it actually shows the bar of the enemy just hit if you have more than one.

Anyway...
So what I want is that when one of the bosses dies the other bosses HP will double. However, when I use a skill to scope all allies with grow HP and some HP recovery, it targets the enemy that just died too! Obviously, I don't want them to come back alive. There is a command for targeted only dead allies but not only alive how annoying. Guess I'll have to manually make sure the dead enemies don't get revived
You'll want to put a turn 0 troop event that sets the Immortal state on each of the enemies in your troop.

Then, make another troop event (make sure the span is set to Moment) with a condition of Enemy HP 0 or below. Put the following into a Script window:
Code:
for (var i=0; i<$gameTroop.aliveMembers().length; i++)
{
    if ($gameTroop.aliveMembers()[i].hp>0)
        $gameTroop.aliveMembers()[i].gainHp($gameTroop.aliveMembers()[i].hp);
    else
        $gameTroop.aliveMembers()[i].removeState(ImmortalID);
}
where ImmortalID is the ID of your immortal state (default is 3).

Original thread: https://forums.rpgmakerweb.com/threads/skill-to-boost-hp-of-other-enemies-when-one-dies.136678/