1 turn penalty stun state triggered when TP = 0

Sup, everyone!
I'm currently dealing with 2/3 dillemas to implement some of the basic combat funcionality for a game.

The TP system will cause characters to go into a Passive Stun State for their next turn if they reach 0 TP in their turn. After the one penalty turn, they get +1 TP and the end of the turn, and can act as normal in the following turn.

I made the stun state conditional:
<JS Passive Condition>
condition=user.tp==0;
</JS Passive Condition>

It worked. Then I tried to add a +1TP gain in some shape. TP Regeneration backfired, it made the state never truly apply (the penalty stun turn wouldn't happen since the 1TP immediately cancelled the condition)

I think something on <Erase/Expire> should work, and set the Turn to 1 and setting auto removal on Turn End. But I'm not entirely sure how to write it like that.

Another issue that I'm assuming it could be happening is that it might be constantly checking the condition, so maybe an if (condition) = do nothing, else add state, sorta of thing is needed in the <Passive Condition> part? Or am I over-complicating things and the solution is simpler?

Thanks for your time!
I think you're going the wrong way by trying to make the stun itself be a passive state.

Instead, give actors a passive state that has
Code:
<JS Post-End Action>
if (user.tp == 0)
    user.addState(69);
</JS Post-End Action>

where 69 is the ID of your stun state. That will check after every action they perform to see if they've run out of TP.
I think you're going the wrong way by trying to make the stun itself be a passive state.

Instead, give actors a passive state that has
Code:
<JS Post-End Action>
if (user.tp == 0)
    user.addState(69);
</JS Post-End Action>

where 69 is the ID of your stun state. That will check after every action they perform to see if they've run out of TP.

Oh, you're right! Turns out the Post-End Action option processed the whole situation much better. Thanks, I deeply appreciate your help and input!

Original thread: https://forums.rpgmakerweb.com/threads/1-turn-penalty-stun-state-triggered-when-tp-0.167588/