Script: if critical hit

Hey guys,

I would like to make a condition in a script that something happens whenever an actor lands a critical hit.
How would you do this?
Where do you wanna put that if condition?
I would like to have an animation played everytime an actor lands a critical hit, but BEFORE the actor does that specific hit.

VE's Cast Animation does that, but it shows the animation always. Now I want to change this plugin in a way that it only happens for critical hits.

Original thread: https://forums.rpgmakerweb.com/threads/script-if-critical-hit.83984/