MV Another question regarding Yanfly Battle AI Core

Hi!

Using the battle AI core, I was wondering if you guys can help me with a check. An enemy of my game uses a spell like Esuna from FInal Fantasy. I want that the spell in only used if an alive troop member is effected by one or more states. I guess an Eval here is necessary...

Thanks!
There is already a condition for this very thing in the plugin...

State === state x
or
State !== state x

You do something like this :

State === state x +++ State === state x +++ State === state x:

should do what you want.
There is already a condition for this very thing in the plugin...

State === state x
or
State !== state x

You do something like this :

State === state x +++ State === state x +++ State === state x:

should do what you want.
Yeah, but in that case the spell is used only if the target is affected by all those states at once. i mean, with those conditions you are using an "and" I need an "or".
I'm not 100% sure, nut I think you then replace +++ with ||

I didn't test it and my javascript knowledge is limited, but try it out.
I'm not 100% sure, nut I think you then replace +++ with ||

I didn't test it and my javascript knowledge is limited, but try it out.
That is not an option for the standard plugin conditions. An Eval is necessary here, but like you I'm not that good in JS, I'm sure that is a pretty easy check though...
Have you tried to make several conditions checking for each state?

Like this:
State === state x:
State === state x:
State === state x:

Put the AI Priority to 100... I do and the enemy follows the conditions pretty well, for the most part
That is not an option for the standard plugin conditions. An Eval is necessary here, but like you I'm not that good in JS, I'm sure that is a pretty easy check though...
How about State === state x || state x || state x
EDIT: this thread can be closed now, I have solved the issue.
If I understand correctly, it seems it'd be easier to use YEP_X_SelectionControl to give the Skill a custom target condition.

You could give the skill a condition so that it can only be used on a target with whatever States you decide.

JavaScript:
<Custom Select Condition>
 condition = target.isStateAffected(6) || target.isStateAffected(9)
</Custom Select Condition>
EDIT: this thread can be closed now, I have solved the issue.
For the sake of other people who might want to know how it's solved: the code that BlackGoldSaw could be pasted into an eval condition in the Battle AI Core.

This is also a good use scenario for Yanfly's State Categories. You might give all the removable states the notetag
<Category: debuff>

then the skill has the AI condition
Code:
eval: target.isStateCategoryAffected("debuff")
For the sake of other people who might want to know how it's solved: the code that BlackGoldSaw could be pasted into an eval condition in the Battle AI Core.

Tbh my "solution" is not that great. I just put 3 conditions one after another, the thing is working but its a bit redundant and the AI is doing 3 condition checks instead of 1...
Ah. Then I'd suggest one of the above solutions, instead.
Ah. Then I'd suggest one of the above solutions, instead.
Sorry for being so annoying, but using BlackGoldSaw code in an eval is not working. Can I use that code without extra plugins? I'm not using target core or selection control, only battle AI core.
Okay. Bizarrely, the eval condition gives you no way to look at the potential targets. So open the plugin in a text editor, highlight lines 1347 - 1353, and delete them. Replace with this:

Code:
    var group = this.getActionGroup();
    if (condition.includes("target"))
    {
        let target;
        for (let i = 0; i < group.length; i++)
        {
            if (!group[i])
                continue;
            
            target = group[i];
            try 
            {
                if (!eval(condition))
                    group.splice(i, 1);
            } 
            catch (e) 
            {
                Yanfly.Util.displayError(e, condition, 'A.I. EVAL ERROR');
                return false;
            }
        }
        if (group.length > 1)
        {
            this.setProperTarget(group);
            return true;
        }
        else
            return false;
    }    
    try 
    {
        if (!eval(condition))
            return false;
    }
    catch (e) 
    {
        Yanfly.Util.displayError(e, condition, 'A.I. EVAL ERROR');
        return false;
    }

Right-click the plugin in your plugin manager, reload, then save your project and test in a new play test.

That should make the code above work correctly. I have not tested this, let me know if you get any errors (press F8 and go to the Console tab to provide full error traces).

The reason I'm leery of @BlackGoldSaw's suggestion using Selection is I'm not sure the AI core checks for the skill to have valid targets. My first suspicion would be that it meets your AI conditions, says you're using this skill, then it wastes a turn if the skill can't be used.
Thanks @ATT_Turan, its working fine now. No crashes here for the moment.

​

Original thread: https://forums.rpgmakerweb.com/threads/another-question-regarding-yanfly-battle-ai-core.171097/