Enemy approaching when the player is 2-3 tiles away.

I think the title says it all.
I'm looking for an easier way to trigger events with enemies. Now my system is based on trap tiles all around the NPC which activate the autorun event of the NPC getting to the player and starting a fight. All of those trap tiles have the same commands that I have to alter a little and it's a real pain to set this with every NPC.
Is there any good way of using the approach type movement? I don't want the NPC to go after my player since the beginning of the game, but If he would start that when the player is 2 tiles away it would make everything easier.
The "simple" way with the default engine would be to make a parallel process event on each map that constantly checks the X and Y position of the player against the X and Y positions of the events.

You could also get a plugin that adjusts the hit boxes of the events so that the events themselves trigger in a broader radius. If the event is stationary there should be several options that meet that need. If the event moves, the only plugin I'm aware of that works to increase the hitbox of moving events is the one by Dahlys: https://forums.rpgmakerweb.com/index.php?threads/big-sprite-movement-collision-trigger-fix.86141/
I think this Plugin (Visustella) has some functions that you're looking for.

EDIT: Sorry wrong engine
http://www.yanfly.moe/wiki/Event_Chase_Player_(YEP)
Hi there!
Well, you could try putting this in the move route script call of the event:
Set the Autonomous movement to Custom.
I also put repeat and skip if cannot move.


if( $gameMap.distance($gamePlayer.x, $gamePlayer.y, this.x, this.y) <= 2 ){ this.moveTowardPlayer() }

Change 2 to the number of tiles you want the event to chase the player.
Or you can flip a self switch. You call it 🙂

if( $gameMap.distance($gamePlayer.x, $gamePlayer.y, this.x, this.y) <= 2 ){ $gameSelfSwitches.setValue([$gameMap.mapId(), this._eventId, 'A'], true) }

$gameMap.distance($gamePlayer.x, $gamePlayer.y, this.x, this.y) This will return the distance, in tiles, from the player and the event.

It's a little messy because the move route script call can only use one line. ^^''
That's exactly what I needed! Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/enemy-approaching-when-the-player-is-2-3-tiles-away.131167/