Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
135
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
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?
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,382
Reaction score
8,098
First Language
German
Primarily Uses
RMMV
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.
 

Kenen

Veteran
Veteran
Joined
Apr 3, 2012
Messages
301
Reaction score
226
First Language
English
Primarily Uses
RMMZ
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

Light up explosions with QABS and Community Lighting.
qcPQHt9.gif
Doing RPG Maker News #18 | Moghunter is Back, Encrypt MV/MZ Plugins, Isometric Geometric Tiles
Unironically, no joke, after consideration and self-reflection, I have decided that the best thing for my creative/workflow/commitment problems is to spend EVEN MOAR hours a day playing videogames than I normally do. (Micro-thread)
FINALLY got my weather system implemented. Who needs a black mage when you have a weathermancer! :p

Forum statistics

Threads
110,650
Messages
1,054,946
Members
143,776
Latest member
CursedBlackWolf
Top