MV BattleAI detect enemy state and cast buff on himself

Hey!
I'm trying to build combat around stances.
I was trying to make the enemy detect a state and accordingly buff himself.

Player X has state 1, EnemyAI adds himself state 2 to counter.

Maybe someone would help me?
Battle A.I. Core (YEP) - Yanfly.moe Wiki

I would appreciate it if someone would help me with the additional condition.
The enemy ("user" which is enemyAI) has state 2 == use skill X (use only when the enemyAI has state 2, kind of buff himself and then use the skill if he detects the buff).
from the plugin description:

STATE === state x
STATE === state name
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This will detect if the target scope has state x (or state name if you use
that instead). If the target does, that target is added into the pool of
valid targets. Any targets not affected by the state will be ignored.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Example: State === State 5: DeBlind, Highest ATK
State === Knockout: Life, Random

first, the skill must have the desired targeting scope. if what it needs to check is if an actor has something, the scope should be either alive actors or everyone. check the skill scope in the editor, i cant remember the exact names for those conditions.

have a skill (the skill X bellow) that applies your state 2 if said state 1 is present.
that said, try this code on a skill that targets the opposing side:

JavaScript:
State === state 1: skill X, user

where the X above is id of the skill applying the state 2.
OH, yes. It seems it's working. Would you know how to apply an extra random value to use the state, 50% roll? On top of AI randomness.
im not quite sure i understand what you mean... you want a 50% chance of success of applying the state 2?

Original thread: https://forums.rpgmakerweb.com/threads/battleai-detect-enemy-state-and-cast-buff-on-himself.132609/