MZ [Visustella Auto Skill Triggers] Targeting previous target

Hello everyone,

I am using Visustella's Auto skill trigger plugin to create a skill that triggers when using a particular skill. However when the skill is triggered it seems to either hit a random enemy or the 1st one in the troop.

I've seen this issue somewhat solved in this thread, however in this case I'm trying to have the triggered skill target the last enemy that was targeted/attacked. Is there a script that would be able to make this work? Thank you in advance!
If you do it the same way by setting a VS Battlecore target notetag in the skill, I think it's:

<JS Targets> if ($gameTroop.members()[$gameTemp.lastActionData(5)-1].isAlive()) targets = [$gameTroop.members()[$gameTemp.lastActionData(5)-1]]; </JS Targets>

However, if the original attack kills the enemy, the autoskill will target another enemy (maybe could be avoided with an else branch empty targets array?).

Original thread: https://forums.rpgmakerweb.com/threads/visustella-auto-skill-triggers-targeting-previous-target.163014/