How to have auto passive state for 1 turn

Hello. I am new to RPG Maker and the forum, so let me know if anything is wrong.

First, I am using MP like a stamina, so that it will be recovered every turn a little bit, but decreases when skills are used.
I want a player/monster to be in stun state for 1 turn when the MP becomes 0, and recover to the max MP after that turn.

Therefore, I've created 2 states: (I'm using Yanfly's auto-passive state.)
1, the default state where MP regenerates by 10% each turn. (state 11)
2, the stun state where the actor cannot move. (state 12)

But if I set the default state condition as
Code:
<Custom Passive Condition>
if (!user.isStateAffected(12)) {
  condition = true;
} else {
  condition = false;
}
</Custom Passive Condition>
and stun state condition to <Passive Condition: MP below 1>,
and actor's notetag to <Passive State: 11, 12>,
the actor would never come back to state 11.

What should I do to implement what I want?
It must be reapplying it, cuase MP is less than 1. The charecter Also probably isn't regenerating MP from being stunned. I'll try to come up with a solution unless someone beats me to it
It must be reapplying it, cuase MP is less than 1. The charecter Also probably isn't regenerating MP from being stunned. I'll try to come up with a solution unless someone beats me to it

It would be awesome and I'd be very thankful if you could do that...!
I'm stuck because if I don't apply the condition to default (11) like that, it would regenerate the MP while in stun and just escape from stun right away, instead of staying unable to move.
Wait. Try fliping true and false. i think "!" means the condition isn't active

If that doesn't work. try making the MP regain a part of the charecters instead of in a state

If that doesn't work, do the code with battle events instead of code making it increase MP and stun the charecter at the same time
Wait. Try fliping true and false. i think "!" means the condition isn't active

If that doesn't work. try making the MP regain a part of the charecters instead of in a state

If that doesn't work, do the code with battle events instead of code making it increase MP and stun the charecter at the same time

I put in the '!' because I don't want regaining to be active while stun, which will cause the actor to exit from the stun.
Would MP regain inside character also trigger the character to escape the stun state at the same turn?
Also, I would really appreciate if you can explain a little more about the last thing you mentioned 🙂
I put in the '!' because I don't want regaining to be active while stun
Ironicly that's whats causing your problem then. The stun is removed when MP is above 0 right? And with this set up, MP won't go above 0 thus the charecter will be stunned indefinitly

Edit: You might want to use a progressive state script. So that the exhaustion state can progress into the MP Regain state. There is still work to be done, but it's a start

http://himeworks.com/2015/11/progressive-states-mv/
Ironicly that's whats causing your problem then. The stun is removed when MP is above 0 right? And with this set up, MP won't go above 0 thus the charecter will be stunned indefinitly
Alright. Makes sense.
Now I'm trying a different approach.
If I can have the default state to cause the user to have stun state when mp is 0, and stun state, without relying on passive stuff, would last for the turn i set through the tool itself. Is there some way to do this?

I'm trying something like
Code:
<custom battle effect>
  if (user.mp <= 1) {
    user.addState(12);
  }
</custom battle effect>
to the default state, but it wouldn't work...
See my edit in my last post
After thinking about it, i think you can do this in battle events with it being set to turn 1 + 1. In a conditinal branch, check if MP is below 1. in another, make sure a switch isn't on. If its not, apply the state and turn on the switch. Then, in another set of conditinal branches do the opposite (Like checking if MP is above 0. Fliping the switch off, ect)

Original thread: https://forums.rpgmakerweb.com/threads/how-to-have-auto-passive-state-for-1-turn.114608/