A question about undying ability

I type this script in note of state "Death". But it doesn't effect, I don't know what's wrong with it.

Code:
<Custom Apply Effect>
if (target.isActor()) {
  var i = 32 ;
  if (target.isStateAffected(i)) {
    target.removeState(i);
    target.startAnimation(42);
    var hp = Math.floor(target.mhp * 0.1);
    target.gainHp(hp);
    target.startDamagePopup();
  }
}
</Custom Apply Effect>

It should make the character revive from death......
What about substituting target for user? After all, custom apply effect doesn't deal with targets and subjects AFAIK.
Without knowing anything about State 32, I think the most likely problem is that since all states get removed automatically upon death by default, State 32's getting removed. So the code for the death state thinks that the battler doesn't have State 32 and thus doesn't process. In this case, I'd suggest grabbing Yanfly's State Categories plugin and putting the notetag <Category: Bypass Death Removal> into State 32's notes.

Again, this is without knowing anything about State 32. I don't know what the problem could be if you've already done this.
What about substituting target for user? After all, custom apply effect doesn't deal with targets and subjects AFAIK.

It's no use......

Without knowing anything about State 32, I think the most likely problem is that since all states get removed automatically upon death by default, State 32's getting removed. So the code for the death state thinks that the battler doesn't have State 32 and thus doesn't process. In this case, I'd suggest grabbing Yanfly's State Categories plugin and putting the notetag <Category: Bypass Death Removal> into State 32's notes.

Again, this is without knowing anything about State 32. I don't know what the problem could be if you've already done this.

It really works as you say. The problem is state 32 removed by death......thank's a lot!
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/a-question-about-undying-ability.90483/