Skills targeting friend or foe

A lot of skills in this game fall into both of these categories:

  1. Can target friend or foe
  2. Hit multiple targets at once

… which is more complicated that it seems. By default the engine lacks support for the player changing targets between friends and foes.

Attempt one

At first I used Yami’s Invert Target. It’s a buggy mess. A community-created compatibility patch fixed it for a while, but eventually it started to give me errors again.

Yanfly to the rescue

I recently switched to Yanfly’s Selection Control. It’s a solid plugin, compatible with Yanfly’s other works. But it still doesn’t support both of the conditions I mentioned. You can either have a skill toggle between friend and foe, OR have it hit multiple targets.

I compromised by writing this block of code for each of my multi-target skills:

for (var i = 0; i < target.friendsUnit().aliveMembers().length; ++i) {
 var member = target.friendsUnit().aliveMembers()[i];
 targets.push(member);
}

After the player selects a target, all of the target’s allies are added into the scope of the attack.

It’s still not the most elegant solution – the selection cursor only appears over one target at a time – but it’s stable and it works.