Detect the interaction with the moving event from behind.

Hello!
I am trying to set up something like backstab system, when you can interact from the enemy event from behind and get the outcome A (ambush or insta-kill). In all other cases when collide with the event you should get the outcome B (battle start or game over).

But there is the issue with interacting with the event from behind. Cause the event always auto turn to player when you interact with it before(!) triggering any content of the event. I thought it would be possible to branch conditions within an event, depending on the side of the interaction.

It works correctly with the direction fix, but I want enemies to move randomly with rotation.
Paste this into a text editor, save as a *.js file, and include in your project as a plugin:
Code:
Game_Event.prototype.lock = function() {
    if (!this._locked && !$dataMap.events[this.eventId()].meta.noturn) {
        this._prelockDirection = this.direction();
        this.turnTowardPlayer();
        this._locked = true;
    }
};

You should be able to add the <noturn> notetag to an event and it won't face the player when activated.
Thanks! Worked like a charm

Original thread: https://forums.rpgmakerweb.com/threads/detect-the-interaction-with-the-moving-event-from-behind.156831/