Hadn't thought of this, but the
index function will return -1 if the actor is not in the party at all
(which might happen during battle where the party is reduced to the battle members). An easier alternative to check whether your actor is in the battle party could be this:
$gameParty.battleMembers().contains($gameActors.actor(5))
The passive conditions will likely only get updated when the actors stats or traits change (hence the delay before the state is applied during battle). If you need to update your passive states manually you can try to call
$gameActors.actor(5).refresh();
or add more update trigger points through a plugin.
The screenshot does not really show what exactly causes the excessive amount of calls, most of the errors seem to come from the stack being at its limit and overflowing in random spots.
Just guessing for now, but does the error occur if you disable the passive condition? (Or change it to something simple like
condition = true; ?)
If that actually avoids the error, you could try to set the condition to this instead in case some other "non-existing" party member causes the infinite loop:
Code:
condition = (!a.isActor() || $gameActors._data[a.actorId()]) &&
$gameParty.battleMembers.contains($gameActors.actor(5)) &&
$gameParty.battleMembers.contains($gameActors.actor(6));
(This should disable the condition for any actor during their initialization rather than just actor 5 and 6).
Code:
<Custom Passive Condition>
let member1Present = $gameActors._data[5] && $gameActors.actor(5).index() < 4;
let member2Present = $gameActors._data[6] && $gameActors.actor(6).index() < 4;
if (member1Present && member2Present) {
condition = (!a.isActor() || $gameActors._data[a.actorId()]) &&
$gameParty.battleMembers().contains($gameActors.actor(5)) &&
$gameParty.battleMembers().contains($gameActors.actor(6));
} else {
condition = false;
}
</Custom Passive Condition>
Okay getting somewhere now!
The above code does set the two chosen actors to have a passive state only when they are in the first four slots of the party. (The actual party members participating in the fight.) Now it even works inside of battle as well, but at the cost of a half second of lag when switching members with the actorPartySwitch plugin which isn't THAT big of a deal.
However, I still get a load of errors every time I start a new game or load a game, but I mean once you get past the 10 seconds of nonstop errors the system works like a charm.
I also added extra states to test more options for this type of passive state with more party members or conflicting members.
Code:
<Custom Passive Condition>
let member1PresentB = $gameActors._data[2] && $gameActors.actor(2).index() < 4;
let member2PresentB = $gameActors._data[4] && $gameActors.actor(4).index() < 4;
let member3PresentB = $gameActors._data[6] && $gameActors.actor(6).index() < 4;
if (member1PresentB && (member2PresentB && member3PresentB)) {
condition = (!a.isActor() || $gameActors._data[a.actorId()]) &&
$gameParty.battleMembers().contains($gameActors.actor(2)) &&
$gameParty.battleMembers().contains($gameActors.actor(4)) &&
$gameParty.battleMembers().contains($gameActors.actor(6));
} else {
condition = false;
}
</Custom Passive Condition>
Code:
<Custom Passive Condition>
let member1PresentC = $gameActors._data[3] && $gameActors.actor(3).index() < 4;
let member2PresentC = $gameActors._data[4] && $gameActors.actor(4).index() < 4;
let member3PresentC = $gameActors._data[5] && $gameActors.actor(5).index() < 4;
let member4PresentC = $gameActors._data[10] && $gameActors.actor(10).index() < 4;
if ((member1PresentC && member2PresentC) && (member3PresentC && member4PresentC)) {
condition = (!a.isActor() || $gameActors._data[a.actorId()]) &&
$gameParty.battleMembers().contains($gameActors.actor(3)) &&
$gameParty.battleMembers().contains($gameActors.actor(4)) &&
$gameParty.battleMembers().contains($gameActors.actor(5)) &&
$gameParty.battleMembers().contains($gameActors.actor(10));
} else {
condition = false;
}
</Custom Passive Condition>
These two states work just fine, even in conjunction with each other they only lag the party switching just a little bit.
But obviously I still get nearly 1000 errors despite attempting to fix it. I'm going to try and keep toggling/ reinstalling my other plugins to see if it fixes anything, or maybe the script just needs some tidying up, I don't know. But thank you helping anyway of course.
The errors I get are constant PASSIVE STATE CUSTOM CONDITION ERROR, Maximum call stack size exceeded, and a million <failed to convert exception to string>
The only scripts appearing in the console are the two extra ones I added, when I delete them I don't see any scripts in the error console, so I'm assuming that the scripts I edited probably need to be cleaned up to stop at least some of the errors.