Smart Pathfinding

Hi @Shaz, I'm having a bit of troubles interacting with the event while it's moving.

Once I set an NPC event to move towards a point, when the player interacts with the NPC to talk to it, it keeps moving towards its destination.

How do I temporarily stop the event and continue its path after the interaction ends?

Thank you.
How do I temporarily stop the event and continue its path after the interaction ends?
Being addressed in:
Hi. Sorry for necroposting - but was this ever ported to MZ?
Hi. Sorry for necroposting - but was this ever ported to MZ?
Necroposting rules don't apply to plugin release threads, so you're fine on that front. However, you should generally try reading the other posts in a thread before asking questions, since the question may have already been answered.

A page or two prior to this, Archeia posted a list of script calls that will allow you to use this plugin in MZ. The plugin is compatible with MZ, with the exception of the fact that, by default, MV plugin commands won't work in MZ. So you can simply use the script calls, instead of the plugin commands. Alternatively, you can use this plugin to enable you to use MV plugin commands in MZ.
Necroposting rules don't apply to plugin release threads, so you're fine on that front. However, you should generally try reading the other posts in a thread before asking questions, since the question may have already been answered.

A page or two prior to this, Archeia posted a list of script calls that will allow you to use this plugin in MZ. The plugin is compatible with MZ, with the exception of the fact that, by default, MV plugin commands won't work in MZ. So you can simply use the script calls, instead of the plugin commands. Alternatively, you can use this plugin to enable you to use MV plugin commands in MZ.
I apologize - I should have read all of the other posts first. Thank you very much for your answer though, I appreciate it greatly.
I'm kind of a noob, but i found this script that's basically Shaz's script with wait and auto cancel functions, but i can't figure out how to use them. i'm trying "SmartPath -1 12 12 Wait" and "SmartPath -1 12 12 Auto_Cancel", but it just ignores the cancel and wait.
In fact, i can't make it follow events either. Is it because of my version? i'm on 1.6.1
Spoiler
@Varfarin A few tips for you:
1 - Please don't post multiple-hundreds of lines of code in a post, it's very annoying to scroll past 😛
Put it in Spoiler tags, or attach the .js file instead of posting its contents, or (most preferable) link to where you got it.

2 - As this is someone else's modification, it makes more sense to ask them to provide examples in the documentation for how to use their changes, rather than ask in the original author's thread about what someone else did.

To answer your question, it appears to be changing the syntax entirely. It looks like it's expecting the new option words to be the second argument in the plugin command, e.g. SmartPath -1 wait
@Varfarin A few tips for you:
1 - Please don't post multiple-hundreds of lines of code in a post, it's very annoying to scroll past 😛
Put it in Spoiler tags, or attach the .js file instead of posting its contents, or (most preferable) link to where you got it.

2 - As this is someone else's modification, it makes more sense to ask them to provide examples in the documentation for how to use their changes, rather than ask in the original author's thread about what someone else did.

To answer your question, it appears to be changing the syntax entirely. It looks like it's expecting the new option words to be the second argument in the plugin command, e.g. SmartPath -1 wait
Thanks for replying and sorry for that. I thought it would be fine if somebody else in the thread looked into it, since DragoonKain and Shaz are in the thread, but don't seem to be active for some time.
I tried "SmartPath -1 wait 12 12", but it doesn't do anything. "SmartPath -1 12 12 wait" works but without the wait. "SmartPath -1 1" (to make the actor follow an event) doesn't work at all.
I tried "SmartPath -1 wait 12 12", but it doesn't do anything. "SmartPath -1 12 12 wait" works but without the wait.
Neither of those matches the syntax I gave you above.

"SmartPath -1 1" (to make the actor follow an event) doesn't work at all.
I can't speak to that as I haven't tested the plugin, but does it work in Shaz's original version?
Neither of those matches the syntax I gave you above.


I can't speak to that as I haven't tested the plugin, but does it work in Shaz's original version?
The original works normal for both coordinates and events.
The DragoonKain version only works for coordinates. and if i try:
SmartPath -1 12 12
SmartPath -1 wait
it goes to the coordinates, but ignores the wait function. If i try the same thing with events the game gets locked in the wait function
Hello, I want to create an event like this. How do I set it up?

1. Event A walks to Event B.
2. Wait 3 seconds.
3. Event A returns to the original point.

1719106676484.png
Hello, I want to create an event like this. How do I set it up?

1. Event A walks to Event B.
2. Wait 3 seconds.
3. Event A returns to the original point.

View attachment 309250
Personally I would use Yanfly's Move Route Plugin... It does this kind of problem easily.

If you don't want to use a plugin then just make a Move route that looks like this:

move up
move up
move up
move left
wait: 180 frames
move right
move down
move down
move down
wait: 180 <- so the event waits for 3 seconds before repeating the route again.

Repeat without wait activated....
Still one of my favorite scripts that I may or may not be using in MZ.
Script Calls for those who need it.


JavaScript:
// Make Player go to X/Y
$gamePlayer.setTarget(null, X, Y);

//Make Player go to target event
const target = $gameMap.event(ID)
$gamePlayer.setTarget(target);

//Make event go to target event
const event = $gameMap.event(ID);
const target = $gameMap.event(ID)
event.setTarget(target);

//Make event go to player
const event = $gameMap.event(ID);
event.setTarget($gamePlayer);

//Cancel Pathfinding script calls. Use whichever you want.
$gamePlayer.clearTarget();
$gamePlayer.setTargetAutoCancel('on');
$gamePlayer.setTargetAutoCancel('near');

//Cancel Pathfinding script calls. Use whichever you want.
const event = $gameMap.event(ID);
event.clearTarget();
Thank you!
for everyone instrested, here's the plugin with the script calls writed inside the help desciption box.
Is there a way to check if event has reached it's destination? Like, i want something to reach X spot, and then disable pathfinding and do other stuff. But i can't possibly know when it will happen to stop pathfinding in time.
That can be done with basic eventing, though it's a bit involved. You would need to store the X and Y of the event into two different variables, then compare those variables with its intended destination.
I noticed (by having this happen on a project I work on) that if the Plugin commands were to happen during a Battle, it would cause a crash. Normally, you wouldn't call this plugin during a battle, but if you work with Parallel Events too, it might just occur.

To prevent this, I added a failsafe conditional ("!$gameParty.inBattle()") to both the original plugin and DragoonKain's modification, here are the Failsafe'd plugins:

Original thread: https://forums.rpgmakerweb.com/threads/smart-pathfinding.46761/