Smart Pathfinding

So it looks like, when the Hidden switch is off, you want event 3 to pathfind to the player, and when Hidden is on, you want it to stop pathfinding.

If that's the case, it looks like you've got the correct commands.

What IS happening?
Is Hidden off or on when you enter this map?
Where do you change the switch? If you're changing the switch on this map, the above won't work properly, because you're doing the check once when the map is loaded, then erasing the event, so it won't react to the changed switch.
If the Hidden switch is being turned on and off on this map, then just put the SmartPath commands right where you've got the commands to change the switch.
Okay, it Loses me, but it doesn't walk randomly away, what should I do to make the enemy walk randomly around the map?
do a set move route, repeat, move random
Thank you so much again Shaz!
is this the script i need for making board games? after dice roll x set move event a to event tile b?
This script will let you move one event to a specific location (by x, y coordinates) or to another event's position. Handy if you don't know where the event might start, or where it might end. If you know the starting and ending positions, you can just use a normal move route.
Say, could someone give me an example on how to write it out?

In my event Event #34 is the one being tracked and Events #15 and 14 are the ones pathfinding. In Plugin Commands section on another Event (not the one that is being walked towards, or the one walking) I wrote:

SmartPath eventId14 eventId34

With the events that walked having Autonomous Movement set to Random. Is this correct?
SmartPath 14 34

If having their move routes set to random causes a problem, just turn on a switch before you do the plugin call, and on those events, have another page conditioned by that switch where they have no movement route.
I'm trying to add a plugin event for an NPC to go to a specific door. I do not know the eventID so I just put:

"smartPath $gameVariables.value(myNPC) 6 6 "

myNPC is the name of the NPC event i want to move
6 6 being the specific tile i want him to go.

Am I missing something? Should get the eventID somehow else?
You need to use the event id, not the name (you could have 50 events with the same name).
Why are you using variables?

If you want your NPC event to go to position 6, 6 and your NPC is event 15, it will be
SmartPath 15 6 6
Sorry, I forgot to specify. I have no idea which eventId "myNPC" is. I tried writing:

"SmartPath myNPC.eventID() 6 6" but i does not work. How could i check, even if it's manually, the eventID of any event?

Thanks!
I don't understand. I assume you have a specific event that you want to go to that spot. THAT is the event whose id you need to put in. What is myNPC if it's not an event? Is it a variable? Is that why you use $gameVariables.value(myNPC)? $gameVariables.value() also takes a number, not a name. So if your event id is in variable 23, and variable 23 is called myNPC, it would be this:

SmartPath $gameVariables.value(23) 6 6
Is there any way that this improved pathfinding could be used for the player's movement in response to mouse/touch input? The pathfinding has a tendency to make me enter towns that are in the way instead of going around them, which is kinda annoying...
This plugin uses similar logic to the mouse/touch input, so you probably wouldn't gain anything by trying to use this instead.
I'm having issues with the pathing trying to take the event through impassable tiles.

I have event 2 that is, when a switch is thrown, is supposed to path to event 66. The problem is that en route there is a tent, which is marked in the tileset as impassable. The smart path doesn't seem to register the tile is impassible and tries to path through it. It's not just that one tile either. A separate event is trying to path through impassable log piles.

It does path around some obstacles, but not others and I haven't been able to identify a pattern other than: All obstacles so far have been impassable decoration type tiles, but not all impassible decoration type tiles seem to have triggered the bug.
I've identified the main problem i think. The pathing treats ALL events as impassable, so if the route there has events on it and no way through the events even if they are passable, it'll panic and get stuck.
It uses the default MV pathfinding logic. Events can't pass through other events, unless one of them has THROUGH on.
Knowing that helps a lot. I used your plugin to have a "magnet" event in an inaccessible place that drew used, invisible events to it to solve the problem. With that tip i'll be able to make static, invisible events "through" and they shouldn't bother the pathing either. Thanks.
Hello @Shaz, is there a way to set pathfinding via script call? I wanted to "invoe" it from move route, but there is no plugin command option.
is there a way to set pathfinding via script call?

You should be able to do something like this (in the Script call of a move route):

this.setTarget($gamePlayer)

this.setTarget($gameMap.event(id))
where id is the event id you want to move to (event number, no leading zeros)

this.setTarget(null, 10, 20)

this.setTarget(null, $gameVariables.value(1), $gameVariables.value(2))
where variable 1 and 2 are the x and y locations.

I haven't tested these, so hopefully that'll work and not give you any syntax errors or anything.

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