MV Targetting help using YEP_TargetCore

I have a good idea that Target Core is the way to go for what I want, but I have no clue how to implement it. It's a rather specific targeting that I'd like to do.

So, I have a skill that attacks all the enemies in a troop, one at a time. That part is easy... What I want to have happen is to randomize that sequence or target.

So, when you use the tag <Target All Foes> with the skill scope of 1 Enemy, you get to pick the enemy you want to attack and then the skill selects all the other troop members as targets. So the sequence would go something like targets 1, 2, 3, 4. It'll do this sequence every time. If you attack target 4 then the sequence would target 4, 1, 2, 3, and so on.

I would like to randomize that sequence but keep it attacking all the enemies. So something like attack target 1, 3, 2, 4 or target 2, 3, 1, 4 and so on... It's random but it still attacks all the foes in the list.

Is this even possible?
I would say yes using the lunatic mode notetag <Custom Target Eval>:

Code:
<Custom Target Eval>
targets.push(target);
targets = targets.concat(foes.aliveMembers().filter(m => m !== target).sort((a, b) => Math.random() - Math.random()));
</Custom Target Eval>

or with more explanation

<Custom Target Eval>
targets.push(target); // Add the selected target
// From all alive members of enemy unit, get all that are not the selected target
var foesButTarget = foes.aliveMembers().filter(m => m !== target);
// And sort them in some randomized order, this is just an example other random logic could be taken.
var randomFoes = foesButTarget.sort((a, b) => Math.random() - Math.random());
// Add the randomly sorted array to the targets
target = targets.concat(randomFoes);
</Custom Target Eval>

And also custom target text for BattleEngine Core can be added, too:
Code:
<Custom Target Text>
text = 'The selected enemy and all alive members of the enemy unit in random order.'
</Custom Target Text>
Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/targetting-help-using-yep_targetcore.170541/