Force enemy to perform action on specific actor

Hello,
I have the following situation:
-an enemy can perform a scan on one/two of the party's actors (out of a maximum of four) via a decision-making process:
--if only one actor is available/alive, the enemy simply copies that actor's skill via the scan and then performs the skill itself (say a heal if only Natalie is available/alive)
--if at least two are available and not dead, those two are scanned via force-action and the enemy fires a special combination attack based on who those two actors are

My problem is that while everything works if all 4 actors are in the party, in case that an actor is missing, the force-action command (based on the index system the program provides) bugs out and may display the scan on the wrong actor(s); for example if Erik is missing, then Alice and Natalie are scanned when it should be Erik and Alice being scanned respectively (it's only a visual error though).

I use Yanfly Engine Ace - Ace Battle Engine for this.

So question is: is it possible to NOT use indexes for the scan skills, but instead use the actual actor numbers (2-5) rather than indexes 1-4?

Thank you very much for reading and, hopefully, providing an answer.
You could try to replicate the same effect but use script calls. This is untested, taken directly from the code that handles the force action.
Code:
battler = $game_troop.members[enemy_index]
battler.force_action(skill_id, $game_actors[actor_id].index)
BattleManager.force_action(battler)
Fiber.yield while BattleManager.action_forced?
What you need to replace
enemy_index = replace with the enemy index (not id) based on how you put it in the troop
skill_id = replace with the skill id you want the enemy to use
actor_id = replace it with the actor id you want the enemy to target
I tried to script-call this:
Code:
battler = $game_troop.members[1]
battler.force_action(471, $game_actors[2].index)
BattleManager.force_action(battler)
Fiber.yield while BattleManager.action_forced?

Sadly it crashes outright.

Code:
---------------------------
Magical Camp 0.4.7b
---------------------------
Script 'Game_Interpreter' line 1411: NoMethodError occurred.

undefined method `force_action' for nil:NilClass
---------------------------
OK  
---------------------------
Index started from 0, not 1
Right, that was the error. It works perfectly now, thank you very much.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/force-enemy-to-perform-action-on-specific-actor.122273/