Call Last Enemy ID to Act

So I have a skill that enemies do, and with a common event I want it to store the latest enemy's ID that used it as a variable.

Problem is by default you can only call Last Enemy INDEX to act, and I need Last Enemy ID to act.
Set the variable to this script:
$gameTroop._enemies[$gameTemp._lastActionData[3]]._enemyId
and I need Last Enemy ID to act.
why? as soon as you have a troop with multiple of the same enemy (like the default Goblin*2) then the ID is useless because all those goblins have the same ID.
That is the entire reason for the existance of the index, the ID is not unique for a troop, it is only unique for a type of enemy.
why? as soon as you have a troop with multiple of the same enemy (like the default Goblin*2) then the ID is useless because all those goblins have the same ID.
That is the entire reason for the existance of the index, the ID is not unique for a troop, it is only unique for a type of enemy.
Enemies are unique so I have a lil [Rot inflicted by Enemy : X] on the character bio.

Set the variable to this script:
$gameTroop._enemies[$gameTemp._lastActionData[3]]._enemyId
Still seems to return 0 after the skill is used.
asdd.png
@Drake616, try this
$gameTroop._enemies[$gameTemp._lastActionData[3]-1]._enemyId

I'm dumb, or RM is dumb. Enemy "Index" isn't the index i thought it was, where the first enemy would be "0". I think it adds one so that 1st is "index 1". So to compensate we need to subtract 1.

I don't think it was returning 0. It was probably looking for an extra enemy in the troop array that doesn't exist, and therefore doesn't have an _enemyID.

Original thread: https://forums.rpgmakerweb.com/threads/call-last-enemy-id-to-act.145859/