Remove state when HP is full

(MV, 1.6.2)

I'm working on making some kind of "Safe mode" state for character. Idea is next:

If actor's HP is below or equals 25%, then actor gains "Safe" state.
This state regenerating the health.
If actor's HP is equals 100%, then removes this state.

But i met some troubles: default hp regeneration acts slower on the map. How to quick this thing?
And how to check actor's HP in this case?
You can do that in two ways:

1. Use Yanfly Auto Passive States plugin and in your state "Safe Mode" add (in notes field) following:
Code:
  <Custom Passive Condition>

if (user.hp == user.mhp) {

condition = false;

} else {

condition = true;

}

</Custom Passive Condition>
and simply add this state to your character / actor.

2. With troop eventing:
https://prnt.sc/p2njyj
You can do that in two ways:

1. Use Yanfly Auto Passive States plugin and in your state "Safe Mode" add (in notes field) following:
Code:
  <Custom Passive Condition>

if (user.hp == user.mhp) {

condition = false;

} else {

condition = true;

}

</Custom Passive Condition>
and simply add this state to your character / actor.

2. With troop eventing:
https://prnt.sc/p2njyj
I tried to make it by eventing. But suddenly stuck with variables which suppose to check actor's HP/Max HP.
I will try to use Auto Passive States.
As I understand, I just need to install Yanfly's plugin and write in notes next:
Code:
  <Custom Passive Condition>

if (user.hp == user.mhp) {

condition = false;

} else {

if (user.hp < user.mhp) {

condition = true;

}

}

</Custom Passive Condition>
It means that If actor's HP equals to Max HP, then state removes. Otherwise, if user's HP belows MHP, then state remains.
Then, if I understand correctly, I can just add event "If actor's HP is belows 25%, then add "Safe Mode" state on it" in combat.
Or even in map, but i have a question: how to quick HP regeneration on the map? Because default trait regenerates HP faster only in battle, but not on the map.
Yes, install that plugin, read instructions and everything will be fine, I'll show you on my example:
https://prnt.sc/p2rsld

if actor's TP is greater or equal 80 (user.tp >= 80) state will be enabled and active, otherwise it is disabled.
I have "Maximum call size exceeded" error each time, when character supposed to get the state.
It seems that passive state conflicts with a common event and any other plugins.
The common event suppose to change actor's class and name.
Plugins that i using is ChangeGraphic.
---
This is common event. It launches by skill:
commonevent1.jpg

This is the state
state.jpg

For now error appears like this:

RangeError: Maximum call stack size exceeded
at Game_Actor.Game_BattlerBase.passiveStateConditions (YEP_AutoPassiveStates.js:494)
at Game_Actor.Game_BattlerBase.meetPassiveStateCondition (YEP_AutoPassiveStates.js:488)
at Game_Actor.Game_BattlerBase.getPassiveStateData (YEP_AutoPassiveStates.js:461)
at Game_Actor.passiveStatesRaw (YEP_AutoPassiveStates.js:576)
at Game_Actor.Game_BattlerBase.passiveStates (YEP_AutoPassiveStates.js:441)
at Game_Actor.Game_BattlerBase.states (YEP_AutoPassiveStates.js:427)
at Game_Actor.Game_BattlerBase.traitObjects (rpg_objects.js:2371)
at Game_Actor.traitObjects (rpg_objects.js:3808)
at Game_Actor.Game_BattlerBase.allTraits (rpg_objects.js:2375)
at Game_Actor.Game_BattlerBase.traits (rpg_objects.js:2381)

For now, APS stand above ChangeGraphics and Yanfly's BattleCore. Actor have <passive state>.
There is full list of plugins.
plugins.jpg
@Morizel
1. You're plugins are out of order(You're Yanfly Ones I mean) it should match how it's listed here.
2. The code in yours state is a bit messed up.
3. It seems like something is stacking over and over again, it's hard to explain the code to someone who knows so little about the code, but basically something is calling itself over and over again with an end point.

Original thread: https://forums.rpgmakerweb.com/threads/remove-state-when-hp-is-full.112988/