check which enemy has state?

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Basically I just need to know the script for looping through every enemy until I find the one with the state and then return its id. I know I've seen this done before but I can NOT remember how.

**EDIT** Actually, if anyone knows how to store the id of a skill's target that'd work just as well. I thought it would be something simple like $game_variables[x] = b? (I've also seen b.id) but neither seem to work? if that's correct though let me know.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
675
Reaction score
437
First Language
English
Primarily Uses
RMVXA
To get the first enemy with that state, use:
Ruby:
enemy = $game_troop.members.find {|m| m.state?(STATE_ID)}
Alternatively, for every enemy with that state, use:
Ruby:
$game_troop.members.select {|m| m.state?(STATE_ID)}.each do |enemy|
    # do stuff here
end
Untested but it should work.

You should just be able to store the enemy using $game_variables[x] = b in the damage formula. How are you using it after it's stored?
 

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
To get the first enemy with that state, use:
Ruby:
enemy = $game_troop.members.find {|m| m.state?(STATE_ID)}
Alternatively, for every enemy with that state, use:
Ruby:
$game_troop.members.select {|m| m.state?(STATE_ID)}.each do |enemy|
    # do stuff here
end
Untested but it should work.

You should just be able to store the enemy using $game_variables[x] = b in the damage formula. How are you using it after it's stored?
Oh shoot I forgot I to check on this, sorry for the late response lol. Come to find out I was doing something else wrong on my event that SEEMED like it wasn't taking the id, but it was.

"$game_variables[x] = b" worked just fine.

But thank you very much for this! I'm still trying to learn and this is very helpful!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Is there anyone need help with anything except art and music?
is Gotcha Gotcha Games Inc. = KADOKAWA CORPORATION? I haven't found this topic yet, Want to know for credits on my game. Thanks.
If you get everything you want, when you want it, it kills your creativity. If you never get anything you want, you're forced to be creative with what you have.
Old chiptune loops free for use.
I think I've got my hero designs pretty much finialised ( still got some tweaks. ) In the end it'll be the four outfit colour variants with four different skintones.

Forum statistics

Threads
104,299
Messages
1,005,377
Members
135,818
Latest member
Hennet91
Top