Pathfinding

lordamon

Warper
Member
Joined
May 30, 2014
Messages
2
Reaction score
1
First Language
Portuguese
Primarily Uses
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.
 

Venima

Treasure experiences and sensations, not progress.
Veteran
Joined
Oct 8, 2013
Messages
128
Reaction score
48
First Language
English
Primarily Uses
N/A
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.
 

Lakeyour

Warper
Member
Joined
Sep 21, 2015
Messages
4
Reaction score
0
First Language
Swedish
Primarily Uses
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!  :)
 

SvenVI

Warper
Member
Joined
Dec 20, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
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.
 

Venima

Treasure experiences and sensations, not progress.
Veteran
Joined
Oct 8, 2013
Messages
128
Reaction score
48
First Language
English
Primarily Uses
N/A
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 :p .

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.
 
Last edited by a moderator:

SvenVI

Warper
Member
Joined
Dec 20, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
First of all, Sven, I doubt that convoluted approach will be necessary, though I appreciate your effort :p .

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 :guffaw:
 

Lakeyour

Warper
Member
Joined
Sep 21, 2015
Messages
4
Reaction score
0
First Language
Swedish
Primarily Uses
First of all, Sven, I doubt that convoluted approach will be necessary, though I appreciate your effort :p .

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.
 

Lakeyour

Warper
Member
Joined
Sep 21, 2015
Messages
4
Reaction score
0
First Language
Swedish
Primarily Uses
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!  :D
 

Venima

Treasure experiences and sensations, not progress.
Veteran
Joined
Oct 8, 2013
Messages
128
Reaction score
48
First Language
English
Primarily Uses
N/A
You are using my latest version of the script right? The one at the end of page 4?
 

Mhin Ra

Veteran
Veteran
Joined
Aug 17, 2015
Messages
65
Reaction score
19
First Language
English
Primarily Uses
RMVXA
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.
 

Venima

Treasure experiences and sensations, not progress.
Veteran
Joined
Oct 8, 2013
Messages
128
Reaction score
48
First Language
English
Primarily Uses
N/A
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.
 

Mhin Ra

Veteran
Veteran
Joined
Aug 17, 2015
Messages
65
Reaction score
19
First Language
English
Primarily Uses
RMVXA
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 :)
 

Lakeyour

Warper
Member
Joined
Sep 21, 2015
Messages
4
Reaction score
0
First Language
Swedish
Primarily Uses
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
 
Last edited by a moderator:

Mhin Ra

Veteran
Veteran
Joined
Aug 17, 2015
Messages
65
Reaction score
19
First Language
English
Primarily Uses
RMVXA
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 :p   If you need more help, let me know.
 

AeghtyAteKees

Nyctopheliac
Veteran
Joined
May 8, 2013
Messages
33
Reaction score
2
Primarily Uses
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...
 

Venima

Treasure experiences and sensations, not progress.
Veteran
Joined
Oct 8, 2013
Messages
128
Reaction score
48
First Language
English
Primarily Uses
N/A
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
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games. and, if so, would any of you be interested in a short, proof of concept type non-euclidian puzzle game?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top