Piercing skill

I'm in the making of a skill that pierces its target and hits a random target in the next row using yanfly's row formation and target core plugins.

Yanfly did make a video on how to make a "Piercing Arrow" ability, which did do what i wanted it to, however all targets are chosen randomly, meaning that if there are several people in the first row, you won't hit your target consistently.

I've tried tinkering with it, and can't find a way to make it target it's original target.

Here's the code he used

<Custom Target Eval>
var row = target.row();
var group = target.friendsUnit();
for (var i = row; i <= Yanfly.Param.RowMaximum; ++i) {
var members = group.rowAliveMembers(i);
if (members.length > 0) {
targets.push(members[Math.floor(Math.random() * members.length)]);
}
}
</Custom Target Eval>
Good point. The notetag code is taking a random enemy from each row, including the row that the target is in.

I believe that "target" is a keyword in Yanfly's Skill Core (etc.) notetags which refers to the battler object being targeted. If that's the case, I believe you could modify the notetag to:

<Custom Target Eval>
var row = target.row();
var group = target.friendsUnit();
targets.push(target);
for (var i = row + 1; i <= Yanfly.Param.RowMaximum; ++i) {
var members = group.rowAliveMembers(i);
if (members.length > 0) {
targets.push(members[Math.floor(Math.random() * members.length)]);
}
}
</Custom Target Eval>

and have the same effect, except always hitting the target you selected (and never hitting another enemy in that same row). I haven't tried it myself, but definitely let me know with an @Wavelength if it throws an error or doesn't work for you.
@Wavelength it worked like a charm! Thanks for the help, and best of luck in the future for you.
Glad it worked for you 🙂

Original thread: https://forums.rpgmakerweb.com/threads/piercing-skill.111480/