Event Chase Player

Last Updated: 2012.01.05
Download Link
Github Link

This script allows you to make events that will chase the player or flee from the player when the player enters within range of the event or when the event sees the player.

Insert these lines into the script call window within the Movement Route event to give an event the chase or flee flag. This doesn’t work with players.

@chase_range = x

Event will chase the player after reaching x range.

@flee_range = x

Event will flee from player after reaching x range.

@chase_speed = x

Event will move at x speed when chasing.

@flee_speed = x

Event will move at x speed when fleeing.

@sight_lock = x

Event will chase/flee from player for x frames.

@alert_balloon = x

Event will show ballon ID x when chasing or fleeing.

@see_player = true

For events that require them to see the player first, use this script call inside the movement boxes. This does not follow line of sight rules, which means if there’s a rock blocking you and the event, it will still see you.

And that’s all, folks!

62 comments on “Event Chase Player

    • “I wan to do a visible monsters/touch encounter. In order to trigger this event I set its trigger to ‘Parallel process’ (otherwise it makes no sense, as I have to go and touch or activate the event). But, once I’ve set it to Parallel process, how can I event/script it so that when the monster comes in contact with the player, the battle gets started?”

      Instead of creating a movement event, go to the events fixed posistion option and put it to custom.
      After that, just do what you would have done to make him follow you.

      he will chase you without having to parrarell proccess and you can now make it an “Event Touch” so that you battle process on contact

  1. Would it be possible to code regions or terrain tags to ‘block’ the line of sight, then? If you can, then you have basically made MGS Maker VX Ace. :P

  2. Having some fun with this. Is there a way to make a sound effect play when seen/chased/ran away from or call an event when they happen? I tried placing the sound effect in under the other stuff, but it just plays repeatedly.

  3. I jsut wonder how I can desactivate it? I mean, I use it for a cat that flee player. If player catch him, event will follow. But the cat dont follow the event, he start running away again. How desactivate the movement?

  4. there is a bug. the scripts calls in the custom move route for the first event page work on the second event page even if it has different script calls in its custom move route

  5. I have been looking for this!
    I want to make touch encounters, so the enemy will randomly patrol or move around however when the player comes within X range, the enemy will begin the chase until either combat or you get far enough. If you get far enough the player will then continue random/patrol movement.
    Can this be done??

  6. I wan to do a visible monsters/touch encounter. In order to trigger this event I set its trigger to ‘Parallel process’ (otherwise it makes no sense, as I have to go and touch or activate the event). But, once I’ve set it to Parallel process, how can I event/script it so that when the monster comes in contact with the player, the battle gets started?

    Sorry for bad english.

    • Instead of creating a movement event, go to the events fixed posistion option and put it to custom.
      After that, just do what you would have done to make him follow you.

      he will chase you without having to parrarell proccess and you can now make it an “Event Touch” so that you battle process on contact

  7. Set up the monsters custom movement command as “move random” – “chase range” “chase speed” “sight lock” “alert balloon” “see player” then have it as repeat action and skip if impossible.

    Set the trigger to “event touch” and in the events window set up a battle processing to your chosen battle specifications.

    This will let your monster wander around the area randomly, then when they see you they will chase you around for a while until you escape. If they catch/touch you, you’ll be dragged into battle. Set :)

    I’m using this script for my visible monsters and it works perfectly using that method.
    (http://forums.rpgmakerweb.com/index.php?/topic/2455-dance-of-the-immortals/)

    • Could you expand it a little bit? When I set it to event touch, the monster does not move automatically. Do you mean making one page Parallel Process and another Event Touch, but if that’s the case, that didn’t work for me either.

      • Took me a little while to figure that one out myself. For Trigger select Event Touch. Then under ‘Autonomous Movement’ (same event screen) choose custom and click the ‘Move Route’ button. Within the move route editor for every Event Chase player setting you want to apply (chase speed, sight lock, etc.) click script to add a script event and add the setting “@chase_range = 4” for example.

  8. I’m having a little trouble with this script. As I’m sure many of you are, I’m trying to get this to work so I can have enemies on the map which approach my player. The trouble is, no matter what I put in the Movement Route box, the event just moves at random, not approaching the player at all. This is how I’ve got it set up:

    In the Autonomous Movement section.
    Type: Custom
    Move Route…
    @chase_range = 4
    @chase_speed = 4
    @alert_balloon = 1
    Repeat Action is Checked
    Skip If Cannot Move Is Checked

    I’ve tried different values after the chase range and speed, plus including the other different settings such as sight lock. I’m probably being a bit thick and missing something, but I’m stumped. Any suggestions?

    • That’s weird because I don’t have any trouble using this script

      mine’s movement is:

      In the Autonomous Movement section.
      Type: Custom
      Move Route…

      Move at Random
      @chase_range = 3
      @chase_speed = 2
      @alert_balloon = 1

      Repeat Action is Checked
      Skip If Cannot Move Is Checked

      I put ‘Move at Random’ to make it move randomly, else, it will just stood there if I don’t approach it.

      You are probably using another script that collide to this one. my project is 100% using yanfly script only.

  9. Got the same trouble as Zilla, thought I had some script that didnt collide with this one, but tried it in a new project and still couldnt work it out. All my other scripts are working fine, and Yanflys too.. but for some reason I cant get this to work Oo

  10. I don’t know what im doing wrong. I put the commands in the custom route but it doesn’t do anything. However when I put the same commands on set/move route on the event side it works, but then I can’t get it to process a battle on event touch.

    • Under “Autonomous Movement Type” where you can choose ‘Custom, Random, Approach, etc. click on the “Move Route” button and enter the script there, then set the move route to custom. Works fine :)

  11. Is it possible to make the event moving and detect for the player at the same time. I dont want my event just standing there waiting for the player to pass by.

  12. The documentation for this isn’t entirely correct.

    @sight_lock is NOT the number of frames (ie 60/sec). It is actually the number of movement attempts made. If the event is stuck on the far side of a wall, this will go by relatively quickly. If the event is making a beeline for the player, it will take that many tiles for it to give up and leave.

    Be careful, as the default setting for this is 300 (which is not actually 5 seconds, but 300 tiles).

    Additionally, ALERT_TIMER in the config has the same issue. You can make both of these actually run off frames by:

    1) Search for: def update_self_movement
    Comment out the last line in this function:

    #update_alert_balloon

    2) Insert this after the update_self_movement:

    #————————————————————————–
    # alias method: update_self_movement
    #————————————————————————–
    alias update_ecp update
    def update
    update_ecp
    update_alert_balloon
    end

  13. I believe I encountered a bug with the script. After defeating an enemy with the chase player scripts, after they disappear with a Self Switch they still move around, even though they’re supposed to be “gone”. I can tell because I set an alert balloon on them, and it pops up whenever I run past the place they attacked me at.

    • I think I have a solution for your problem.

      don’t use self-switch or another changing page switch

      just 1 page is enough.
      make your event opened by ‘switch’
      so it can be disappeared by turning it off, and respawn by turning it on again automatically after a set of time. but you need to set “the respawn time and switch-on” both in ‘set move route’ event command. also, use ‘set event location’ command to transfer it back to its starting point.

      and to trigger that switch, place the ‘control switch x-on’ in ‘transfer player event’ in dungeon entrance and set the ‘control switch x-off’ at the transfer event when you want to go out of dungeon.

      hope it helps.

      • I have a much easier solution for this problem:
        When you want your event to stop chasing/fleeing, use a “set move route” event command, and in it just place a script to set @chase_range or @flee_range = -1
        (you have to use the script from inside the set move route command, it will not work if you just use a script command)
        This will stop the chasing/fleeing for this event. Make sure to change the event page to one that doesn’t have chasing/fleeing script call in its autonomous movement, or it will just start again!

  14. The script is great! However, I would like an encounter to occur when the enemy touches the player, but the enemy seems only to dance around the player rather than touching them, making it pretty easy to avoid encounters. Any ideas what I’m doing wrong

  15. Hello. First of all, I am tremendously thankful for your work with RPG Maker in general and these scripts in particular. From personal experience, I could never get around or muster enough time and confidence to learning the innards of programming languages :( But scripts like these work wonders. I’d also like to thank those commenters who showcased how to make an event follow a player and engage in combat.

    Second, apologies if this has already been asked but following on from the Chase Player event, I’m trying to set up a combat system that has a foe (an event) get its sights on the player, chase him/her and engage in combat. This works well with this script; however, I’m trying for a tile step movement like older RPGs used to do, such as Might and Magic (and the more recent Might and Magic X) as well Legend of Grimrock. In short, the game operates as semi-realtime until an enemy sees the player. When combat begins, both player and foe(s) can move away/toward each other, but only do so one step at a time (in essence, each “step” behave like a player or enemy phase/round). A party’s round may consist of moving into another tile (but can only do so if they chose not to attack/defend/use items, etc.), or simply attacking the enemy, and the same applies to foes. Additional foes may flank the player as well, and the player can also, for instance, turn (rotate) his position to deal with enemies from the sides or rear.

    For reference I am also using FPLE to have a simulated first-person view of maps (it doesn’t seem to be incompatible with any Yanfly script so far), if that helps. I’d appreciate any suggestions towards getting such a system to work, though I understand no help provided if it requires a lot of “eventing”.

    Best regards!

  16. Sorry for the double post.
    but apparently, I’m having an issue with this script.
    I use this script to visible monsters. as I test it to only with a monster, it’s fine.
    but when I actually use it to monsters, it gives an error everytime I won the battle. It says,

    “Script ‘Event Chase Player’ line 133: NoMethodError occurred.

    undefined method ‘move_speed’ for nil:NilClass”

    I set the monster event to respawn to its spawn point everytime I won or escape the battle after a set of time.

    Can someone help me with this problem?

  17. I am making a on map encounter system, and i want to know how i can make it so it starts a battle from a random set of monsters without it having random encounters on the map?

  18. But, when i use this

    In the Autonomous Movement section.
    Type: Custom
    Move Route…

    Move at Random
    @chase_range = 3
    @chase_speed = 4
    @alert_balloon = 5

    Repeat Action is Checked
    Skip If Cannot Move Is Checked

    The Npc don’t move at random, why? ^^”

  19. hello yanfly my name is john i am working on my own game and saw you had a script for events chasing player but end up getting a 509 error on your download link. i was hoping you could possibly send me the script through my email address or a demo for the script to my email: thedarksnow183@gmail.com i thank you for your time and your name shall go in my credits for your script use. the game is called Raven: Diamond dust and will be put online for free to play when i finish it

  20. For everyone trying to do the random movement then chase using the custom movement you will have a problem. The custom movement must be checked to repeat therefore you will have a random movement every time ALONG with the chase. It will make the monster look as if it is crazy not really chasing the player all the time or dancing around him. Still seems like there is no easy fix to have the monster move randomly THEN chase the player only when he sees him…

  21. Nevermind, it turns out the default script for having events (monsters) chase the player runs on a random 6 choices with 0 thru 3 actually chasing the player and 4 moving randomly, and 5 moving forward which causes the crazy movement. Using the custom option with random movement placed in a move route works fine…

  22. @see_player = true

    For events that require them to see the player first, use this script call inside the movement boxes. This does not follow line of sight rules, which means if there’s a rock blocking you and the event, it will still see you.

    So…How “do” you make it follow line of sight rules?

  23. this script is good and it starts to develop a stealth mechanic but i think this would make it a bit deeper. Currently i see no way for you to set up different reactions depending on how you interact with an event. so right now in his script if the event sees you it triggers it’s behavior (chase, run away, whatever) but if you say trigger it from behind… it turns around and triggers the same behavior. What i propose is that if you trigger the event from behind (or sides) a different ‘if’ is triggered doing whatever the designer inputs. By extension having different ‘if’s for how the event contacted you would also be great (aka, how it touched you if you did trigger a chase).

    why would you want this? simple.this is the base of a lot of game designs like Chrono cross or Ni no kuni, FF13 Xenosaga, etc. any game where you can see the enemy on the map screen. if the monster touches you, battle starts, if you touch the monster from behind you start battle and you get the advantage. if the monster touches you from behind you have a disadvantage. Also, you can use this for more stealthy games where you can take out enemies that are stronger from behind like say a patrolling guard. ala Metal gear solid or Splinter Cell.

  24. Is there any way to get the event to stop chasing you after you’ve beaten it in battle? I tried turning everything off in the event’s second page, but it still runs around for a few seconds before stopping.

    • Late reply here, but you should be able to set it up so on event page 1, after defeating monster, set a self control switch, then event page 2 just set it up without the “@chase_range” stuff if that makes sense lol.

  25. Cant figure out how to enter the value of a sound effect.

    I know the script is @alert_sound = x
    But i dont understand how the value of x translates to SE list. Someone help?

  26. Good lord this script was an absolute nightmare.

    Every few years I get the itch to mess around with a VX Ace project and every time I go looking for a chase player script this is literally the only game in town, and it is out of the box broke AF.

    Finally seems to be working as intended, thanks to Ruffus and Racheal by way of Numanumayay. Thanks very much.

    I should be more grateful to Yanfly that it even exists, but I’m still so salty lol.

Leave a comment