Yanfly State-Absorption Barrier trouble

Hello! I don't go to the forums that often, but I felt like this is a very important matter and I've been stuck on it literally all day (7+ hours), so for context:

I wanted to have a state automatically remove itself if the absorption barrier is at 0 or at the least a certain number or percentage, this way I could, instead of having a shield state be universal, have equipments that have a per-basis effect, so the regen rate and the amount given wouldnt be the only things that are different (that would be the easy way out but not what I'm looking for), and so that i dont have to resort to making these per-basis benefits last even after the barrier points are gone on a unit

We figured out that the states given by armor or passive states dont work by removal, because they keep them there no matter what even when "removed". so I tried a skill method and it worked, the skill method is suitable even if id prefer to use the first method (giving the state using the equipment instead of having to manually add the state and allow removal).

however, the FINAL problem im facing is that I want the state to leave as soon as the shields are gone, and not at the regeneration phase, as that will lead to forcing enemies to attack you while you still have the buffs applied to you even after your shield is depleted, and can apply to enemies too, so Id prefer not to have (for example) the enemy with a 30% resistance to a damage type to benefit from said effects even after its shields are gone.

the current situation is that if there were 5 enemies, at the moment, if one breaks your barrier and the other 4 come BEFORE your regeneration phase, they'll still have to deal with the stat bonuses
you have on your actor (so if the barrier was broken, the buffs that the shield state gave should go away immediately and not interfere with any actions between the breakage of the barrier and the regen phase of your actor)

in other words, I want the effect to leave as soon as the conditions are met and not wait until regen phase, or else it'll cause problems later on, and i'm spending an extraordinary amount of time on this already and want to get to other parts of my game

upload_2019-4-22_21-21-33.png
does a passive state condition work?
user.!stateAffected(x) for a passive check on the buffs. X being the barrier state which is now only used as an icon.

this would only work if you have no other skills that could give that person a barrier
Does this help? https://steamcommunity.com/app/363890/discussions/0/1743353164075380531/
(You'll need to replace 98, 99, 100 with the state IDs you want to remove on 0 BP.)
okay so for now it looks like it's working! thank you for the help
Great! 🙏

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-state-absorption-barrier-trouble.108265/