Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
133
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,350
Reaction score
8,079
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
300
Reaction score
222
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

besides itch and occasionally here where are people doing game jams at y'all? (plz do not cross reference this with my previous status lol)
Go out all day!
★No work★
Just want to sleep when I get home Zzzzz
just went through 50 issues of Fables, only to left kind of disappointed by it, I guess I have to wait for season 2 of TWAU instead.
Untitled Project.gif

Feel free to subscribe, cuz im gonna release it first there.
https://crashykk.itch.io/crashykk-retro-tileset
and_remember_tomorrow_beside_myself.jpg

The worst part about making custom stuff is, I can't really ask any of you why a second copy of the character randomly appears only when going SW, S, or SE and changing directions. Been bugging me for the last two days. On the plus side, look at the new random map pieces I made while thinking about it.:LZSexcite:

Forum statistics

Threads
110,434
Messages
1,053,262
Members
143,498
Latest member
Juhguu
Top