MV Apply a different status upon state removal

so, I'm using some yanfly plugins (namely "absorption barrier" and "Action sequence pack 1-3"). I'm creating a system where "defending" (AKA; the guard skill) raises your guard (barrier points). you must break your enemies guard before you can deal any damage to there HP. the "defend" skill also applies an invisible "chance to stun" status to the user lasting 3-5 turns. so, I want to set up the "guard" status effect to apply "Stunned" once it is removed, but only if the battler is still effected by "chance to stun", otherwise it will apply "Fumble".

"Stunned" prevents battler from doing anything for 3-4 turns with a 25% chance to be removed when taking damage.
"Fumble" prevents battler from "defending" for 2 turns with a 50% chance to be removed when taking damage.

so this is what I have on the guard state:

Code:
<Custom Remove Effect>
   code
   code
</Custom Remove Effect>

what do I put in the middle here?
Code:
if (user.isStateAffected(ID for your chance to stun state))
    user.addState(ID of stun);
else
    user.addState(ID of Fumble);
Thanks for the help. unfortunately, it doesn't seem to be working. I think maybe the "Buffs And States Core" doesn't recognize the "Guard" state as being removed via the "Absorption Barrier" plugin. (also, I said I was using "Action sequence pack 1-3" when I meant the "Buffs And States Core", sorry)

this is what I have:

Code:
<Custom Remove Effect>
   if (user.isStateAffected(3))
    user.addState(8);
else
    user.addState(9);
</Custom Remove Effect>
I think maybe the "Buffs And States Core" doesn't recognize the "Guard" state as being removed via the "Absorption Barrier" plugin.
I don't understand what that means.

If you changed the Guard command to add a state, the code I provided should run when that state is removed from the battler, no matter how. I'm not sure what Absorption Barrier has to do with it.

It might help if you simply posted screenshots of the Guard skill and the states involved.
the plugin parameters for "Absorption Barrier" allows you to assign a state to be applied when "barrier points" are more than 0. this is how the "guard" status effect is applied, rather than the "Defend" skill applying it.
Okay...so the problem is that using that plugin parameter doesn't actually apply and remove that state.

It basically sneaks it into and out of an actor's list of states whenever the states are checked by the game.

I assumed from your prior posts that you were trying to base this all on the timing/removal of the state, but you're actually trying to do it based on timing from the barrier. The problem is that the Absorption Barrier plugin doesn't give you a way to do that.

So to accomplish this, you're going to have to do some more stuff to the state.
Code:
<Custom Select Effect>
user.hasBarrier=user.barrierPoints();
</Custom Select Effect>

<Custom Respond Effect>
if (user.hasBarrier && !user.barrierPoints())
    user.removeState(2);
</Custom Respond Effect>

That should cause you to lose the Guard state after taking a hit that destroys your barrier. Calling it through removeState should cause the Remove Effect from before to happen. If not, you could try putting the code from the Remove Effect inside the conditional of the Respond Effect.
so I removed the Guard state from the Absorption Barrier plugin parameters, and now the state is applied by the Defend skill. I added the extra code to the Guard state, but now it won't go away once the barrier is broken.

Code:
<Custom Select Effect>
user.hasBarrier=user.barrierPoints();
</Custom Select Effect>

<Custom Respond Effect>
if (user.hasBarrier && !user.barrierPoints())
    user.removeState(2);
</Custom Respond Effect>

<Custom Remove Effect>
   if (user.isStateAffected(3))
    user.addState(9);
else
    user.addState(10);
</Custom Remove Effect>
so... I have something almost working.

Code:
<Custom Respond Effect>
if (user.barrierPoints() <= 0)
    user.removeState(2);
</Custom Respond Effect>

<Custom Remove Effect>
   if (user.isStateAffected(3))
    user.addState(9);
else
    user.addState(10);
</Custom Remove Effect>

with the above code on the guard state, it does remove itself once the barrier is broken, but only until the battler has taken their turn. (the removal of the guard state is delayed) and, it still doesn't apply "fumble" or "stun".
Just to mention it, we're not supposed to post twice in a row. If you want to add something onto your post and no one has replied yet, there's an Edit button on the bottom.

so... I have something almost working.

Code:
<Custom Respond Effect>
if (user.barrierPoints() <= 0)
It doesn't hurt anything, but it looks like the code doesn't allow for negative points to be recorded, so that should be the same as !user.barrierPoints() as I had above.

with the above code on the guard state, it does remove itself once the barrier is broken, but only until the battler has taken their turn.
Do you mean only after the battler takes their turn? Or you actually mean the Guard state re-applies itself?

it still doesn't apply "fumble" or "stun".
Both of the things you're reporting are very odd. Have you checked that your Yanfly plugins are in the correct order as listed on the Yanfly Engine Plugins site? Having them out of order can cause weird, random malfunctions like this.
DELETED
Just to mention it, we're not supposed to post twice in a row. If you want to add something onto your post and no one has replied yet, there's an Edit button on the bottom.


It doesn't hurt anything, but it looks like the code doesn't allow for negative points to be recorded, so that should be the same as !user.barrierPoints() as I had above.


Do you mean only after the battler takes their turn? Or you actually mean the Guard state re-applies itself?


Both of the things you're reporting are very odd. Have you checked that your Yanfly plugins are in the correct order as listed on the Yanfly Engine Plugins site? Having them out of order can cause weird, random malfunctions like this.
Oh, I feel like an idiot. sorry, I haven't posted on this site much at all and I'm still figuring out how it works. my apologies. I didn't realize their was a significant difference between "replying" and adding another post.

but, i have done some more fiddling with the code and got this:

Code:
<Custom Turn Start Effect>
if (user.barrierPoints() <= 0)
    user.removeState(2);
</Custom Turn Start Effect>

<Custom Action Start Effect>
if (user.barrierPoints() <= 0)
    user.removeState(2);
</Custom Action Start Effect>

<Custom Action End Effect>
if (user.barrierPoints() <= 0)
    user.removeState(2);
</Custom Action End Effect>

<Custom Turn End Effect>
if (user.barrierPoints() <= 0)
    user.removeState(2);
</Custom Turn End Effect>

<Custom Remove Effect>
   if (user.isStateAffected(3))
    user.addState(9);
else
    user.addState(10);
</Custom Remove Effect>

<Custom Leave Effect>
   if (user.isStateAffected(3))
    user.addState(9);
else
    user.addState(10);
</Custom Leave Effect>

not sure how much of this is redundant, but it mostly works how I want it. with this, their is no delay with the removal of the guard state (at least not any that drastically effect the flow of battle), and it does now apply "Fumble" and "Stun", but only occasionally and not every time like I want.

P.S. - how do I delete the above post?
Oh, I feel like an idiot. sorry, I haven't posted on this site much at all and I'm still figuring out how it works. my apologies. I didn't realize their was a significant difference between "replying" and adding another post.
I'm not sure what that means, Replying to a post is just quoting it in your editor. The rule is regarding more than one post in a row from the same person, it doesn't matter if they're quoting anything or all new posts.

not sure how much of this is redundant
A lot. There's no reason to have Custom Leave and Custom Remove - any time Leave happens, Remove will also. I also don't see why you're looking at the beginning and ending of their action, what can the person do during their action that would cause them to lose their barrier?

Similarly, I don't see the point in checking at the start of the turn when you just checked at the end of the turn. And none of them should be necessary. If you want to try one more thing, go back to the one notetag you had before and change the Respond to Deselect.

it does now apply "Fumble" and "Stun", but only occasionally and not every time like I want.
Well, that's up to you - clearly things aren't working quite right, but if you're satisfied with this, then good luck with your game!

P.S. - how do I delete the above post?
You don't.
Well, that's up to you - clearly things aren't working quite right, but if you're satisfied with this, then good luck with your game!
well, I just figured out the last issue. I had set up an "enemy defend cooldown" state applied by the defend skill, to prevent enemies from spamming "defend" while also giving it a higher priority. for whatever reason, I had set up the cooldown state with resistance to both "fumble" and "stun". i removed the state resistances and now everything appears to be working as intended.

thank you for your help, and your patience with me.

P.S. - sorry if you had a hard time understanding me. I'm autistic and I don't always know how to phrase things in a way that others will understand.

Original thread: https://forums.rpgmakerweb.com/threads/apply-a-different-status-upon-state-removal.151648/