Force action script call

Does anyone know how to properly use a force action script command? I tried to use this but it doesn't work.

var subject = $gameTroop.members()[1];

subject.forceAction(18, 0);

BattleManager.forceAction(subject);

this.setWaitMode('action');

I know it's probably incompetence on my part, but I can't for the life of me figure out what's wrong with it.

For context, my goal was to force party members to hurt themselves with elemental damage. When I try too use the code above, it does nothing.
If you're entering this in what appears to be a Script event command, why aren't you just using the regular Force Action event command?

Aside from that, your description:
my goal was to force party members to hurt themselves with elemental damage.

doesn't match what your code is doing. You're telling the second enemy (index 1) to use this on the first enemy (index 0).

Thus, there's room for failure there if there aren't actually two enemies in the troop, or if the second enemy in the troop has been killed (or the first has), etc.

So I'd suggest you double check whether the regular event command can serve your purposes, and if not you need to show more context with the complete skill/event that this is happening in, and what precisely you want to be happening.
If you're entering this in what appears to be a Script event command, why aren't you just using the regular Force Action event command?

Aside from that, your description:


doesn't match what your code is doing. You're telling the second enemy (index 1) to use this on the first enemy (index 0).

Thus, there's room for failure there if there aren't actually two enemies in the troop, or if the second enemy in the troop has been killed (or the first has), etc.

So I'd suggest you double check whether the regular event command can serve your purposes, and if not you need to show more context with the complete skill/event that this is happening in, and what precisely you want to be happening.
To answer your first question, The Force action command uses the Actor's ID, not just the party member in that position; my game has a lot of party members, so scripting all that would take too long.

aside from that I'll try to fix it.
To answer your first question, The Force action command uses the Actor's ID, not just the party member in that position; my game has a lot of party members, so scripting all that would take too long.
...then your code is completely wrong for what you want it to do, because you're referencing the $gameTroop. The troop (as seen in your database) is the enemies. You're not making any actors do anything.

The actors are in the $gameParty.
...then your code is completely wrong for what you want it to do, because you're referencing the $gameTroop. The troop (as seen in your database) is the enemies. You're not making any actors do anything.

The actors are in the $gameParty.
Yeah i see that... thanks
Yeah i see that... thanks
Yeah im brain dead, everything worked

Original thread: https://forums.rpgmakerweb.com/threads/force-action-script-call.173029/