Retalitory strikes

I am trying to figure out how I could go about making it so when under a certain State, an Actor will attack any enemy that does a Hit Type: Physical Attack against another Actor.

Does anyone know of such a method and how to code it out?

Thank you.
By my reasoning, you need VisuStella's Battle Core, Skills and States Core, and two states.

One of them is a passive state, via Skills and States Core, and goes on the entire party. If you don't want the actor to counterattack for themself, don't put the passive on them. The other is a regular state that goes on the specific actor.

Will it be always a specific actor that can have this state, or is it potentially anyone in your party? I'll give you the code for a specific actor, and if more than one person can get it you can request an edit.

In the passive state, put the notetag:
Code:
<JS Post-Apply as Target>
if (this.isPhysical() && value>0 && $gameParty.battleMembers().includes($gameActors.actor(X)) && $gameActors.actor(X).isStateAffected(Y))
{
    $gameActors.actor(X).forceAction(Z, this.subject().index);
    BattleManager.forceAction($gameActors.actor(X));
}
</JS Post-Apply as Target>

Where all instances of X are the ID of the actor who can get this state. Y is the ID of the state. Z is the ID of the skill you want to use as the counterattack.
EDIT: Never mind my post. Didn't catch a bit of specifics about what OP wanted.
Thank you for the write up, I will look it over in the next few days, tell you if I can get it to work, still very new to all of this. 😀

Original thread: https://forums.rpgmakerweb.com/threads/retalitory-strikes.149951/