OK! So I tested it out in my hedge maze, and the event was able to find a path almost perfectly most of the time.
However, in a couple of instances, despite using Ctrl to walk through a wall before it reached me, the event seemed to first go to my previous position before adjusting and finding a new path. After some time playing hide and seek, it just stopped moving altogether, although it took a couple of minutes for that to happen.
The event in question was set up to the highest frequency and moving at twice the regular player speed. Its move route was set up with a single goto_player script call and repeat action toggled on.
I'll test it out a bit more later, to see if I can reliably reproduce the event halting the pathfinding.
Did you put <chase player> comment in event?
It will acts like an autonomous movement. So you dont need to manually put move route
New path will be refreshed in once per second
This script is just simply perfect!
Now I can discard my long and tedious eventing and instead use a simple comment for my guards and monsters!
You just saved me hell of a lot time with this, thanks a lot!
I expected some FPS loss, especially with multiple chasing events, but to my surprise, there was no significant FPS loss. o.o
Extra thanks for this! 🙂
Ahoy, Theo!
I had a little fun with this script while I tried something out and I noticed something rather odd...
I had my event set up this way:
Page 1:
- Only set up some commands in the autonomous movement.
- The event moved left and right between 2 points in a straight line. I used your script calls to do this, one find_path(x,y) for each points.
Page 2:
- Requires self-switch 'A' to be turned ON.
- Contains only the <chase player> comment.
- Fixed auto-move route here.
The event's self switch 'A' is turned ON automatically when the player has been spotted (I use a proximity script for this with line of sight feature).
So, what should happen is, when the player did not alerted the guard, it moves left and right, patrolling the area. But when the player has been spotted, the guard will start to chase the player. This works perfectly fine.
When the player successfully managed to hide for a short time, the event's self-switch will be turned off. This initiates the find_path(x,y) auto-movement again for the guard, so no matter where the player lured the guard, it will return to it's original position. And this works well too.
But after the guard has arrived it's original position and moves to the 2nd point, the find_path(x,y) auto-move route fails. It will run another additional path before returning to the 1st spot again. This additional path seems to have a pattern, but maybe I was just watching the blasted guard too long. 😀
I wonder what could cause this? I tried to figure it out, but nothing seemed off in the script for me.
It seems to me that somehow the last move route executed from the <chase player> page goes to the end of the first page's auto-move route.
Just wanted to report this odd behavior, hoping that you can fix it. *-*
I'm thinking of using this to create somewhat smarter AI for a warcraft 2 style RTS/ god/village simulation game. the idea is that the player controls things via a cursor and can select characters then order them to do things. since the cursor would function as the player character, would it be possible for the NPC to go to a specific player-specified coordinate instead of just where the player is with this script?
Does this script have the ability to send NPCs to a location based on Variables?
I.E. If I use a parallel process to store player X,Y in a variable, is there any method to call that information and use it to move the NPC to those coordinates?
You would use:
find_path($game_player.x,$game_player.y)
No variables, no needless parallel process events, especially no parallel process events which update a variable all the time.
You use this in a "Set Move Route" script call, not with a simple script call command, so the target of the script call will be set via that target selector thing at the top left corner of the popup window where you can select "This Event", "Player", or a specific event.
If you need to use variables for X and Y position, you use this:
find_path($game_variables[ID],$game_variables[ID])
But do not update any variables/switches/self-switches in any constantly updating parallel process event, that will drop the FPS, and it is not needed at all.
Does event chase offscreen persist in the new update?
The last time I remember is that when the player outrun the chasing event lets say like 10 squares outside the monitor, the event halts the chase to dead stop but if player reenters event vicinity it will resume chasing.
The new update only fixes the weird behavior on using find_path on event command move route, not autonomous movement. And it doesn't touch anything regarding the event chase itself, so maybe it still is.
Here is the thing. By default, all autonomous movement stops once the event is far away from screen. Which it can be considered as either bug or feature. But anyway, I might try to look at it tomorrow, and see if I could make the event chase keep persistent even if it went off screen.
Thanks for reporting though.
Hi. Great script! Tried a couple of similar ones and they didn't work, so seeing this one actually do what I wanted was awesome 😀.
Buuuut... did you ever look into the events moving when off screen? Right now I'm using it for NPC's in villages going home at a certain time, but of course they only move if I'm on screen with them, which isn't ideal lol. 🙂
EDIT: nevermind I misread.
Hi. This is a great script! Can you recommend a reverse chasing (event moves away from player smartly) too? Thank you.