RPG Maker MV

RPG Maker MV

lassipls Apr 27, 2016 @ 3:03pm
make NPC or Enemy Approach player when within a few squares of event (RPG Maker MV)
Just wanted to make an updated MV version of this.

Original reply from RPG Maker VX Ace forums:
Originally posted by Karanum:

I'm going to apologize in advance in case this is really messy and hard to follow.

You can either do this completely through variable operations and such, or with a little bit of scripting. The latter method only requires 1 variable and this is how you should set up your pages:

Page 1[imgur.com]
Page 2[imgur.com]

...

Basically just replace the script in the event page 1 with:
var variable = X var event = Y var sx = Math.abs($gamePlayer.x - $gameMap.event(event).x) var sy = Math.abs($gamePlayer.y - $gameMap.event(event).y) $gameVariables.setValue(variable, sx + sy)
where:
  • X is the variable ID where the distance from player will be stored in
  • Y is the event ID which you want to affect (you can see the event ID in the upper-left
    corner of the event page)

You can set the range in which the event self switch will turn on and start moving towards the player in your Conditional Branch parameters.

Example of my enemy event pages:

Page 1[puu.sh]
Page 2[puu.sh]

The bat slowly roams around the map randomly, constantly checking the distance from the player. Switches to page 2 when player comes within 4 squares of it, making it rapidly chase the player and begin combat upon touching it. Afterwards erases the event so it disappears from the map.

There are probably better ways of doing it, but this works for me. Hope it helps!
Last edited by lassipls; Apr 27, 2016 @ 3:09pm
< >
Showing 1-6 of 6 comments
Jazeeri Apr 27, 2016 @ 3:55pm 
Ooo thank you I will use this too!
What advantage does this provide over Yanfly's plugin?
lassipls Apr 28, 2016 @ 3:58am 
Yanfly's plugin will probably handle this waaaay better anyways, so my method is just to achieve this simple thing without having to install any plugins. I probably just love coding so much that I like to figure these things out myself instead of relying on plugins :D
satiricalsage Sep 23, 2017 @ 6:57am 
"You can set the range in which the event self switch will turn on and start moving towards the player in your Conditional Branch parameters."

Hey! I'm new to the game and I can't figure out how to set the "distance" section in my conditional branch. The only choice with less than/greather than is the variable choice.
Coldsteelj Sep 19, 2022 @ 11:05am 
Thank you very much lassipls! It work awesome with combination of YEP_EventChasePlayer plugin.
Kurumi Sep 7, 2024 @ 2:19pm 
The images are deleted x.x does someone has the visual example? Im very visual x.x
< >
Showing 1-6 of 6 comments
Per page: 1530 50