Have a state that selections action but target is random.

Is there a way to have a state force an actor to randomly target an enemy with the players selected skill?
This is different from confusion when on your turn you do not have control of your actor.
Ex. You can select your skill like normal, but if it's a single target attack the target will be picked randomly.
You could do this with YEP Target Core.
Thanks for the response.
I didn't think Target Core worked with States?
How would I do it with that plugin?
Yeah, you'd have to do it via script calls rather than notetags. I don't have the time right now to figure out the exact syntax though.
Yeah, you'd have to do it via script calls rather than notetags. I don't have the time right now to figure out the exact syntax though.
Finally got back to looking at this. I can't find the syntax that changes the target of an attack. So far I have the following as testing.
<Custom Initiate Effect>
var action = user.currentAction();
console.log("User command target" + user._commandTarget + "action" + action._targetIndex)
console.log("targets " + JSON.stringify(target));
user._commandTarget = 1;
action._targetIndex = 1
</Custom Initiate Effect>
Code:
  <Custom Target Eval>
  for (var i = 0; i < foes.aliveMembers().length; ++i) {
    var member = foes.aliveMembers()[i];
    if (member.level % 3 === 0) targets.push(member);
  }
  </Custom Target Eval>
Maybe you can use something like this at the Skill. This is at the documentation of Target Core.

If your character is affected by state X, you can make a random variable that randomly chooses an enemy or ally to be the target. Not 100% sure how to do that, I could look in to that.
I'm looking for something I could add to one state instead of adding it to every skill that every actor could use.

Original thread: https://forums.rpgmakerweb.com/threads/have-a-state-that-selections-action-but-target-is-random.155073/