I'm trying to create an array of all of the states that an actor is affected by within certain numbers listed in the database.
So for instance, let's say I'm trying to find all of the states that the actor is affect by within 1-400. And as an example let's say the actor is affected by states 12, 44, 189, and 333. How would I get these numbers into an array?
My ultimate goal is to have the plugin cycle through all of the states affecting the actor within the 1-400 range of states in the database and select one at random. Keep in mind the actor is affected by states beyond 400, so I don't want it to just cycle through every state currently applied to the actor.
While the code above works to some degree, it unfortunately cycles through all of the 400 possible states, leaving long gaps in time where nothing is coming up; and I don't want this. The actor at most would only be affected by 10-15 of these specific states at a time so I know there's room for efficiency here.
So for instance, let's say I'm trying to find all of the states that the actor is affect by within 1-400. And as an example let's say the actor is affected by states 12, 44, 189, and 333. How would I get these numbers into an array?
My ultimate goal is to have the plugin cycle through all of the states affecting the actor within the 1-400 range of states in the database and select one at random. Keep in mind the actor is affected by states beyond 400, so I don't want it to just cycle through every state currently applied to the actor.
JavaScript:
abilities = [];
for (var i = 1; i <= 400; i++) {
abilities.push(i);
}
selectedability = abilities[Math.floor(Math.random()*abilities.length)];
if ($gameParty.leader().isStateAffected(selectedability)) {
selectedability += 400;
$gameTemp.ability_checker[1] = 1;
}
While the code above works to some degree, it unfortunately cycles through all of the 400 possible states, leaving long gaps in time where nothing is coming up; and I don't want this. The actor at most would only be affected by 10-15 of these specific states at a time so I know there's room for efficiency here.