Adding the same state after first removing it

This was giving me some problems yesterday.  I thought I had figured it out - and while I did identify the problem, I still don't understand why it occurs.  So I'm hoping someone can enlighten me about this.  And I'm going to try and do this without posting a screen shot so people don't have to wade through a morass of variable conditions since I already know where the problem is.  But if posting one becomes necessary I will.

It seems that when removing and adding states on this program - if I try to add the same state after first removing it - the command doesn't function. 

Conditional Branch: [1. ] is [stateA] Inflicted

Change Enemy State: [1. ], - [stateA]

Branch End

Change Enemy State: [1. ], + [stateA]

In this example, if StateA is inflicted I remove it.  Then I attempt to apply it again - but for some reason I don't understand it doesn't let me add the identical state I just removed.  Is this normal?
You're talking about enemies, so this is in a troop tab? I just tried it, and it removes it once only, and then continues to add it. Are you sure it's removing it in the first place?


Please post a screenshot of your troops tab, with the code you have above visible.
You're talking about enemies, so this is in a troop tab? I just tried it, and it removes it once only, and then continues to add it. Are you sure it's removing it in the first place?

Please post a screenshot of your troops tab, with the code you have above visible.
I'm pretty sure it's removing it.  I have a conditional branch after I remove it that triggers a text message if no States are inflicted, and the message comes up.  It's hard for me to show you the screen shot you describe, because my event is layered in common events but I will attempt it to show it in pieces.

Screen Shot.png

This is my troop tab.  At the bottom you'll see a common event called Troop1:Trait.  It looks like this:

Screen Shot_1.png

Before I add the State you will see two common events called Show E:Stances and Remove Stances.  They look like this:

ScreenShot_2.png

ScreenShot_3.png

The [show E:Stances] event is mostly just for testing purposes and just tells me when a State is inflicted or when no states are inflicted.  So you can probably ignore that one.  But I included it just in case you wanted to see it.

The [Remove Stances] is the event that actually checks if a state is inflicted them removes it.  But it's going to be important for you to keep in mind when viewing that event that I made some changes to it since I made this thread that might complicate this some. 

Since I was unable to add "Thrusting Stance" to my enemy if "Thrusting Stance" was inflicted before I removed it, I created a work around and do a check to see if Thrusting Stance was on the enemy previously.  If it was I don't remove it, because I was unable to figure out how to add the same state after I remove it.  So when you look at that event try to imagine it without the two conditional branches that check my Random Tactics Variable.  The ones underneath the comments ====If Thrusting Attack NOT Being Used ====If Thrusting Attack IS Being Used====.  I added those conditional branches as a work around since I couldn't for the life of me figure out why I couldn't add the same state after I just removed it.

Thanks for trying to help me.  It's weird it works for you but not me.

Edit#

To make things easier I rewrote the event in it's original form without the work-around conditional branches.  Maybe easier that way to see if you can figure out why it isn't working.

Screen Shot_4.png
btw, what would you want to achieve via removing a state then adding it again right away?
btw, what would you want to achieve via removing a state then adding it again right away?
It doesn't happen because I'm trying to achieve anything.  The way my battle event works is it randomly selects States to inflict on the enemy.  But I only want one of them to be inflicted at a time.  So I have a common event that removes all of the inflicted States before adding a new one.  Sometimes - due to the random nature of it - it ends up inflicting the same state on the enemy back to back.  And when that happens - for some reason I don't understand - the Change/Add State command doesn't work after my common event removes the inflicted state.
Try adding a Wait 1 Frame in there.


As I said, when I did the test, it added the state, then removed it, then added it, then it kept on adding it. It didn't remove it a second time for me.


So that might indicate that it WASN'T adding the state for me either. Maybe you need to let it come up for air between removing and adding.
Try adding a Wait 1 Frame in there.

As I said, when I did the test, it added the state, then removed it, then added it, then it kept on adding it. It didn't remove it a second time for me.

So that might indicate that it WASN'T adding the state for me either. Maybe you need to let it come up for air between removing and adding.
Guess I misunderstood you then. I thought you were saying it was working.

I tried the Wait 1 Frame idea and it was a no go.  I tried 60 frames just to be safe, and still didn't work.  So I don't think it's an issue with the event moving too fast for the program to keep up.  It may be a bug in the code or something?  I don't know.

At first it was a serious problem.  Now it's more of a nuisance since I have found a work around.  Though a lot of my make-shift fixes can come back to haunt me later on as the code matures.  I hope that's not the case with this one.

Original thread: https://forums.rpgmakerweb.com/threads/adding-the-same-state-after-first-removing-it.16898/