Pathfinding

I have a map 500x500 but it seems that this script has a very short (to me) distance to pathfind. 80x80 in a line to be more precise. Plus when you request a pathfind that long the game freezes and than nothing happens. I wonder if there is anything that could increase that range. Please look into this.
I have a map 500x500 but it seems that this script has a very short (to me) distance to pathfind. 80x80 in a line to be more precise. Plus when you request a pathfind that long the game freezes and than nothing happens. I wonder if there is anything that could increase that range. Please look into this.
Can I have an example project demonstrating this freeze please? Help me help you.
Hello, I'm in need of help with this script.

I would like to setup this script like this;

Starts from 33, 9 and walks over to 59, 9 and then I would like it to go back from 59, 9 to 33, 9

Currently I've tried running it like this:

find_path(59, 9, ev = 0, wait = false, distance = 0)

find_path(33, 9, ev = 0, wait = false, distance = 0)

However the script doesn't seem to like that I'm trying to run it like this, appreciate any advice!  🙂
Hello, I'm in need of help with this script.

I would like to setup this script like this;

Starts from 33, 9 and walks over to 59, 9 and then I would like it to go back from 59, 9 to 33, 9

Currently I've tried running it like this:

find_path(59, 9, ev = 0, wait = false, distance = 0)

find_path(33, 9, ev = 0, wait = false, distance = 0)

However the script doesn't seem to like that I'm trying to run it like this, appreciate any advice!  🙂
The way I'd probably solve it would be to use a paralel proces in the back which checks if the event has reached those coordinates.

Something like:

if $game_map.events[1].x == 33 && $game_map.events[1].y == 9

  mr = RPG::MoveRoute.new

  mr.repeat = true

  mr.skippable = true

  m1 = RPG::MoveCommand.new

  m1.code = 45

  m1.parameters = ["find_path(59, 9, 0)"]

  mr.list.insert(0,m1.clone)

  $game_map.events[1].force_move_route(mr)

end

if $game_map.events[1].x == 59 && $game_map.events[1].y == 9

  mr = RPG::MoveRoute.new

  mr.repeat = true

  mr.skippable = true

  m1 = RPG::MoveCommand.new

  m1.code = 45

  m1.parameters = ["find_path(33, 9, 0)"]

  mr.list.insert(0,m1.clone)

  $game_map.events[1].force_move_route(mr)

end

wait(60)

Not the prettiest, but it gets the job done 😉 Refine it as you like.

Good luck.
Hello, I'm in need of help with this script.

I would like to setup this script like this;

Starts from 33, 9 and walks over to 59, 9 and then I would like it to go back from 59, 9 to 33, 9

Currently I've tried running it like this:

find_path(59, 9, ev = 0, wait = false, distance = 0)

find_path(33, 9, ev = 0, wait = false, distance = 0)

However the script doesn't seem to like that I'm trying to run it like this, appreciate any advice!  🙂
First of all, Sven, I doubt that convoluted approach will be necessary, though I appreciate your effort 😛 .

Secondly, Lakeyour, try "find_path(59, 9)" instead of "find_path(59, 9, ev = 0, wait = false, distance = 0)". You do not put the variable names in the parameters, the "ev = 0" simply means that 0 is the default value if you don't provide the parameter.

IF that still doesn't work, run the find_path as a script as part of the event's move route. Either checking or unchecking 'repeat' should have the desired effect I believe.
First of all, Sven, I doubt that convoluted approach will be necessary, though I appreciate your effort 😛 .

Secondly, Lakeyour, try "find_path(59, 9)" instead of "find_path(59, 9, ev = 0, wait = false, distance = 0)". You do not put the variable names in the parameters, the "ev = 0" simply means that 0 is the default value if you don't provide the parameter.

IF that still doesn't work, run the find_path as a script as part of the event's move route. Either checking or unchecking 'repeat' should have the desired effect I believe.
lol, it's been a while, but yeah, the script runs just fine if you make the call correctly 🤣
First of all, Sven, I doubt that convoluted approach will be necessary, though I appreciate your effort 😛 .

Secondly, Lakeyour, try "find_path(59, 9)" instead of "find_path(59, 9, ev = 0, wait = false, distance = 0)". You do not put the variable names in the parameters, the "ev = 0" simply means that 0 is the default value if you don't provide the parameter.

IF that still doesn't work, run the find_path as a script as part of the event's move route. Either checking or unchecking 'repeat' should have the desired effect I believe.
Tried this already to no avail it does not work.

I thought it would be pretty simple to make a patrol event on a NPC, however putting it to right, repeating and checking the skip if can't move box and then going left did not work either.
The way I'd probably solve it would be to use a paralel proces in the back which checks if the event has reached those coordinates.

Something like:

if $game_map.events[1].x == 33 && $game_map.events[1].y == 9

  mr = RPG::MoveRoute.new

  mr.repeat = true

  mr.skippable = true

  m1 = RPG::MoveCommand.new

  m1.code = 45

  m1.parameters = ["find_path(59, 9, 0)"]

  mr.list.insert(0,m1.clone)

  $game_map.events[1].force_move_route(mr)

end

if $game_map.events[1].x == 59 && $game_map.events[1].y == 9

  mr = RPG::MoveRoute.new

  mr.repeat = true

  mr.skippable = true

  m1 = RPG::MoveCommand.new

  m1.code = 45

  m1.parameters = ["find_path(33, 9, 0)"]

  mr.list.insert(0,m1.clone)

  $game_map.events[1].force_move_route(mr)

end

wait(60)

Not the prettiest, but it gets the job done 😉 Refine it as you like.

Good luck.
Thanks for that tip, I will try anything.

What I did instead of messing around with the scripts, just to clarify I did mess around with this for about 3 hours but realizing it did not work as I wanted I did this > was just skip a patrol event and put the NPCs next to fires and putting some dialogue, sure it's boring but patroling is pretty much the same level of boring in my opinion, I'll probably go with my method on solving this, thanks though both of you!  😀
You are using my latest version of the script right? The one at the end of page 4?
If all you are trying to do is get an event to walk back and forth from 33,9 to 59,9 and repeat, I achieved that by just setting the event's custom move route to:

find_path(59, 9)

find_path(33, 9)

and then ensuring the Repeat Action box was checked.   The guy walked back and forth indefinitely for me with no issues.

I think if you are finding that its not working for you, then your issue is likely something else.   One thing I've noticed has caused no end of trouble for me is the fact that events (even invisible ones) make a square impassable from the point of view of the pathfinding script.   So, if there's a choke point (i.e. single square through which the path must go) on your route that has an event on it which isn't marked as Through, then pathfinding will fail to find the route.   If the pathfinding algorithm can't find a route, it won't move at all - so it might look like things are just broken.
I think if you are finding that its not working for you, then your issue is likely something else.   One thing I've noticed has caused no end of trouble for me is the fact that events (even invisible ones) make a square impassable from the point of view of the pathfinding script.   So, if there's a choke point (i.e. single square through which the path must go) on your route that has an event on it which isn't marked as Through, then pathfinding will fail to find the route.   If the pathfinding algorithm can't find a route, it won't move at all - so it might look like things are just broken.
Well done for thinking of that, it hadn't crossed my mind that there might be an obstruction caused by an event (that doesn't have through set). I'm not entirely sure if it checks the above/below characters property of events either, I didn't write the original script, I only modified it to be more flexible.
And I had never thought of using above\below to control that.   I'll take a look this weekend and if I come up anything clever, I'll post.   But, maybe Lakeyour will find the problem solved if there was in fact an obstructing event 🙂
I haven't tried this theory I have but, I set two parallel events on each side where this NPC would patrol from left to right, However the events where not in the range of the path that he was suppoused to patrol.

IF I would put events on both ends 1 square outside of the patrol path would this prevent this script from running correctly?

find_path(59, 9)

find_path(33, 9)


My solution, that worked for me;

1. Don't try and block the path even though it's 1 square outside of the path range, that's gonna mess up everything.
2. I found that the repeat function is not necessary, what happens if you use repeat? It's gonna reach 59, 9 and it's gonna keep repeating the wrong direction in this case right and then one left and then it's stuck in a loop of
1 left and 1 right.

Instead I used the wait for completion function, which essentially does the same thing in this case, except it does not go into that loop which hinders the patrol event I wanted.

Although thanks again for the help!  😉

As Mhin Ra said, it worked for him probably the only difference is that I put events there for troubleshooting purpouses
I'm glad that you got it working 🙂   If you found that events just outside your patrol route were causing the find_path function to not work correctly, you might check out this earlier post: http://forums.rpgmakerweb.com/index.php?/topic/3064-pathfinding/page-4#entry432967.   There was a bug in the original version of the script that would prevent the script from finding a path in some cases like that.   That might explain the weirdness you were seeing with the 1 left and 1 right thing (b/c the pathfinding algo might be confused about which squares are passable)... otherwise, I am not sure why you'd see that.   Repeat should repeat the script call, which should (hahaha - 'should' 😉  not do what you describe.

Anyway, if you've got it going, maybe never touch it again 😛   If you need more help, let me know.
Hi!


Erm...I may just be doing something wrong, but it seems as though the latest update (posted in a comment by Venima) is all on one line...When I post it in the script editor...
Hi!


Erm...I may just be doing something wrong, but it seems as though the latest update (posted in a comment by Venima) is all on one line...When I post it in the script editor...



You're right, it's all broken-like. I'll re-upload it as a file instead, (not my first choice but it seems Spoilers are a bit glitchy atm).


You can find the updated script here: View attachment Pathfinder.txt
You're right, it's all broken-like. I'll re-upload it as a file instead.



It's crashing on startup. 🙁
It's crashing on startup. 🙁



Hm. Ok then, I'll have to revert to this one. I've just tested it myself and is working fine: 


View attachment Pathfinder.txt
Thanks!
I have a question: Can it find a smart way to chase player?

Original thread: https://forums.rpgmakerweb.com/threads/pathfinding.3064/