Sneak Attack on Events with Yanfly Event Chase Plugin

So, I ran into a little issue some time back. I put it on the backburner while I worked on other aspects of my game, but I've come right back around to the issue. I am using on map monster encounter events. I have currently programmed these events with Yanfly's EventChasePlayer plugin to, well, chase the player when the actors are spotted. With the Event Touch trigger, combat is initiated. Pretty basic stuff. No problem.

Now, here's the issue. Awhile back Hiddeone posted a great piece on spicing up On-Map Encounters with pre-emptive strikes on the enemy if the actor could get behind them. (Sorry I cannot find the page right now). I followed the directions, tried it out annnnd...the pre-emptive strike was working even when the enemy had clearly touched my actors first...against the enemy. I figured it just did not work with Yanfly's event chase plugin.

So, here I am. Again. Beseeching the community: how can I create an on map event that will follow a move route on map, chase the player when spotted, return to their route after, gain advantage on the actor if the actor is hit from behind, and the actors gain pre-emptive strike on the monsters if they are hit from behind?

Currently, with Yanfly's Event Chase plugin, I can already have the move route, event chase and return done. Am I able to event it for surprise/pre-emptive combat for monster/actors? Do I need Yanfly's Event Chase Stealth for this in combination with Yanfly's Force Advantage plugin? Or do I need to abandon the yanfly plugin for another path? Does anyone have any experience/knowledge with this?
I think the most likely cause for the player advantage at inappropriate times is an error in your event setup. So could you please post a screenshot of that so we can double check that?
Once again, thank you for responding. I have two screenshots of the on map encounter that I coded months back following Hiddenone's Quick Time Event/Encounters (?) and the Common Event itself. Let me know if you need to view anything else.

EDIT: I found the tutorial Hiddeone wrote that I was attempting to copy and mess into this: Eventing a Preemptive Strike QTE.

QTE.PNGQTE2.PNGQTE3.PNG

QTE4.PNG
Well in your eventing there is no notion of "if the player attacks from behind, they get a preemptive strike, but if the monsters get them from behind they do". It's just "When the monster touches the player, play a quick time event. If the player manages to press ok in time, they get a preemptive strike". So that's why you observe the behavior you do. Even hiddenone's tutorial goes one step further and randomly fires negative quick time events. Because otherwise the player can just spam ok and get a preemptive strike every time.
The thing is, I could have sworn I actually saw a tutorial that did not rely on quick time events, but rather the direction the event and the player were looking. But I couldn't find it to point you in the right direction.

The basic idea was to get the direction the event and the player were facing (under control variable -> game data) and compare them. If both are looking in the same direction one of them must have gotten the other from behind. Then you could use the player's and event's coordinates to determine which one actually got the upper hand. For example if both player and event are facing down, the one with the smaller Y coordinate would have been the one to get the advantage.

I hope that is enough to get you started.
I think the plugin you may actually want to use is Yanfly's Event Encounter Aid. It creates a group of script calls that should easily be able to determine if the player is facing the event's front, back or side, or if the event is facing the player's front, back or side when triggered, like what eomereolsson was getting at above. It looks like there are also event notetags to prevent the event from automatically turning when triggered (potentially throwing off the script call results) and to allow follower contact to also trigger the event.

I have not personally implemented it into my visible encounter system yet, so I don't have any pointers, but it looks like a relatively simple plugin for Yanfly, so hopefully there aren't any weird quirks to iron out, and it is basically just a collection of true/false script calls, so it should be pretty straightforward implementing it into what you have already built.
Thanks @eomereolsson and @Matrien. I just discovered Yanfly's Event Encounter Aid before seeing your post and just shook my head. Exactly what I was looking for, unfortunately I require Yanfly's ForcedAdvantage plugin to do what I want. Which, apparently, the itch page was changed some time ago where I can no longer buy individual plugins. (Sigh) Talked to my hubby today about just purchasing the entire set for the $30. There are other plugins I have been wanting anyway, and might as well just bit the bullet. Wish I had downloaded everything ages ago. I have quite a large selection before it was paywalled and, well, you know.

Oh! Also, I managed to track down the tutorial about Directional Line of Sight. That's what I was thinking of, but it was for VX Ace. I think one for MV was done a few years back as part of a 'school' project but I have no idea where that is.
Yeah, I went ahead and bought the whole collection shortly after it was paywalled and haven't regretted it 🙂

Your link isn't working for me, so I am not sure if it is along the same lines, but this post I tracked down a while back provides a line of sight method I like the look of. It was written for MZ, but I think it only uses calls that are shared between MV and MZ so it should be compatible as is.

Original thread: https://forums.rpgmakerweb.com/threads/sneak-attack-on-events-with-yanfly-event-chase-plugin.151309/