Attack Random Enemy OR Ally

Hey guys!
I'm currently making an attack that hits really hard! The downside to using it is that it targets a random enemy OR ally... But I'm having trouble figuring out how to do that.

I also have Yanfly's Battle Engine Core and Action Sequence Packs 1, 2 and 3. I just haven't figured out how to target a random enemy or ally with the base RPG Maker or Action Sequence Pack. Any solutions?
You could have the skill apply an "invisible" state that forces the user to attack randomly before an attack is launched. I'm not too versed in the Action Sequences, but that's a start.
I'd advise looking at Yanfly's Target Core, specifically this notetag:

<Target: x Random Any>
If you'd prefer to not use plugins, make it so a dummy skill the player can select activates a common event, then have that common event make the actor use the actual skill on a random target, via the third page's Force Action command, you can select "Random" from the target drop down menu.

I don't know for sure if this is truly random though tbh.
You could have the skill apply an "invisible" state that forces the user to attack randomly before an attack is launched. I'm not too versed in the Action Sequences, but that's a start.

I hadn't thought of that, but unfortunately, it doesn't work. The skill's "Scope" overrides the state that the character receives through Action Sequences...

I'd advise looking at Yanfly's Target Core, specifically this notetag:

<Target: x Random Any>

This worked great! Unfortunately, it also targets the user, which is what I do not want... Any way to exclude the user of the skill?

If you'd prefer to not use plugins, make it so a dummy skill the player can select activates a common event, then have that common event make the actor use the actual skill on a random target, via the third page's Force Action command, you can select "Random" from the target drop down menu.

I don't know for sure if this is truly random though tbh.
Would that not be the same as using the Target Core plugin? I feel like this would also make the user a target.

EDIT: Also, any monster/actor in my game is going to be able to use this skill. Where it asks for the "Subject" to use the skill, I'd have to just pick the actor OR make 300+ common events for each monster/actor that can use the skill, if I'm seeing this correctly.
If you want enemies to function like this, just make 2 copies of the spell where one targets random allies and the other targets random enemies, then give them equal priority.
This worked great! Unfortunately, it also targets the user, which is what I do not want... Any way to exclude the user of the skill?

I don't see an option in the plugin help but you could just use a custom js eval instead:

Code:
<Custom Target Eval>
choices = foes.aliveMembers();
for (var i = 0; i < allies.aliveMembers().length; i++) {
   member = allies.aliveMembers()[i];
   if (a !== member) {
      choices.push(member);
   }
}
var t = Math.randomInt(choices.length);
targets.push(choices[t]);
</Custom Target Eval>

This should make choices equal to all alive enemies then uses a loop to add every ally that isn't the user. It will then pick a random member of the choices group and make that the target.

EDIT: Original eval would have targeted everyone but the user, not one random target. Updated.
If you want enemies to function like this, just make 2 copies of the spell where one targets random allies and the other targets random enemies, then give them equal priority.
That's genius.

Original thread: https://forums.rpgmakerweb.com/threads/attack-random-enemy-or-ally.107863/