MZ Maze Pathfinding

Hi hi! been a minute since I've been on the forums, got burnt out on development for a while but I'm getting back to it!

I've been struggling with this one section for a while (contributing factor to my hiatus on dev work) and I was hoping there might be a better solution out there? I've tried pretty much every pathfinding plugin out there (kotc's which I had a bizarre series of bugs with and ultimately didn't even end up functioning most of the time, schach pathfinding which got stuck more than rpg maker's built-in pathfinding did, theoallen's which I couldn't get to work either, and the only one I've found but haven't tried is this visual pathfinding by undermax which I was going to purchase to try and see if it worked the way I wanted, but their art is AI generated and I'd rather deal with RMMZ's default pathfinding than financially support that) and nothing has functioned properly.

The section in question is rather large, a maze sitting pretty at 95x84 (with a buffer of 6-8 tiles at the edges so the screen doesn't shift awkwardly at the edges when I have it zoomed in, a large amount of real estate is actually just walls so you can't see over them) and the mechanic itself is a sort of hide and seek - you explore the maze to find a character a few times, and then you have to find a place to hide yourself. The goal is to have the character search through the maze for you with pseudo-random paths (not actually random movement, I have him path to point A, then check to see if he should go to point B or C, and so on)

Initially I did this with move routes, which was painful, clumsy, and inexplicably broke at random, now I'm transitioning over to points of interest with the built-in RMMZ pathfinding and move route scripts, but it loves getting stuck on walls and I need to separate it into much smaller pieces for it to stop running back and forth and entirely killing the tension (alongside never actually ending the section, because the character needs to finish its sweep of the maze before the next sequence begins) which poses a similarly tedious problem to move routes.

Is there literally ANY way to have better pathfinding in-engine? I am willing to pay to have a plugin commissioned for this. Below is an exported map image if it helps, I have it randomly pick a path at every crossroads so outside of the few long, straight corridors he's only moving a maximum of around 20 tiles per command ideally. This should help with the issue I've heard of where complex pathfinding can cause lag.

My current system runs on a parallel so the player can, if they want to, decide to creep out of their hiding spot while he searches (and I can follow him around while playtesting to make sure things are working, which they are not) and I included an exported image of the map (so, without any event markers, but there are none that restrict movement outside of one stopping the player from hiding in the starting area that leads out of the maze in the top right and the event that searches starts below the hitbox for this) at the bottom of this post.

Ideally it would also be able to be stopped by a trigger, ex. a self switch or some other external factor since I have the event being moved around via another event and just handling the command to activate the line of sight plugin I'm using for him to be able to actually react when he finds the player but I can probably find a workaround for this if I need to.

If I've been unclear about anything, I would be happy to clarify where I can! Also, if I mistagged the post, let me know? I'm still a bit new to actually posting on the forum.
TL;DR: I'm looking for pathfinding that works in areas bigger than a single screen's width and doesn't want to push me down the stairs. thank you kindly!

Map015.png
I don't have MZ in but to be clear, it should create a path from point A to B
and avoid blocking wall path, find the best route without getting stuck?

so if you click, it take the shortest route => blocked at the wall because it can't
reach it instead of going around it cleanly?

building this stuff can be complex, but you may be able to omit it and use eventing
that can work out.

at each cross path and or T split ways, put a region (1,2,3,4,5 etc) than check player
location, than find path to other based on where to go follow the regions numbers.

this can be complex if its far bigger than that though, out circle can be 1, inner 2,
deeper inner 3 etc.

but visual path like undermax is something I don't know, it looks cool, but seeing
it, it also check the shortest path, not avoiding spikes/lava as it should and is
something I would do in the checks for tileset => dmg tiles => avoid.

there was a thread about path finding always correct how complex you made it.
but creating it in the maker, it may take some time.
I think the pathfinding that exists in the engine is probably sufficient for your purposes. Specifically, the pathfinding used when you click on the map with the mouse. This is a standard A* algorithm crippled by a search depth limit. So that means you need to do two things:

  • Make the event in question actually use that pathfinding. By default, it's only ever used for the player.
  • Increase the search depth limit so it can find its way through the maze.

The search depth limit can be changed like so:

JavaScript:
Game_Event.prototype.searchLimit = function() {
    return 100;
};

The default limit is 12. I've found that 100 works well for quite twisty corridors, but for an actual maze, you might need to crank it up even higher.

To make events actually use that pathfinding, your options include Shaz's Smart Pathfinding or Aerosys's Advanced Move Route. (The latter also allows customizing the search depth limit in the plugin parameters; I'm not sure if its pathfinding functionality is what you need though.)

This is somewhat tangential, but you could also use my own pathfinding plugin (note: it probably conflicts with Aerosys's). My plugin focuses on making the pathfinding a little smarter about the route it selects – for example, avoiding things that technically aren't obstacles, or understanding bridges.
I think the pathfinding that exists in the engine is probably sufficient for your purposes. Specifically, the pathfinding used when you click on the map with the mouse. This is a standard A* algorithm crippled by a search depth limit. So that means you need to do two things:

  • Make the event in question actually use that pathfinding. By default, it's only ever used for the player.
  • Increase the search depth limit so it can find its way through the maze.

The search depth limit can be changed like so:

JavaScript:
Game_Event.prototype.searchLimit = function() {
    return 100;
};

The default limit is 12. I've found that 100 works well for quite twisty corridors, but for an actual maze, you might need to crank it up even higher.

To make events actually use that pathfinding, your options include Shaz's Smart Pathfinding or Aerosys's Advanced Move Route. (The latter also allows customizing the search depth limit in the plugin parameters; I'm not sure if its pathfinding functionality is what you need though.)

This is somewhat tangential, but you could also use my own pathfinding plugin (note: it probably conflicts with Aerosys's). My plugin focuses on making the pathfinding a little smarter about the route it selects – for example, avoiding things that technically aren't obstacles, or understanding bridges.
Thank you (both) kindly for your response!

I tried out everything I could, and while Shaz's had the same issue, it did work out straightaway when I added the script line you wrote to it. I couldn't find Aerosys's Advanced Move Route anywhere, but I did try out your plugin because it seems terribly in-depth and I quite appreciate its out-of-the-box alterations to the move routes rather than requiring a separate commend. Had the funniest issue of events moving at the speed of light during testing regardless of what the event's speed was set to, and ran into a function error before I wisened up and added your utils plugin, but I fixed the speed issue by setting the event's speed via move route specifically beforehand.

I'll probably go forward using your plugin, since I'll admit I like your presentation, and being able to customize the limit for each map is VERY helpful. Thanks again for your assistance, you're a lifesaver!
I couldn't find Aerosys's Advanced Move Route anywhere
For what it's work, the exact name is MK_AdvancedMove.js.

It looks like you're using MZ? If you find any issues with my plugin in MZ, please let me know in the plugin thread.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/maze-pathfinding.181855/