MV YEP_Buffs&States_Leech Seed_JavaScript Support

This community request for support is part 2 of my "Metroid-like" enemy post.

Link below:

Issue:
Now that my enemy has a killable weakness solved in my last post, I need to fix its LEECH skill. Currently, LEECH skill places the actor being fed on and the feeding enemy in the STUN state, and with each turn, it steals HP from the actor utilizing Yanfly's LEECH SEED, which created LEECHED (state 126). The enemy must be FROZEN (state 35) or KILLED to remove LEECHING (state 125; it just ensures the enemy cannot move) from the enemy, which should also remove LEECHED (state 126) from the player. I believe the issue lies in LINE 5 of FREEZE.

Desired End State:
Currently, if I FREEZE the enemy, it only removes the LEECHING skill from the enemy and not LEECHED state from the player.

Community assistance is appreciated!

JavaScript codes for LEECHED and FREEZE are below:
LEECHED:
JavaScript:
<Custom Remove Effect>
   origin.removeState(125);
</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 = target.hp / 8;
  // Round up the damage.
  damage = Math.ceil(damage);
  // Cap the damage to 500.
  damage = Math.min(500, damage);
  // Play the healing animation on the original caster.
  origin.startAnimation(41);
  // Original caster gains HP.
  origin.gainHp(damage);
  // Show the HP gained.
  origin.startDamagePopup();
  // Clears the original caster's HP popup.
  origin.clearResult();
  // Play the poison animation on the target.
  target.startAnimation(58);
  // 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>

FREEZE:
JavaScript:
<Category: Ailment>

<Custom Apply Effect>

target._customDotValue = origin.atk * 2;

target.removeState(125);

aliveMembers.removeState(126);

</Custom Apply Effect>

<Custom Remove Effect>

target._customDotValue = undefined;

</Custom Remove Effect>

<Custom Regenerate Effect>

if (target._customDotValue !== undefined) {

var value = target._customDotValue;

target.gainHp(-value);

target.startDamagePopup();

if (target.isDead()) {

target.performCollapse();

}

target.clearResult();

}

</Custom Regenerate Effect>

<Custom Respond Effect>
// Get the fire element ID.
var fire = 2;
// Check if physical damage is dealt.
if (this.isPhysical() && target.result().hpDamage > 0) {
// Remove immortal state.
  target.removeState(3);
// Set the target's HP to 0.
  target.setHp(0);
// Check if fire damage is dealt.
} else if (this.item().damage.elementId === fire) {
  // Get the Freeze status effect ID.
  var stateId = 35;
  // Remove the status effect from target.
  target.removeState(stateId);
}
</Custom Respond Effect>
aliveMembers.removeState(126);
There's no such thing as "aliveMembers." You're referring to it here as if it were a Game_Actor variable, but you haven't declared that variable.

You're going to see me refer to aliveMembers() below, but that's a method of the Game_Party, not just a word that can be used. It's also a function, not a variable. It's also also not a Game_Actor, so you can't call removeState() on it, that doesn't mean anything.

To remove the state from any actor that's being leeched by this enemy, do:
Code:
for (var i=0; i<$gameParty.aliveMembers().length; i++)
{
    if ($gameParty.aliveMembers()[i].isStateAffected(126) && $gameParty.aliveMembers()[i].stateOrigin(126)==target)
        $gameParty.aliveMembers()[i].removeState(126);
}
Solved. You never disappoint, Turan. Thank you!

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/yep_buffs-states_leech-seed_javascript-support.152776/