Remove State when variable stuck hit 0.

Hi.. im using RPG MAKER MV and YEP_BattleEngineCore.js, YEP_BuffStatesCore.JS

i have problem settings up skills in note (state).

so i want make Poison skill can be stacking damage.

Here code, i use this in state named "Poison String"
Code:
<Custom Apply Effect>
target._stackingPoison = target._stackingPoison || 0;
target._customDotValue = origin.mat;
target._stackingPoison += 1;
</Custom Apply Effect>

<Custom Remove Effect>
target._stackingPoison = 0;
</Custom Remove Effect>


<Custom Regenerate Effect>
target._stackingPoison = target._stackingPoison || 1;
var stacks = target._stackingPoison
var def = target._customDotValue
var damage = stacks * 50 - def * stacks;
target.startAnimation(59);
target.gainHp(-damage);
target.startDamagePopup();
target.clearResult();

if (target.isDead()) {
  target.performCollapse();
}
</Custom Regenerate Effect>

I build Skill again to remove -1 stacking Poison String named "Cure Poison"
here code i use

Code:
<Custom Apply Effect>
target._stackingPoison = target._stackingPoison || 0;
target._stackingPoison -= 1;
</Custom Apply Effect>

<Custom Regenerate Effect>
if (target._stackingPoison <= 0) {
target._stackingPoison = 0;
origin.removeState(30);
}
</Custom Regenerate Effect>

but when Stacking hit 0, why states not remove?. i need help. thanks..

sorry for bad english.
Why do you use "origin.removeState"? It will remove that state on the user who applies the state on your target. Try to change it to "target.removeState" or "user.removeState" to see.
Why do you use "origin.removeState"? It will remove that state on the user who applies the state on your target. Try to change it to "target.removeState" or "user.removeState" to see.
Okay thanks.. Sorry in advance, I really didn't understand ... and it turns out the problem was there. I am very grateful.

Original thread: https://forums.rpgmakerweb.com/threads/remove-state-when-variable-stuck-hit-0.122809/