Yanfly Battle AI Help

I'm having trouble getting the enemy AI and state checks. I want the AI to check and see if the target is under a specific state, and if not, use a specific move. My AI is setup as follows...

<AI Priority>
Eval user.hp >= Math.floor(user.mhp * 0.9): Attack
Eval user.hp >= Math.floor(user.mhp * 0.8): Cheap Shot
Random 01%: Attack
Eval user.hp >= Math.floor(user.mhp * 0.6): Cheap Shot, Lowest HP%
Random 01%: Attack
State !== State 12: Flashbang Grenade {This is where I want to check to happen but it doesn't work}
State === State 12: Sucker Punch
Always: Cheap Shot
</AI Priority>

How am I supposed to tell the AI to target the enemy (player) or target itself to debuff?
I'll explain as best I can:
If you check for a state the 'normal' way (I.E the way Yanfly does in the video for the Battle A.I Core), it checks only within the scope of the skill. As in, if the skill targets itself or its ally's, then the state check will only be for the enemy/enemy party. Same applies vice versa. This is the only way for an enemy to check if the player/player party has a state or not.

As for checking for itself specifically, use an eval. Like so:
Eval user.isStateAffected(1) +++ Random 30%: Attack, Highest HP%

You can also also combine states to check using the default way. This checks the scope of available targets and counts anyone who doesn't have either state 66 or state 70 as a target:
(State !== State 66 || State !== State 70) +++ Random 30%: Attack, Highest HP%
I'll explain as best I can:
If you check for a state the 'normal' way (I.E the way Yanfly does in the video for the Battle A.I Core), it checks only within the scope of the skill. As in, if the skill targets itself or its ally's, then the state check will only be for the enemy/enemy party. Same applies vice versa. This is the only way for an enemy to check if the player/player party has a state or not.

As for checking for itself specifically, use an eval. Like so:
Eval user.isStateAffected(1) +++ Random 30%: Attack, Highest HP%

You can also also combine states to check using the default way. This checks the scope of available targets and counts anyone who doesn't have either state 66 or state 70 as a target:
(State !== State 66 || State !== State 70) +++ Random 30%: Attack, Highest HP%
Oooh I didn't know I could add a random chance on like that. I figured it was possible but I didn't know how, that by itself helps a lot. Your explanation was pretty simple and I think I understand it but that leave me with a different question.

Using my posted setup, if I wanted the enemy to do "Sucker Punch", all of my characters would need to be afflicted with state 12 otherwise the enemy is just going to keep using "Flashbang Grenade". Actually, I just realized I can swap the order of those two and it should work just fine. Using what you've told me I'm pretty sure I can get the AI doing what I want. Thanks for your help!
'Plugin Releases' is where people who have written plugins they want to share with the community can post them.

Moved to: JavaScript/Plugin Support

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