Chance Random Targeting - Yanfly's Buffs & State Core

Link to Yanfly's Plugin: http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/

I'm trying to create a state that confuses the victim and has a chance of randomly targeting an ally or foe.
So, for example:

Roy uses a Fire Spell and selects Enemy A.
There is a 50% chance of avoiding the confusion effect.

Roy is unlucky and becomes confused.
He randomly casts the Fire Spell at Enemy A, Enemy B, Enemy C, himself, Ally B or Ally C.

Is this possible?

I know it would need to run at the action's start hence <Custom Action Start Effect>

Code:
<Custom Action Start Effect>
var confuseRate = 0.50;
if (Math.random() < confuseRate) {
 // Insert code
}
</Custom Action Start Effect>

And well, I know this piece of code which causes the user to consume the skill's resources (This can be utilized for Paralysis-based Status Ailments):

Code:
  user.useItem(user.currentAction().item());

Is there something like user.currentAction(). "determine target here" ?

What I am currently thinking of trying is using:

Code:
subject.forceAction(skillId, $gameParty.battleMembers().indexOf(X));

subject.forceAction(skillId, $gameTroop.members().indexOf(X));

The confusion state would obtain the current skill's ID and execute a Forced Action using that skill ID. It would randomly choose between targeting the party and or enemy troop. Then it would target a random (applicable) index.

I'm not sure if that would be efficient though.
I'd also have to include conditions for when skills with User or All scopes are used.
http://yanfly.moe/2017/01/11/tips-tricks-confusion-pokemon-rpg-maker-mv/

That link is to Yanfly's Confusion Tips & Tricks page. It won't answer everything, but it's a start.
@shockra that's where part of the code I linked came from, lol.
I left out the part that specifies a specific skill to be used.

Original thread: https://forums.rpgmakerweb.com/threads/chance-random-targeting-yanflys-buffs-state-core.78065/