Force Action: Quick question using the script version

Would anyone mind showing me how is it called? I want to use the script version of "Force Action" as I want to call the command with variables.
I've tried:

$game_actors[0].force_action(1,0)/ $game_party[0].force_action(1,0)
for actors and
$game_troop.members[0].force_action(1,0)
for enemies, but it doesn't seem to work.

What am I missing?
Game_Battler, line 335.

Code:
def force_action(skill_id, target_index)
    clear_actions
    action = Game_Action.new(self, true)
    action.set_skill(skill_id)
    if target_index == -2
      action.target_index = last_target_index
    elsif target_index == -1
      action.decide_random_target
    else
      action.target_index = target_index
    end
    @actions.push(action)
  end
Game_Battler, line 335.

Code:
def force_action(skill_id, target_index)
    clear_actions
    action = Game_Action.new(self, true)
    action.set_skill(skill_id)
    if target_index == -2
      action.target_index = last_target_index
    elsif target_index == -1
      action.decide_random_target
    else
      action.target_index = target_index
    end
    @actions.push(action)
  end

Thank you for clarifying, but I'd like to know how to execute it.
For example, I've also tried
$game_troop.members[0].force_action(4,-1)
$game_party.members[0].force_action(4,-1)
to force both parties to use skill 4 on a random target but sadly this does nothing.

Battle commands are also not listed in the script call collection so sadly I'm at a loss. If anyone could demonstrate how it works it would be much appreciated.
it's been a while since I worked with the default system, but I believe forced actions are processed at the end of the turn.
do a broad search in the code, for "force_action", you'll get 4 or 5 results, one of them will be the Battle Manager, backtrack from there.
it's been a while since I worked with the default system, but I believe forced actions are processed at the end of the turn.
do a broad search in the code, for "force_action", you'll get 4 or 5 results, one of them will be the Battle Manager, backtrack from there.
Looking up the code only yields the use of the code sadly.
upload_2019-1-26_17-11-32.png

In any case, here's what I've been working with. "Force Action" (in purple) runs the instance it is called. So no issues there.

However,
$game_troop.members[0].force_action(4,-1)
$game_party.members[0].force_action(4,-1)
Don't do anything, I'd like to rewire them so they work identically to the Force Action Event Command.
Looking up the code only yields the use of the code sadly.

how did *I* find the relevant function, then?

nuevo-1.jpg


search the code!
*the code*, not the help file.

Original thread: https://forums.rpgmakerweb.com/threads/force-action-quick-question-using-the-script-version.104899/