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 Profile Posts

Officially not a mod anymore. Thanks for the many years!
Thinking if i should post on the classifieds section...
Made another plugin showcase video! :kaojoy:
(Plugins and details inside the description of the YouTube video.) :LZScheeze:
Ami
Castle is my Biggest Fear :kaodes:. I just Managed make Part by Part (like the Entrance only),not the Entire Castle like in the RM Sample...
This video really speaks to me...

Forum statistics

Threads
104,374
Messages
1,005,910
Members
135,894
Latest member
EnriX
Top