[SOLVED]Need help with custom passive condition for Yanfly Passive States

Here is the link to Passive States, Buff & States Core, and Absorption Barrier. I believe these are all the plugins associated with what I'm doing.

What I've done is create a passive state that only actives when the actor has barrier points. It's very simple and works fine. This is what it looks like:

Code:
<Custom Passive Condition>
var statusblock = user.barrierPoints();
if (statusblock > 0) {
  condition = true;
} else {
  condition = false;
}
</Custom Passive Condition>

The point of this passive state is to provide protection against certain other negative status effect states while the actor has active barrier points. For example, if an attack would inflict poison and the actor has barrier points, then the poison state is not inflicted. This works fine.

What I've overlooked is that if the actor has poison inflicted at the time the passive state is activated, due to barrier points being added to the actor in some way, the poison state is then removed. That's because the passive state has the trait resist poison. I do not want a negative state to be removed when barrier points are added, I only want the negative state to be prevented if the barrier points were active when the attempt to inflict the negative state took place.

My theory is to possibly add another custom passive condition that checks if an array of these negative states are already applied to the actor, therefore preventing the passive state from activating. However, I am unsure of exactly how to write the lunatic code for that.

Also, if my theory works, then it could possibly create another problem. Let's say the actor has poison applied, he then gets barrier points added, but the passive state does not activate because the actor already had poison applied. Now, even though the actor has barrier points again, he will succumb to further negative status effects. This is what I don't want to happen.

If anyone has some ideas, I am open to try them. I would really like to have my cake and eat it too... 😩
Instead of State Resist traits, try using State Rate 0% traits. 🙂

State Resist is designed to make it impossible for the state to exist on the battler.
State Rate 0% makes it impossible for the state to be added to the battler.
Oh my word, I think you may have discovered the simplest of solutions. I can't believe I didn't think about doing that.

I'll test it when I get the chance, and I'll update.
Yay, I like simple solutions! 😂
@caethyril Thank a lot for the solution! It works just like I wanted it to now. I still can't believe I didn't see that for myself lol 😅

I would consider this issue solved.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-need-help-with-custom-passive-condition-for-yanfly-passive-states.123019/