MV/MZ Smarter pathfinding plugin

The thing is, I already tried that and even separate values but the enemy just randomly stutters and stops near the player a lot of the time for whatever reason. I guess my map is just "too big" so it breaks automatically.
a better way is using this (which I made a mini plugin out of it
JavaScript:
Game_Character.prototype.chasePlayer = function() {
    $gameMap._events[this._eventId].moveStraight($gameMap._events[this._eventId].findDirectionTo($gamePlayer.x, $gamePlayer.y));
};

Game_Character.prototype.chasePlayerVariables = function(vx, vy) {
    $gameMap._events[this._eventId].moveStraight($gameMap._events[this._eventId].findDirectionTo($gameVariables.value(vx), $gameVariables.value(vy)));
};

this in a way the event wont get stuck as your gif.
use it like

this.chasePlayer()

or

this.chasePlayerVariables(vx, vy)

and your good to go, so it can work with this plugin without issue, save the above in a plugin.
as its just a snippet I made, and shared in one of the threads as plugin.
a better way is using this
Again: just use this in place of $gameMap._events[this._eventId].

You can certainly argue that making a mini plugin is a bit easier to understand, but it doesn't make any actual difference to the result.
Assuming you're putting this in a Move Route script command, there is no reason to do this:

JavaScript:
$gameMap._events[this._eventId]

It is completely equivalent to just this, which is shorter. Even if for whatever reason you can't put it in a Move Route script command and must put it in a regular script command, the following is again 100% equivalent and also shorter:

JavaScript:
this.character(0)

That wouldn't be the cause of your issue though (since, as I said, both forms are 100% equivalent). Note that the shortened forms are context-sensitive though – one only works in Move Route scripts and the other only works in event Script calls.

Okay, now I'll try to describe what I think are the issues you're seeing, and you can confirm if I got it right.

In the first video, there are two occasions where I see the event is about to touch you but then you back away and the event in turn reverses direction as well. Also, there is one place where it looks like it got stuck at a corner, trying to go down (into the wall) when the correct choice would have been to go left. I'm not quite sure what would cause it to get stuck, unless there's a bug in the passability settings. Reversing direction could happen if it thought the route that appears longer is actually shorter.

In the second video, it appears that the event stops before reaching its goal on several occasions. In other words, it simply won't progress any further until the player moves again. This seems like it could be a bug in the system that caches the path to avoid expensive recomputation on every step – that cache is automatically cleared when the destination changes, so the fact that it comes unstuck when the player moves is a pretty good sign that this is the cause.

Does that seem correct? I see 3 separate issues – getting stuck at a corner, reversing direction when you back away, and stopping randomly. The first and third might be the same, but they might not be.

For the issue of seemingly choosing a "longer" path than optimal, I'd suggest checking a few things:
  • What's the search limit? Did you change it or leave it at the default? This isn't that complicated of a map, so I wouldn't expect problems with the default search limit, but it's possible it could be related.
  • Can you reproduce similar issues by moving the player with the mouse? Like, click in various locations and see whether the player chooses the shortest path to get there.
  • Are there any invisible events on the map? If so, be sure to set them to THROUGH so the enemy can pass over them.
Excuse my sloppy coding, just learned RPG Maker like 1 month ago for a Game Jam nonetheless.

-I didn't touch the search limit at all, should be the default
-Mouse movements seem fine (without your plugin)
-Any invisible events get erased, made them even passthrough
-I tried using the newest version of your plugin and it throws back this error on startup:
1777824797352.png
that's because it probably require his/her core plugin, which has a recursive parser.
so its a reason why it fails.

so you need the core plugin found [here MV] or [here MZ].
it should work after you have its core.
that's because it probably require his/her core plugin, which has a recursive parser.
so its a reason why it fails.

so you need the core plugin found [here MV] or [here MZ].
it should work after you have its core.
Rookie mistake, gonna try again and will get back to you if I got something new
-Mouse movements seem fine (without your plugin)
Are they fine with my plugin? That was the main point.

For what it's worth, SFG_Utils is the same for both MV and MZ.
Are they fine with my plugin? That was the main point.

For what it's worth, SFG_Utils is the same for both MV and MZ.
that's because it probably require his/her core plugin, which has a recursive parser.
so its a reason why it fails.

so you need the core plugin found [here MV] or [here MZ].
it should work after you have its core.
The plugin works fine actually, clicked around and made another room with an event that moves randomly with a <PathChase> Note. The player always caught up and seemingly chose the shortest path

Back to the enemy in my preview. I discovered that the enemy moves perfectly without any issues when the room is rectangular with nothing in it. Yet the moment there's even a hint of a obstacle or the room itself is slightly shaped it just starts breaking down and not working properly anymore
Okay. It's probably worth testing with a higher search limit. I don't know if the search limit could be the issue here, but it is one possibility.
a better way is using this (which I made a mini plugin out of it
JavaScript:
Game_Character.prototype.chasePlayer = function() {
    $gameMap._events[this._eventId].moveStraight($gameMap._events[this._eventId].findDirectionTo($gamePlayer.x, $gamePlayer.y));
};

Game_Character.prototype.chasePlayerVariables = function(vx, vy) {
    $gameMap._events[this._eventId].moveStraight($gameMap._events[this._eventId].findDirectionTo($gameVariables.value(vx), $gameVariables.value(vy)));
};

this in a way the event wont get stuck as your gif.
use it like

this.chasePlayer()

or

this.chasePlayerVariables(vx, vy)

and your good to go, so it can work with this plugin without issue, save the above in a plugin.
as its just a snippet I made, and shared in one of the threads as plugin.
Tried that as well and it just yielded the same result as my original issue lol
I didn't test it together as it works fine on its own.
and there is a lot going on that change this plugin that should make it work without it.

what the snippet does is basicly, walk around impassable tiles and take it.
this doesn't take account like "lave" tiles, or "spikes" if that is added to the SmarterPathfinding plugin.
which walk around it.

question is, do you have something on the map that could "block" this?
does it work with only the path finding plugin or only this snippet?

if it does, than one of your plugins may mess some things up.
where is this plugin placed? on top or bottom or center?
Okay. It's probably worth testing with a higher search limit. I don't know if the search limit could be the issue here, but it is one possibility.
Yeah tried changing that as well and still same issue. Not knowing how I could properly implement your plugin in my context, I tried to add a <PathChase> note manually via script to the player... Nothing.
I have a new version of the plugin with a couple of new things:

  • Avoid a hitch when clicking on an accessible yet impassable tile. This means a tile that you can stand next to and interact with, but which itself is impassable. Note: This currently doesn't include tiles that are only accessible over a counter.
  • Support <SearchLimit> in individual events.
I have a new version of the plugin with a couple of new things:

  • Avoid a hitch when clicking on an accessible yet impassable tile. This means a tile that you can stand next to and interact with, but which itself is impassable. Note: This currently doesn't include tiles that are only accessible over a counter.
  • Support <SearchLimit> in individual events.
Update on my problem, the basic method I used at the very start worked on another device's build flawlessly. Guess my RPG Maker version is just cursed
Upon booting the game in play test I am met with these errors and I have no understanding what it's talking about.
1779555371392.png

1779555312722.png
1779555348514.png
Upon booting the game in play test I am met with these errors and I have no understanding what it's talking about.View attachment 366882
View attachment 366880View attachment 366881
you need his SFG Core plugin which has the utils. above it, as this is missing.
You can find SFG_Utils in my main plugin thread (see my signature).
There's now a new thread for it in the releases section, so any further questions can go there.

Closed at OP's request.

Original thread: https://forums.rpgmakerweb.com/threads/smarter-pathfinding-plugin.180004/