MZ VisuStella - Skills and States Core, JS Passive Condition

Greetings. I am using VisuStella's Skills and States Core plugin.

I'm trying to create a passive state that only activates if the actor isn't affected by any of the states listed in its condition. However, the code I'm using only works if every listed state is affecting the actor.

This is the code I'm using in the passive state's note box:
<JS Passive Condition> condition = ((!user.isStateAffected(41)) || (!user.isStateAffected(45))); </JS Passive Condition>

My intent is this passive remains active if the actor isn't affected by either state 41 or 45. But right now, it will only deactivate if the actor is affected by both state 41 and 45. Is there a way to fix this?
Your problem is that you are using ||, the logical OR to connect your two statements. a || b will be true if either a, b or a and b are true. So let's examine what happens when your battler is only affected by one of these states (for example state 45):
1. The user is not affected by state 41, so isStateAffected returns false.
2. We use ! to negate that (flip from true to false or vice versa). So the first part of our expression is true.
3. As the user is in fact affected by state 45, isStateAffected returns true.
4. We also negate that with !, making it false.
5. Our condition now is set to true OR false. As mentioned above, one true is enough to make the whole OR expression true. Only if the user is not affected by either state, both sides of the OR will be false and only then your condition will also be false.

We can simply connect these two statements in our expression with &&, the logical AND. Now both sides must be true for the condition to be true. A single false value (because the user is affected by a single state from your list) will cause the whole condition to become false.
Greetings. I am using VisuStella's Skills and States Core plugin.

I'm trying to create a passive state that only activates if the actor isn't affected by any of the states listed in its condition. However, the code I'm using only works if every listed state is affecting the actor.

This is the code I'm using in the passive state's note box:
<JS Passive Condition> condition = ((!user.isStateAffected(41)) || (!user.isStateAffected(45))); </JS Passive Condition>

My intent is this passive remains active if the actor isn't affected by either state 41 or 45. But right now, it will only deactivate if the actor is affected by both state 41 and 45. Is there a way to fix this?
It's like what @eomereolsson said, you need a Logical And.
We can simply connect these two statements in our expression with &&, the logical AND. Now both sides must be true for the condition to be true.

Try this code:

Code:
<JS Passive Condition>
 if (!user.isStateAffected(41) && !user.isStateAffected(45)){
   condition = 1;
 } else {
   condition = 0;
 }
</JS Passive Condition>
Just as a note, unlike C, the reserved words true and false in JavaScript are not equal to the numerical values 1 and 0. This can often work correctly, but if there's any place in the VisuStella where they use strict equality, e.g. condition===true, it will fail because you set it to 1.

So if you know you're working with something that expects a boolean, it's better to stick to true/false.
Or just simplify down the code and have:
Code:
<JS Passive Condition>
condition=!user.isStateAffected(41) && !user.isStateAffected(45);
</JS Passive Condition>
Thanks, y'all!! I understand my error, and the state now works as intended.

Original thread: https://forums.rpgmakerweb.com/threads/visustella-skills-and-states-core-js-passive-condition.143706/