YEP Buffs & States Core: Trying to create a counter attack using a state

Hi everyone,

I have an enemy I'm trying to create that uses a skill which casts a state on itself.

When the state is applied, the enemy is supposed react to a physical attack from any actor and then attack the entire party instantly. Here's what I tried to set up on the state itself:

Code:
<Custom Apply Effect>

user._counterAttack = false;

</Custom Apply Effect>

<Custom React Effect>

if (value > 0 && this.isPhysical()) {

user._counterAttack = true;

}

</Custom React Effect>

<Custom Respond Effect>

if (user._counterAttack){

user.forceActionCast(97, 0);

user._counterAttack = false;

}

</Custom React Effect>

When that wasn't working, I tried to shove everything under Custom Respond Effect (thinking that putting the check for physical damage before the damage eval was the problem), like so:

Code:
<Custom Respond Effect>

if (value > 0 && this.isPhysical()) {

user._counterAttack = true;

}

if (user._counterAttack){

user.forceActionCast(97, 0);

user._counterAttack = false;

}

</Custom Respond Effect>

And, trialing it in battle, when any actor attacks the enemy when the state is applied, skill 97 isn't forced.

I have a funny feeling this is something to do with using "user" (thinking that the enemy with the state applied to it is the "user") and perhaps this needs to change?
I believe custom respond effect is correct, because that is supposed to run after the battler has been selected as a target and after damage has occurred.

Have you tried using Yanfly counter control? You can select the skill to be used when any battler executes a counter attack. Using this plugin, could you not just have the state grant 100% counterattack rate to the battler?
Hi @HumanNinjaToo - I have tried using Custom Counter Control but it will some editing to be made compatible with my game. Once I get the plugin edited for compatibility with the other plugins I use, I will be using this primarily. In the meanwhile, I wanted some more creative ways to creating counter attacks.
What plugin is not compatible w/ CounterControl?
Possibly Ellye's ATB @staf00 , but then again, possibly one of the many custom plugins I've had commissioned.

Original thread: https://forums.rpgmakerweb.com/threads/yep-buffs-states-core-trying-to-create-a-counter-attack-using-a-state.122973/