MZ creates event that whenever enemy lands a critical hit?

Hello~ i am trying to creates event that whenever enemy lands a critical hit.
i aws thinking, if enemy npc lands a critical with any skill, like normal attack or spell, the switch with turn on, and then there's parallel running, when it picks up the siwtch is on, it will start an event.

i have tried visustella's
Switch: Critical:
- Turns switch ON if the action performs a critical hit.

but regardless who lands a critical hit, the switch still remains off.
is there any other way? thx!
I can't recall a more practical way to do this other than using the moment the text is inserted into the battle message queue, so sorry if the code looks amateurish.

I also included a common event call, maybe that will make things easier, I couldn't capture enemy ID or target member.

Plugin name: EnemyCriticalAttackCallEvent.js

JavaScript:
/*:
 * @target MZ
 * @plugindesc Activates a switch or call a Common Event if the enemy inflicts a critical hit
 * @author <None>
 *
 * @help EnemyCriticalAttackCallEvent.js
 *
 * Switch ID: To turn this off, select the "None" option.
 *
 * Common Event: To turn this off, select the "None" option.
 *
 * @param switchid
 * @text Switch ID
 * @desc Sets ID
 * @type switch
 * @default 0
 *
 * @param commonevent
 * @text Common Event
 * @desc Sets ID
 * @type common_event
 * @default 0
 *
 */

(() => {
    const params = PluginManager.parameters('EnemyCriticalAttackCallEvent');
    const sw = Number(params["switchid"]) || 0;
    const ce = Number(params["commonevent"]) || 0;
    Window_BattleLog.prototype.displayCritical = function(target) {
        if (target.result().critical) {
            if (target.isActor()) {
                this.push("addText", TextManager.criticalToActor);
                if (sw > 0) {
                    $gameSwitches.setValue(sw, true);
                }
                if (ce > 0) {
                    $gameTemp.reserveCommonEvent(ce);
                }
            } else {
                this.push("addText", TextManager.criticalToEnemy);
            }
        }
    };
})();

No credit should be given to me, as this is merely an overlay of an already existing function.

Original thread: https://forums.rpgmakerweb.com/threads/creates-event-that-whenever-enemy-lands-a-critical-hit.181000/