Bug Report: Remove by Restriction (Confusion State)

Bug Explanation: It seems that there's a bug with Remove by Restriction not acting as described, though it's possible I just don't understand what it does. I have the Confusion and Sleep states in my project. I would like Sleep to remove Confusion, if it's present.

The way I'm reading it, this is exactly what "Remove by Restriction" is intended to do - remove the state where the box is checked (Confusion) if ANOTHER state that has a different action restriction enabled (Sleep) is added. The tooltip for "Remove by Restriction" reads: "Will be replaced by a new state with a different action restriction." And the helpfile reads: "When enabled, the condition will be removed when another state is added that has separate restrictions."

However, what's actually happening is that the Confusion state is applied and IMMEDIATELY removed. (Apparently, it is registering itself as a state with an action restriction, and triggering Remove by Restriction.)

I have tried disabling all plugins, and I tried using a blank project.

Error Report: Not applicable, it's just an unexpected behavior within the game.

Steps to Recreate:
1) Create a blank project.
2) Go to the Confusion state and check the box "Remove by Restriction".
3) Change the state on the Attack skill to Confusion 100%.
4) Battle Test. Watch Confusion be applied and removed immediately.

Sample Project: If needed, can be downloaded here.

Steps to Fix:
EDIT: I THOUGHT I came up with a solution, but even though it worked, it really shouldn't have.
However, it looks like there's a problem in $gameBattlerBase.addNewState(stateId) with the if statement used to call this.onRestrict().
I've hit the same bug in ACE too. I just get around it by not using remove by restriction. Also, if you ever add it as a passive state (via a plug-in), the game will crash as you will create a permanent loop.
@bgillisp Yeah, I could get around this using Yanfly plugins or even a common event, but since the base program isn't doing what it's described to do, I figured I'd submit the bug report. Thanks for the heads-up on the passive states, that's a good thing to watch for in the future if I add that in!
Actually, Yanfly's plug-ins might not fix it. I know in my ACE project I use a lot of Yanfly's scripts, and it still doesn't work. Maybe it is working in a way that none of us understand? Either way maybe someone who knows more on it can chime in.
@bgillisp I wound up adding "State Resist: Confusion" to the Sleep state. It works well in this instance, as a sleeping character probably wouldn't be able to be confused. Would still be nice if the core feature worked, though. 🙂
From my tests in Ace, Remove by Restriction actually means "Remove when this character is restricted". For instance, Guard is removed when you are put to sleep. It's not intuitive, but it is a function I appreciate existing.

Making the states incompatible seems to do what you want, @Llareian. I remember in older makers (XP?) Death actually removes other states. I stopped it from removing poison in one of my games because it made sense to me poison would stick around.
I will ask about to see if this is a translation error, or if it is indeed a bug with the function.

Thanks for the report,
- Liquidize

Original thread: https://forums.rpgmakerweb.com/threads/bug-report-remove-by-restriction-confusion-state.85912/