Hi!
I need to check if 2 or more actors in a range have the same status.
Ie. Check if at least 2 actors between 1, 2, 4 and 5 have status x.
How can I do this without nesting CBs here and there?
you can make a loop that counts up a variable whenever the condition is fulfilled, and then check how many actors have that condition by checking the variable.
One way to do it would be with a new function:
Game_Party.prototype.checkStates = function(actors, state) {
for (i = 0; i < actors.length; i++) {
var actor = actors[i];
if (actor.isStateAffected(state)) {
console.log(actor.name() + ' has state ID ' + state);
}
}
}
You can call the function with a script call to check for a state with a custom array of actors:
var actors = [$gameActors.actor(1), $gameActors.actor(2)]
$gameParty.checkStates(actors, 6);
Or use an existing array. This would check all party members in battle:
var actors = $gameParty.battleMembers()
$gameParty.checkStates(actors, 6);
Depending on the context of how and when want to make this check, you might want to move the function out of Game_Party and maybe into Game_Battler or something.
Hopefully this will get you started.