[FIX] Status Effects Removing Incorrectly in MOG - ATB System

So I have been using the ATB System by Moghunter and noticed that the Poison status effect would be removed from the player after a short while, even though this is set to never auto-remove.

After some digging in the code I think I found the issue and fixed it.

Note, this worked for me, however may not work for you as required.
Before making any changes BACK UP YOUR PROJECT!

So, the issue I found looks to be on within the remove_states_auto_atb method.

This cycles through all effects applied to battlers and checks if the state should be removed.
After doing some initial checks (Checking state turns and restrictions) it then checks the auto removal timing and max turn.

This is where is issue looks to be:

Ruby:
unless state.auto_removal_timing == 2 and state.max_turns <= 1
    remove_state(state.id)
end

As we see here, this will remove the state unless the auto removal time is 2 and the max turns is less than or equal to 1.

This is where the problem looks to be.

For those that don't know, auto removal time 0 = Never Remove, 1 = Action End, and 2 = Turn End.

So to fix this, all you need to do is change this to following and this should fix it!

Ruby:
unless state.auto_removal_timing == 0 and state.max_turns <= 1
    remove_state(state.id)
end

Ps. In my project I tweaked it a bit more as shown below but that was just personal preference:

Ruby:
next if state.auto_removal_timing == 0
next if state.max_turns <= 1
remove_state(state.id)
Normally, you would create a new method for the state class as a way to let it handle those checks while only calling the state's contents once from that condition. It's not mandatory but serves as a good example of encapsulation of that process.
I have encountered another issue of the back of this, in that if the Battlers HP hits 0 by status effect, they don't die until they are damaged by a skill :/
RPG immortality achieved by the scripter! 😮
That's as dangerous as claiming a non existing penalty during a match. :S

Double check that just in case that's not the only issue there.
So I found the issue and not sure what would cause it (I have disabled all the battle scripts I have and it still happens so maybe a default thing?

Poison will leave the player with at least 1HP during battle, at it looks like "K.O by slip damage" was being disabled by my base troop event

Original thread: https://forums.rpgmakerweb.com/threads/fix-status-effects-removing-incorrectly-in-mog-atb-system.158205/