Apply State's on crit Attack

Hi all,

I am trying to give my skills some special abilities.
I use Yanfly's Critical Control and Skill Mastery Plugin.

My goal is it that certain skills will get better with higher lvl.

There for i use the code from Yanfly to enable states on the target or the user:

Code:
<After Eval>
if (user.skillMasteryLevel(item.id) >= 5) {
 target.addState(10);
 target.removeState(9);
}
<After Eval>

I use this as code from Yanfly.

What I want now, is to check before this if clause, if the hit is a critical hit. Only if it crits, it will enable the state.
But I have no idea how to write this as a code.

Anyone can help me please?

It would be nice to get codes for some other actions too:

1) If crit, User gets Healed by 10% of his Max HP
2) If crit, Party gets healed by 10% of user's Max HP
3) If crit, Party gains a certain state
4) If crit, User or Party gains MP

Would be very nice if someone could tell me if this is possible, and if yes, how I need to write it 🙂

Best Regards,

Nebu

Original thread: https://forums.rpgmakerweb.com/threads/apply-states-on-crit-attack.108219/