MZ How to force action from last acting enemy?

I've tried to accomplish this with $gameTemp.lastActionData(3) which should be the 'last enemy index to act' in this force action script:

var subject = $gameTemp.lastActionData(3);

subject.forceAction(18, 0);

BattleManager.forceAction(subject);

this.setWaitMode('action');

but it gives me the error: subject.forceAction is not a function, yet if I use something like $gameParty.members()[1] instead it works just fine.

Does anyone know what the problem is or another way to achieve this? Thanks.
var subject = $gameTemp.lastActionData(3);
subject will be a number, not a battler
use the last action data to get the battler, and then use that instead
subject will be a number, not a battler
use the last action data to get the battler, and then use that instead
How would I do that?
the same way you did with
yet if I use something like $gameParty.members()[1] instead it works just fine
you use the index in the array of the battler's unit's members.
Code:
var subject = $gameTroop.members()[$gameTemp.lastActionData(3)];
although i think the action data adds 1 to the index, so you may need to take that back out
the same way you did with

you use the index in the array of the battler's unit's members.
Code:
var subject = $gameTroop.members()[$gameTemp.lastActionData(3)];
although i think the action data adds 1 to the index, so you may need to take that back out
I managed to make it work, thank you.
How'd you "manage to make it work"? Details?

Original thread: https://forums.rpgmakerweb.com/threads/how-to-force-action-from-last-acting-enemy.181464/