CounterSpell using Yanfly Action Sequences or Yanfly Buff and States

Goal:


Player puts a counter spell state on all enemies


One Enemy goes to use a spell but instead they get stunned instead


common event plays and removes the counter spell state from all enemies


Was hoping just adding a state check to a setup action in each magic would do the trick but I can't seem to get it to work.


<setup action>


if user.isStateAffected(41)


Animation 64: user


ADD STATE 12: user, show


Common Event: 19


else


end


</setup action>


12 being stun and 41 being the counter spell state.


Any help into making this work would be very welcomed.


Edit***


After much trial and error I figured out a way to do this. Can lock this post if needed.

Original thread: https://forums.rpgmakerweb.com/threads/counterspell-using-yanfly-action-sequences-or-yanfly-buff-and-states.62014/