[YEP_Target Core] Problem with a Custom Target Eval

Hello!
I'm making a skill for my project where the user, before casting it, can choose if he wants it to target the enemies or his allies. For that i made this code, using both "YEP_Target Core" and "YEP_ActSequencePack":


Code:
<setup action>
display action
wait: 40
clear battle log
common event: 5
</setup action>
<follow action>
</follow action>
<target action>
change variable 3 = 0
change variable 3 = Math.floor((user._level+1) / 2) + Math.randomInt(Math.floor((user._level+1) / 2) * 5 + 1)
action effect
</target action>
<whole action>
</whole action>
<finish action>
change variable 3 = 0
change variable 17 = 0
</finish action>

<Custom Target Eval>
var member = 0;
if ($gameVariables.value(17) == 1)
{
   for(var i = 0; i < allies.aliveMembers().length; ++i)
   {
     member = allies.aliveMembers()[i];
     targets.push(member);
   }
}
else if ($gameVariables.value(17) == 2)
{
   for(var i = 0; i < foes.aliveMembers().length; ++i)
   {
     member = foes.aliveMembers()[i];
     targets.push(member);
   }
}
</Custom Target Eval>

So, what should this do?

1- Common Event 5 is called, and it's there where the user decides to target either enemies or allies.
The Common Event is a simple "Select Choice", and based on the choice the value of Variabile 17 will be changed to either 1 or 2;

2- The Custom Target Eval will look at Variable 17's value, and if it's 1 it will change the target to your allies, while if it's 2 it will change to the opponents;

3- The attack lands on the chosen target.


The problem is that no one receives the attack. I tried targeting both enemies and allies, but nothing.
Is there something that i'm doing wrong? Thanks in advance!
I believe the issue here is that the target eval is parsed before the action sequence begins. Target evals happen when the skill is selected, and even the <Setup Action> of the skill happens after the skill has already been selected, and a target has been chosen.

For this skill, you're probably going to want a different Yanfly plugin - Selection Control - which allows you to set skills as being usable on allies and enemies via note tags. Target core was never designed for this sort of thing, selection control is the way to go.
I believe the issue here is that the target eval is parsed before the action sequence begins. Target evals happen when the skill is selected, and even the <Setup Action> of the skill happens after the skill has already been selected, and a target has been chosen.

For this skill, you're probably going to want a different Yanfly plugin - Selection Control - which allows you to set skills as being usable on allies and enemies via note tags. Target core was never designed for this sort of thing, selection control is the way to go.
I see ^^". I'll check if with Selection Control works.
Thank you!

EDIT: I thought that the tag <Actor or Enemy Select> would've been perfect for this, but sadly it automatically changes the skill to select an actor/enemy at a time, when what i would need is to select all actors/enemies at a time. Any idea how i could do that?
I think you have to add this:

<Single or Multiple Select>

and you have to have the skill set, in the database, to all allies or all enemies to allow for the multiple select
I think you have to add this:

<Single or Multiple Select>

and you have to have the skill set, in the database, to all allies or all enemies to allow for the multiple select
It sort of works, but it makes me able to also target a single enemy/actor, which i don't want.
Did you try just the <Actor or Enemy select> and then set the skill to target all enemies or all allies? Maybe that would work
Did you try just the <Actor or Enemy select> and then set the skill to target all enemies or all allies? Maybe that would work
Yeah, but the tag changes it by default to a single target selection :/
Idk then, there's probably a way to do this with lunatic code, but I'm not sure off the top of my head. I know you can set conditions, but I'm not sure that works the way you want it to happen.
Good news, a friend of mine who's more experienced than me helped me out!
I'm leaving his solution here for the people that could have the same problem:

Code:
<setup action>
common event: x
display action
perform start
</setup action>

<whole action>
if $gameVariables.value(x) == 1
   action animation: friends
   action effect: friends
else if $gameVariables.value(x) == 2
   action animation: opponents
   action effect: opponents
end
</whole action>

<target action>
if $gameVariables.value(x) < 1 || $gameVariables.value(x) > 2
   action animation: target
   action effect: target
</target action>

<finish action>
move user: home, 20
face user: forward
clear battle log
</finish action>

The common event should be a "Choose option", where depending of your choice the Variable will be set to either 1 or 2.
It always seems so simple once you get the answer 😀
It always seems so simple once you get the answer 😀
Very true 😅
I think you have to add this:

<Single or Multiple Select>

and you have to have the skill set, in the database, to all allies or all enemies to allow for the multiple select

Had a same problem, your advice helped me. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/yep_target-core-problem-with-a-custom-target-eval.120720/