MV Skill - Target Conditions

Hi all.

I want to make a skill that only aim one enemy which has a certain state.
But if the enemy with the state is already dead, and there are no potential enemies, it should aim itself instead.

So, the skill checks out if one of the targets have the state, if not it targets the user.

I have used SelectionControl by Yanfly to create the target condition for the skill, to aim only the enemy with the state.
The Problem is, I don't know how to make the skill target the user, if the enemy with the state is dead.

(btw. this will be an enemy skill and the targets are the actors)

Is it possible to do this at all? Maybe with Custom Select Conditions?

THX
You could try:
Code:
<Custom Select Condition>
if (target.isStateAffected(stateID) || target==user)
    condition=true;
else
    condition=false;
</Custom Select Condition>
where "stateID" is the ID they need to be affected with.

However, I'm not sure it will work because I don't see a way to set the scope to allow an enemy to target an ally as well as an enemy.
Hey, thx for the answer @ATT_Turan !
I've tried the code out. Unfortunately it doesn't work correctly.
It hits the enemy with the state, but if the mentioned enemy is dead, it just do nothing.

Btw. does this (target.isStateAffected(stateID) || target==user) mean, that the target is the user and the target the same time?
Hey, thx for the answer @ATT_Turan !
I've tried the code out. Unfortunately it doesn't work correctly.
It hits the enemy with the state, but if the mentioned enemy is dead, it just do nothing.

Btw. does this (target.isStateAffected(stateID) || target==user) mean, that the target is the user and the target the same time?
|| is "or", so read it as "if the target is affected by the state with ID X OR if the target is the user of the skill"
It hits the enemy with the state, but if the mentioned enemy is dead, it just do nothing.
That's what I thought. That's because the scope of the skill can only be set to some number of enemies or some number of allies, and the Yanfly plugins don't provide any way to change that - so it will never consider allies and enemies as targets for the same skill.

You might be able to code it in with a possibly convoluted Action Sequence.

Original thread: https://forums.rpgmakerweb.com/threads/skill-target-conditions.137739/