SOLVED Advice on making a custom Death state

Hello, all! I'm working on a state for a character in my game who is an undead. My idea is that instead of the normal Death state, they have a custom 'Fallen' state applied that lasts for 7 turns and then revives them with 5% MHP + 150.

Using Yanfly's Auto Passive States, I created the state and gave it the passive condition of 'HP below 1,' while also making the actor resistant to the base Knockout state. The problem is that the turn counter isn't showing up when the state is applied and when I attempt to check how many turns the state has left in the console, it returns 'NaN.' Is there a different way I should be going about this?

Spoiler: Fallen Status
fallenStatus.png

Spoiler: Fallen Status Notetags
Code:
<Cannot Select: All>
<Passive Condition: hp Below 1>

<custom apply effect>
console.log('Custom Apply Effect');
target._stateTurns[136] = 7;
AudioManager.playSe({
  name: 'Collapse4',
  volume: 90,
  pitch: 100,
  pan: 0
});
</custom apply effect>

<custom leave effect>
var value = Math.round(target.mhp * 0.05);
user.startAnimation(70);
target.gainHp(value);
target.startDamagePopup();
target.clearResult();
</custom leave effect>

Spoiler: Console
fallenConsole.png

Spoiler: Plugin List
pluginList_01.png

pluginList_02.png

pluginList_03.png

pluginList_04.png

pluginList_05.png

pluginList_06.png
You're doing several things wrong here.

First and biggest, the whole point of a passive state is they don't have any duration in turns - they are permanently on the target as long as their condition is valid.

Second, there's no such thing as an Apply Effect on a passive state (unless you use the modification from my tweaks thread).

I would expect some things to not work correctly if you try to leave the target at 0 HP without them counting as dead.

Instead of this, I'd put a passive on the actor with a Custom React Effect that says if the incoming damage (value) is >= current hp, change the value to leave the target at 1 HP and apply a second, regular state for being a zombie that has a 7-turn duration in its database settings.

Then that state has a Leave Effect to do the parting heal.
You're doing several things wrong here.

First and biggest, the whole point of a passive state is they don't have any duration in turns - they are permanently on the target as long as their condition is valid.

Second, there's no such thing as an Apply Effect on a passive state (unless you use the modification from my tweaks thread).

I would expect some things to not work correctly if you try to leave the target at 0 HP without them counting as dead.

Instead of this, I'd put a passive on the actor with a Custom React Effect that says if the incoming damage (value) is >= current hp, change the value to leave the target at 1 HP and apply a second, regular state for being a zombie that has a 7-turn duration in its database settings.

Then that state has a Leave Effect to do the parting heal.
It worked! Thank you!

If anyone is interested in using a state like this, I'm putting the screenshot of the states below.
Spoiler: Undead Status
undeadStatus.png

Spoiler: Fallen Status
fallenStatus_final.png

Code:
<Cannot Select: All>

<custom apply effect>
console.log('Fallen Applied');
AudioManager.playSe({
  name: 'Collapse4',
  volume: 90,
  pitch: 100,
  pan: 0
});
</custom apply effect>

<custom leave effect>
console.log('Fallen Status Leaving')
var value = Math.round(target.mhp * 0.05);
console.log('Recovering ' + value + ' HP');
user.startAnimation(70);
target.gainHp(value);
target.startDamagePopup();
target.clearResult();
</custom leave effect>

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/solved-advice-on-making-a-custom-death-state.174309/