Map Enemy Movement

I'm trying to set up enemy encounters to appear on the map and while I can get them to move towards the player, I can't figure out how to make it conditional so that they wait until the player is within a certain distance of them before doing so.

Also, how do I check the player's levels from the event menu? I want to have the enemies run away if the player is above a certain level.
Neither can be done by default. But, here's how I was able to pull this off.

First, the make enemies approach when the player was close enough I did with Yanfly's Enemy Chase script in ACE. I think they have a similar one in MV. In that, you can specify a distance you want the enemy to chase the player at.

For the levels, I had to take a convoluted approach. I used a parallel process which calculated the average level of the entire active party, and if the average was above a certain level, I had it turn on a switch. Then, on each enemy encounter, I had two versions, one with and one without a switch, and the one with that switch was set for a move route: Flee from player (though Yanfly's plug-in will let you specify for the enemies to also flee if the player is within x distance of the event).

Unfortunately, all my code for this is in ACE, and MV changed the code you'd need for the parallel process, so I can't help there. But that's the general approach to it at least. Start by getting Yanfly's Event Chase plug-in, or some other author's plug-in that does event chasing.
For the enemy chase you can use those plugins and do as @bgillisp said about levels

http://yanfly.moe/2016/06/03/yep-105-event-encounter-aid-rpg-maker-mv/
http://yanfly.moe/2015/10/21/yep-20-event-chase-player/
'Resources' is not the place for "How do I...?" questions, it is for posting assets made by people that they want to share with the community.

Moved to: RPGMaker MV
It's also possible to do with just standard events if you want.

Give the enemies 2 pages. One is just them normally moving randomly or whatever and the second page is the exact same thing, but it chases you instead and controlled by a switch.

Make a parallel process event that compares the player's X/Y location with the enemy's by subtracting the one from the other.
(subtract the enemy's X from the player's X and the enemy's Y from the player's Y.)

Then you just set up some conditional branches that define the range.
Say you wanted the enemy to chase the player if you got within 6 tiles of them?
So if the X comparison of their positions is greater than -6 but less than 6 you know they're within range and you can turn on the chase switch.

Make the same check with the Y and there you go.

but anyway, here's what the simpler version would look like controlling one enemy.
Code:
◆Wait:1 frame
◆Control Variables:#0009 Player X = Map X of Player
◆Control Variables:#0010 Player Y = Map Y of Player
◆Control Variables:#0011 Enemy X = Map X of enemy 1
◆Control Variables:#0012 Enemy Y = Map Y of enemy 1
◆Control Variables:#0009 Player X -= Enemy X
◆Control Variables:#0009 Player X -= Enemy Y
◆If:Player X ≥ -6
  ◆If:Player X ≤ 6
    ◆
  :Else
    ◆Control Switches:#0003 Enemy 1 chase = OFF
    ◆Jump to Label:chase
    ◆
  :End
  ◆
:Else
  ◆Control Switches:#0003 Enemy 1 chase = OFF
  ◆Jump to Label:chase
  ◆
:End
◆If:Player Y ≥ -6
  ◆If:Enemy Y ≤ 6
    ◆Control Switches:#0003 Enemy 1 chase = ON
    ◆
  :Else
    ◆Control Switches:#0003 Enemy 1 chase = OFF
    ◆
  :End
  ◆
:Else
  ◆Control Switches:#0003 Enemy 1 chase = OFF
  ◆
:End
◆Label:Chase

It sounds complicated but it's really just simple math.
The best part is that the single parallel event can be used to control the positions of every enemy on the map with the same variables, just by remaking the position comparison for each of them.

If you REALLY wanted to get fancy, rather than having the parallel event control switches you could have it control the enemy's actual movement by doing more complex comparisons and telling the enemies which way and how to move. it could be used to make an enemy that only moves diagonally, or one that lunges at the player when you walk in front of them or any other pattern you can imagine.

For running away just add a 3rd page to the enemy that runs away from the player and have it controlled by another switch. Something like " If the chase switch is on, and the player's level is greater than X, turn on the "run away" switch."

Original thread: https://forums.rpgmakerweb.com/threads/map-enemy-movement.83087/