Sorry to disappoint if you were one of the people in BCC following along with this but I don't think I have the capacity to finish this project. Pathfinding algorithms are over my head and I just haven't had the time to do the research, and with the future of Blockland becoming more and more uncertain I haven't had much motivation to work on it either. That may change, but nonetheless it feels wrong to just sit on it indefinitely so here you go.
I did my best to write comments to kinda explain what's going on in here. You are free to use this code however you want.
https://cdn.discordapp.com/attachments/609001398087974943/621229227395645451/System_WRathfinder.zipBasic usage:
- Type
wrath_generateNodeMap(); in console. This will create nodes for your entire build. If your build is too big it might explode and crash your game.
- Type
wrath_newPath("start coordinates", "end coordinates"); in console. The system will now increment through nodes to try and 'find' the goal node from the start node and will dump a bunch of information into your console during the process. The example
wrathfinder_newPath("-54.75 -56.25 0.5", "73.75 91.25 13.3"); will look between one corner of Afghan DM to a roof of a building at the opposite corner.
This wont produce any useful information, the shortest path isn't actually cached, it just stops once it finds its way through the nodes. The framework is there though. I think what I'd try to do would be to add a heuristic to every node visited in the path based on what time/order it was visited, and then increment through the path again, but always going to the neighbor with the highest heuristic. That should give you the shortest path through the visited nodes but not necessarily the actually shortest path.
Also features a tool that can place and delete nodes, the intent was to try and make it so you could create your own, way more efficient node graphs manually. You can equip it with
/nodeGun. It seems to do a pretty stuffty job of finding nodes when deleting/linking though so careful if you intend to use it with generated maps with thousands of nodes.