Proximity sensor enemy battle trigger

I wonder if someone can help me with this, it's driving me nuts.
I'm using this lovely plugin

And I'm trying to make the most simple of RPGmaker events: enemies that approach the player when close, back off when you're too far away and trigger a battle (or similar event)upon touching the player.

I may have gone nuts but I just can't figure out how to get an "event touch" event running alongside this plugin (or any other event.)

Because this sensor requires a parallel process, I don't understand how to get the event to also become both an event that triggers on touch AND still back off when the player is far away enough. Sure, I can set zones or regions that activate switches to "de-aggro" the enemies. but it's not quite what I'm going for.

Can someone help with this very simple task? I can show what I'm doing but there's got to be a simpler solution.
I'm not that familiar with that plugin, but it looks like it can set a self-switch when the player is close enough, and turn it off when moving away?

How I'd do it:

Set the plugin to toggle self-switch A when the player is close:

First page, no conditions:
- Do nothing

Second page, requiring self-switch B, autorun:
- Set move route to go back to starting position, set self-switch B off

Third page, requiring self-switch A, autorun:
- Set move route to constantly move towards the player, turn self-switch B on

Fourth page, requiring both self-switch A and self-switch B, event touch:
- Run the encounter

For the move route to go back towards a starting position, there is this cool snippet by @orphalese, though I don't know if it would work for MZ.


There is also a chance MZ has some sort of an on-map encounters plugin that would just do it all for you.
How... can you get an event to require 2 self switches at once? There is only room for 1. I guess normal switches would work.

Thanks for the ideas, but it seems the plugin must be set on specific events which is the problem, if a common event could acrtivate the sensor it wouldn't be an issue. I had a go, but it just seems to freeze (like anything I try with autorun).. But you'vegiven me some ideas on how to make it work, thankyou!
How... can you get an event to require 2 self switches at once?
Ah, sorry, I forgot that's not a feature in the engine by default xD
There are plugins that let you the slots for regular switches with self-switches, at least in MV.

Another common pattern that might help is that of a controller event. Basically, you have your enemy with just one page that's set to event touch, and another invisible event that handles setting its move routes in different situations. I'm not sure if that would work with this plugin though.
For the move route to go back towards a starting position, there is this cool snippet by @orphalese, though I don't know if it would work for MZ.
Yes, It does work for MZ. Actually not sure if it works for MV
Yes, It does work for MZ. Actually not sure if it works for MV
I mean, you did post it in the thread for MV code snippets 😉
And it does work perfectly fine, I use it quite a lot.

Original thread: https://forums.rpgmakerweb.com/threads/proximity-sensor-enemy-battle-trigger.172775/