MV Yanfly Battle AI Core Help?

Hello! I'm using Yanfly Engine Plugins for my project, including Battle AI Core.

So I am trying to set a series of skills for my enemies, I want an elemental mage to check two conditions.
1.) Is there an actor with a weakness to Fire?
2.) Are one of the Mage's allies unaffected by State 204?

If yes, cast EnFire on the ally with the highest ATK.

But I am stumped on how to write this, I'm no good at Javascript yet, but I am trying. I just am unsure how to write it out where it's checking the conditions of two separate users at the same time.

Edited conditions for clarity.
But I am stumped on how to write this, I'm no good at Javascript yet, but I am trying.
There's often no JavaScript necessary, just use the conditions Yanfly wrote for you. However, your condition 2 is kind of weird.

You're saying the mage will only use EnFire if all the enemies have state 204?

So if I understand you correctly,
Code:
Eval !$gameTroop.members().some(enemy => enemy.isStateAffected(204)) +++ Element Fire Weakness: EnFire, Highest ATK
There's often no JavaScript necessary, just use the conditions Yanfly wrote for you. However, your condition 2 is kind of weird.

You're saying the mage will only use EnFire if all the enemies have state 204? You use the word "ally," but that's not a term in RPG Maker so I'm assuming you mean ally of the mage.

So if I understand you correctly,
Code:
Eval !$gameTroop.members().some(enemy => enemy.isStateAffected(204)) +++ Element Fire Weakness: EnFire, Highest ATK
Oh my apologies, I mean if there is an actor who has a weakness to fire, and if there are any allies to the mage unaffected by the state, to cast that state on said ally.

I'll try that code, thank you!

Edit: So the code is kinda working? The mage will cast Enfire on one of their allies, and it is the one with the highest ATK, but it's still triggering even if the first condition isn't met.
Edit: So the code is kinda working?
I don't know how it would, your explanation is very different from what I said my assumption was 😛

The problem is that you're trying to use a skill that targets an enemy but also consider something about a party member (I see where you're referring to Ally in the skill scope, I'm just being very clear).

The plugin instructions say that the conditions will only look at potential targets for the skill when evaluating their conditions.

So you're going to have to replace the Element condition with more JavaScript, otherwise it will evaluate whether any enemies are weak to fire.

You can try this.
Code:
Eval $gameTroop.aliveMembers().some(enemy => !enemy.isStateAffected(204)) && $gameParty.aliveMembers().some(actor => actor.elementRate(X)>1): EnFire, Highest ATK

replace X with the ID of your fire element, no leading zeros.
I don't know how it would, your explanation is very different from what I said my assumption was 😛

The problem is that you're trying to use a skill that targets an enemy but also consider something about a party member (I see where you're referring to Ally in the skill scope, I'm just being very clear).

The plugin instructions say that the conditions will only look at potential targets for the skill when evaluating their conditions.

So you're going to have to replace the Element condition with more JavaScript, otherwise it will evaluate whether any enemies are weak to fire.

You can try this.
Code:
Eval $gameTroop.aliveMembers().some(enemy => !enemy.isStateAffected(204)) && $gameParty.aliveMembers.some(actor => actor.elementRate(X)>1): EnFire, Highest ATK

replace X with the ID of your fire element, no leading zeros.
I really can't tell what it is that's wrong. I tried the code, made sure the Element ID is correct, double checked the state number, made sure the mage had MP to cast the spell, had the skill in their action patterns, double checked the spelling, but the mage won't cast the spell on any troop member, and skips down the list of priorities.

Here's what I have typed in the enemy notebox:
Code:
<Sideview Battler: 3_Actor1_5>
<Default Row: 3>
<AI Priority>
Eval $gameTroop.aliveMembers().some(enemy => !enemy.isStateAffected(204)) && $gameParty.aliveMembers.some(actor => actor.elementRate(2)>1): EnFire, Highest ATK
Always: Skill 496, Lowest HP%
</AI Priority>
Sorry, I'm not sure what else to try. That code should return true if at least one enemy does not have state 204, and at least one actor has a State Rate over 100% for fire.

You can try hitting F8 during the game, going to the Console tab, and pasting in the code portion of the condition to see if it returns true. If it says false, then the problem is with your setup - one of the parts of your situation isn't correct. If it says true and it's not working with the Battle AI plugin, there could be a bug in there.
Sorry, I'm not sure what else to try. That code should return true if at least one enemy does not have state 204, and at least one actor has a State Rate over 100% for fire.

You can try hitting F8 during the game, going to the Console tab, and pasting in the code portion of the condition to see if it returns true. If it says false, then the problem is with your setup - one of the parts of your situation isn't correct. If it says true and it's not working with the Battle AI plugin, there could be a bug in there.
So I received back an error code, it's saying $gameParty.aliveMembers.some is not a function

Edit: So I figured it out! It was missing $gameParty.aliveMembers.some was missing a () afterMembers. It works now! Thank you very much for all your help!
Shoot, that was my fault. Sorry for the typo.
Shoot, that was my fault. Sorry for the typo.
Nah you're all good, those things can be so tricky sometimes, thank you very much for all the help though I appreciate it!
Nah you're all good, those things can be so tricky sometimes, thank you very much for all the help though I appreciate it!
Does it work with the missing brackets added?
Does it work with the missing brackets added?
Yes it works perfect!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-battle-ai-core-help.153198/