Conditional eval for Game_Troop member

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
86
First Language
English
Primarily Uses
RMVXA
I've been trying to figure this out for the better part of the last two hours, so I'm throwing in the towel and coming here.

Basically, I'm trying to write a snippet where an actor becomes affected by x state while an enemy is present. The first part of placing the conditional eval is easy since I'm just using Victor's Conditional States script which allows for evals at certain intervals to check whether a state should be applied or not.

The difficult part is that I can't seem to figure out how to search Game_Troop.members for specific enemy ids. In the setup method:

Code:
  def setup(troop_id)
    clear
    @troop_id = troop_id
    @enemies = []
    troop.members.each do |member|
      next unless $data_enemies[member.enemy_id]
      enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
      enemy.hide if member.hidden
      enemy.screen_x = member.x
      enemy.screen_y = member.y
      @enemies.push(enemy)
    end
    init_screen_tone
    make_unique_names
  end
...It's pretty clear that each value is stored inside an array, @enemies, where each array within the array contains two values, the enemy index and the enemy id. I just don't know how to access the second one though (the index is irrelevant). It would be awesome to get an answer to my title question, but it would also be great to let me know how to access specific variables in an array like this one. Thanks!
 

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
This will return true if there is any enemy with the ID of ENEMYID and that enemy is appeared and still alive.
Code:
$game_troop.members.any? { |enemy| enemy.enemy_id == ENEMYID && enemy.alive? }
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
86
First Language
English
Primarily Uses
RMVXA
This will return true if there is any enemy with the ID of ENEMYID and that enemy is appeared and still alive.
Code:
$game_troop.members.any? { |enemy| enemy.enemy_id == ENEMYID && enemy.alive? }
Awesome, this works perfectly! Thank you!
 

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

Latest Threads

Latest Profile Posts

So, uh, has anyone tried buying any resources from KokoroReflections? Because I've been looking for a 'buy' button on the site for like 10 minutes now and can't find one.
Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Jumping and gravitation 0.1 build - RPG Maker MV

Forum statistics

Threads
97,979
Messages
948,297
Members
129,241
Latest member
LordCola
Top