Quick Question - Getting Enemy ID

● ARCHIVED · READ-ONLY
Started by dugald 2 posts View original ↗
  1. I'm hoping this will be a quick and easy question.  I would like to write a variable operation (using the normal Control Variable function off of the event commands list) that will set the variable's value to the database ID # of enemy #X of the current enemy troop.  How would I go about writing the script that is evaluated for the variable operation?  I know pretty much nothing about Ruby's syntax, so I am not even sure where to start trying possible expressions.
  2. I do believe the syntax to get a troop member's id would be:

    Code:
    $game_troop.members[index_of_battler].enemy_id
    Which you can use in an event script call like so:
    Code:
    id = $game_troop.members[index].enemy_id$game_variables[some_variable_index] = id
    Be wary that if the enemy in $game_troop.members[index] is nil, then the method call enemy_id will fail, because nil doesn't have said method.