Actor/Enemy ID memorization and recall

In my project, I want to create a "Steal" skill. I can make the basic mechanics of it, (Drop table, drop rate) however I want to have individual enemies to have separate drop tables.

My original plan was to make a list of each enemy ID in a common event, and use that to have the skill function. Unfortunately, I can't figure out a way to have the system identify an enemy ID, so when it returns a particular number I can use it in the common event to determine which drop table should be checked.

In short, I need some sort of script that would allow me to have the system check an enemy ID so that I can use the ID number in a common event.
So... you want to be able to access the target's Database ID while within the common event, eh? I trust this is for 'single_enemy' attacks, correct?

First, yes. You do need a script. This script is only to make it so you can access the data in the common event. Normally, the Game_Troops class is not accessible in a common event, let alone battler data. But seeing that you need to get that data, just paste this little add-on into your scripts database. It shouldn't hamper anything at all:

Code:
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :active_battler           # active battler
  #--------------------------------------------------------------------------
  # * Get Enemies
  #--------------------------------------------------------------------------
  def enemies
    return $game_troop.enemies
  end
end

What this does is makes it easier to snag both the current 'active_battler' and data from Game_Troop when the common event runs. Now what is in the common event????... Hehehe. I made the following script call:

Code:
# Get the current target ID
idx = $scene.active_battler.
current_action.target_index
# Get the target from the enemy list
target = $scene.enemies[idx]
# Print the ID (in the Enemy DB)
p target.id

So the end product, the target.ID is the ID value you are looking up.
The add-on and script calls do provide the database IDs for the target enemy, but I can't seem to figure out how to then use that ID.

I tried making conditional branches that say, "If target.id = 1" or "If target.id = 2" but then it crashes with a message saying

"NameError occurred while running script. Undefined local variable or method 'target' for #<Interpreter:0x5b78ac0>"

I'm confused as to why the variable is supposedly undefined when the script call itself can print the database ID number. Do I need to manually define 'target' as a variable in the common event alongside the script call? And if so, how do I do that?
Okay. Needed to know your rgss/scripting level. Gotcha.

The last part of the scriptette that I posted:
p target.id
Let's change that into something you can use in a Plain Jane 'conditional branch'.

Let us replace that single statement within that script call with:
$game_variables[1] = target.id

As a lesson, the Game_Variable class, which you access with $game_variables[numeric], is the data class which stores all your RMXP variables you would use in events and conditional branches. And in the above example, I set RMXP Variable #1 to store the data of the Target ID.

So when the common event is run, it won't print the target ID, but instead will store it in RMXP variable 1. After that, you can run your conditional branch based on the value stored in RMXP variable 1. Of course, this is up to you what variable you wanna use, just by changing the number between the brackets.

😛 Hey, tactician. You appreciate my ingenuity? ☺️
Ah, I get it now. I just didn't understand that I needed to convert the ID to an actual database variable.

The event runs exactly as intended now, thank you so much for your help.

Oh, and thanks for the cool limit break script you made too. :awink:

Original thread: https://forums.rpgmakerweb.com/threads/actor-enemy-id-memorization-and-recall.86811/