MZ Help with JS Targets using Visustella BattleCore in RPG Maker MZ

I am trying to create a follow up attack that can trigger whenever an ally basic attacks an enemy using Visustella Auto Trigger Skills. However, because of how the plugin works, it defaults to targeting whichever enemy is the lowest index in the troop, and not the last targeted enemy. I've tried using this note tag in my follow up attack to manipulate the target scope to always target the last targeted enemy using this:


<JS Targets>

targets = [];

targets = [$gameTemp.lastActionData(5)];

</JS Targets>

First I attempt to clear the skill's scope in the database with "targets = [];" as the documentation advises. Then I use $gameTemp.lastActionData(5) to change the scope to the last targeted enemy. However this does not seem to work.
I am trying to create a follow up attack that can trigger whenever an ally basic attacks an enemy using Visustella Auto Trigger Skills. However, because of how the plugin works, it defaults to targeting whichever enemy is the lowest index in the troop, and not the last targeted enemy. I've tried using this note tag in my follow up attack to manipulate the target scope to always target the last targeted enemy using this:


<JS Targets>

targets = [];

targets = [$gameTemp.lastActionData(5)];

</JS Targets>

First I attempt to clear the skill's scope in the database with "targets = [];" as the documentation advises. Then I use $gameTemp.lastActionData(5) to change the scope to the last targeted enemy. However this does not seem to work.
The documentation isn't too clear on this, but I'm guessing that it expects the array to contain the actual battler objects, as opposed to an Id/index. $gameTemp.lastActionData(5) will only return the index--not the actual enemy object.

Try this and see if it helps:
Code:
<JS Targets>
  targets = [$gameTroop.members()[$gameTemp.lastActionData(5)]];
</JS Targets>

Just as a heads up, unless you've accounted for it elsewhere, this will probably do some weirdo stuff if the last targeted enemy is already dead. But I don't know how exactly you want the mechanic to work, or if you've already accounted for that possibility elsewhere, so I didn't include anything to deal with that scenario. It's probably better to try this first, to make sure we're on the right track, and then let me know if you need help accounting for that possibility.
I didn't even think of that, makes sense! This is what the result was when I used your code:

1702239459137.png

Original thread: https://forums.rpgmakerweb.com/threads/help-with-js-targets-using-visustella-battlecore-in-rpg-maker-mz.163700/