out of ideas for how to make an event with an outer ring trigger zone

What if you wanted an event to trigger 5 tiles out in a diamond shape zone but not trigger if player is closer or farther than that. think of the archers in final fantasy tactics. they can shoot ahead but cannot shoot close too.

im trying to make an event trigger when you hit a certain tile range out and btw this event is moving towards player constantly for the most part.

for instance i want:
-an event to run towards a player (from any direction)
-when event is within 5 tiles of player it slows down and walks towards player
-when event is within 2 tiles of player it stops
-then as player gains ground it slowly reverses the process

any thoughts?

ive tried yanflys proximity and a few other sensor plugins but the solid radius in which they produce make it impossible to have more than 2 types of transitions for when the player is leaving the proximity

just curious if anyone can help me think a way to do this type of event behavior
I'm not 100% on what you mean but in terms of doing a proximity check I usually just to something along these lines:

Code:
If ($gameMap.event(1).x - $gamePlayer.x > 0)
    Variable 1 = gameMap.event(1).x - $gamePlayer.x
Else
    Variable 1 = $gamePlayer.x - $gameMap.event(1).x

Repeat above changing x to y and variable 1 to 2. Then you could do:

Code:
If (Var 1 + Var 2 < 2)
    Do whatever you want to do when it's closer than 2 tiles
Else
    If (Var 1 + Var 2 = 2)
        Stop
    Else
        If (Var 1 + Var 2 <= 5)
            Walk toward player
        Else
            Run toward player

Hopefully that's the logic you're looking for. This isn't full code so you'll have to use event commands for the majority of it.
I'm not 100% on what you mean but in terms of doing a proximity check I usually just to something along these lines:

Code:
If ($gameMap.event(1).x - $gamePlayer.x > 0)
    Variable 1 = gameMap.event(1).x - $gamePlayer.x
Else
    Variable 1 = $gamePlayer.x - $gameMap.event(1).x

Repeat above changing x to y and variable 1 to 2. Then you could do:

Code:
If (Var 1 + Var 2 < 2)
    Do whatever you want to do when it's closer than 2 tiles
Else
    If (Var 1 + Var 2 = 2)
        Stop
    Else
        If (Var 1 + Var 2 <= 5)
            Walk toward player
        Else
            Run toward player

Hopefully that's the logic you're looking for. This isn't full code so you'll have to use event commands for the majority of it.

Thanks for response. I ended up getting what I wanted from Poryg! Here is what I needed:

Code:
Math.abs($gameMap.event(1).x - $gamePlayer.x) < 5 && Math.abs ($gameMap.event(1).y - $gamePlayer.y) < 5

Original thread: https://forums.rpgmakerweb.com/threads/out-of-ideas-for-how-to-make-an-event-with-an-outer-ring-trigger-zone.104265/