Jump to content

[Need Help] Pathfinding Limitations


Recommended Posts

I'm currently working on creating a mod that allows the user to right-click a location on the map (the one you get when you press M, just in case there was any confusion), and their character would start walking to that location.

 

It seems simple enough so I figured it would probably be a good starting point for making my first mod :D, and in just a few hours I had just that functionality. Except that after a certain point it seems that the pathfinding just gives up, and tries to run my character in a straight line. I would assume this is at 40 units (PATHFIND_MAX_RANGE is defined to 40 in scripts/components/locomotor.lua).

 

I initially tried looking into the parameters for 'PathFinder:SubmitSearch', but it only seems to take 6 doubles (the start and end points), and a structure (which contains only two ignore flags).

 

Continuing my search, it seems that the pathfinding algorithm is defined in the exe itself (dontstarve_steam.exe), as I get a hit for what appears to be a symbol definition for 'PathfinderComponent' at 0x323c0f, followed up by a hit for the function 'SubmitSearch' at 0x3247a0. Searching the scripts for anything containing the word 'path' in it's name only yields textures. Outside of these, nothing seems to stick out, other than that the structure of the file as a whole is really weird for a .exe (at least any that I've come across). It definitely starts normal (the usual DOS header string, etc), but exe's are (usually) compiled, and there's an awful lot of text for just plain binary, and the symbols and such almost never look like compiled c++, so maybe it's interpreted internally? Then again the symbol blatantly references "..\\source\\game\\components\\PathfinderComponent.cpp".... now I'm just ranting....

 

 

Back on topic, does anybody know where the pathfinding functions are defined, or maybe just where I can define a range for it?

 

Link to comment
Share on other sites

50 minutes ago, Serpens said:

I think the best way to go would be downloading the "Waypoint" mod and see how it is done there ;)
With that mod you can place markers and then auto-travel to them.

Actually, the "Waypoint" mod's pathfinding sometimes goes haywire too. I have experienced this

Link to comment
Share on other sites

It definitely looks like it's still a limitation in the waypoint mod

Quote

Q: Why does my character not travel to the waypoint correctly? 
A: Waypoint mod uses the in-game's move to function to travel to a destination. If the route is too complex, it will make your character travel simply move straight towards destination ignoring any obstacles.

(- The Steam Workshop)

 

How many mods are out there that make use of long range pathfinding? I'm going to make a pathfinding routine for this mod, and if there's enough demand, I'll take the time to abstract it out.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...