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.
Quick Question - Getting Enemy ID
Learning Ruby and RGSSxI do believe the syntax to get a troop member's id would be:
Which you can use in an event script call like so:
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.
Code:
$game_troop.members[index_of_battler].enemy_id
Code:
id = $game_troop.members[index].enemy_id$game_variables[some_variable_index] = id
Original thread: https://forums.rpgmakerweb.com/threads/quick-question-getting-enemy-id.31270/