Add State Y When Enemy Hit Actor with State X

Okay, please bear with me. I know the title sound confusing as hell.


Basically, I want enemy to get applied with state Y when that enemy attack actor with state X. The problem is of course, I don't know how. 


Here's an example:


Actor A use Subzero Shield in battle, there he got applied with the state magic reflection 100% for 5 turns. What I want is whenever an enemy attack Actor A, that enemy will get frozen.


Thanks in advance. 
add in formula damage


b.isStateAffected(x)?a.addState(y)🙁a.atk * 4 - b.def * 2)
add in formula damage


b.isStateAffected(x)?a.addState(y)🙁a.atk * 4 - b.def * 2)

It's not exactly what I want but after a few modifications there and here I managed to make it work. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/add-state-y-when-enemy-hit-actor-with-state-x.64551/