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

Just finished my midterms! Freedom! Alright, back to gamedev!
I confirmed my train ticket yesterday. I'll be heading to Orlando on the 29th... last time I went, I found this little treasure!
Done with another simple battleback :LZYcheeze:

Forum statistics

Threads
104,306
Messages
1,005,433
Members
135,829
Latest member
LordPenguin666
Top