MV Restrictions on Counter Attack

I'm using a combination of Victor Engine's Counter Actions and Retaliation Damage to implement "reactions" in battle, like attacking an enemy covered in spikes directly will inflict damage from those spikes on the attacker.

I have it working pretty much as intended, one minor detail is that if a character is hit under the "cannot move" restriction their "reaction" does not occur. With spikes, you might be able to rationalise it like "Well, because they can't move, their attacker can be more careful and hit them while avoiding the spikes" but it would make less sense if say, the enemy was made out of fire.

The bigger issue I ran into was when testing these reactions when the target was under the influence of a "polymorph" state* with the "attack an enemy" restriction. A polymorphed battler will counter their original reaction triggers with a regular attack of their own. I tried to cancel the effects by adding Ex-Parameter Counter Attack at - 1000% as one of the traits on the state, but it has had no affect.

*Yes, that one keeps finding ways to cause problems with every new feature I try to implement.

Edit: For posterity, I was able to prevent polymorphed enemies from getting extra attacks from "reactions" with this custom action counter note:
Code:
<custom action counter: skill 1, skill 29>
  result = BattleManager._targets[0].isStateAffected(13) ? 0 : 100;
</custom action counter>
Skill 29 being the reaction, with a 0% chance of going off if they have the indicated state but 100% if they don't.

I haven't been able to figure out how to get them to work on stunned characters, but that feature isn't strictly necessary and I suspect it's not possible without a custom plugin changing how restrictions function in the base code.

Original thread: https://forums.rpgmakerweb.com/threads/restrictions-on-counter-attack.182416/