Closed AlwaysElise closed 2 years ago
Well, I've never played so much time to see a 0.5GB size save file. 🤣🤣🤣
But in my test, it's not a problem of NPC pathfinding.
Instead, NPC cannot fetch the corresponding items cause the items are in darkness, hmmmm.
When the items aren't in darkness
When the items are in darkness
By the way, it's okay if the items are in outside with closing door and windows.
I may try to fix this problem later, need some time to look into the code.
I added that change to my local build, and it fixed the issue on that initial save file. Looks like the solution; thanks!
Fetch being possible in the dark is a nice stopgap, but if querying/pathfinding to tools takes so much time, it should be improved somehow (only look for it every couple of ticks? mark zones as 'dirty' when tools are dropped and don't look for tools that aren't in it at all? just some ideas)
Fetch being possible in the dark is a nice stopgap, but if querying/pathfinding to tools takes so much time, it should be improved somehow (only look for it every couple of ticks? mark zones as 'dirty' when tools are dropped and don't look for tools that aren't in it at all? just some ideas)
Literally it is just a bug where the fetch activity is dark capable in former check, but forget to add that to the latter.
Nothing related to pathfinding. The NPC could reach the right location to pick up the tools as you can see in my second gif posted above. They just failed to pass the darkness check so they will keep picking, thus cause the game "freeze".
Description
While player faction NPCs at a faction camp are attempting to do farming tasks, game ticks take extraordinarily long (>1 second). I have a 100% repro save (0.5GB unfortunately) where it is occurring during the player doing autodoc surgery, effectively softlocking the game on the issue. Break All on the application while this is occurring results in a call stack consistently within the NPC behavior code for farming; with an NPC repeatedly planning out a Planting action, which requires acquiring a tool for Tilling, and Fetching a shovel to do so. In range, both a shovel and halligan bar are detected; after letting it run for a while, this behavior continues indefinitely, suggesting the NPC never managed to successfully Fetch the tools. Commenting out code associated with locating a tool to Fetch resolved the issue on a copy of the save. See Additional Context for a bit more info on my testing of it.
Prior to this, during normal play, farming tasks seemed to do similar things for shorter periods of time, slowing down the speed for the player to make a movement into the seconds range.
Steps To Reproduce
Expected behavior
NPC completes tool Fetch task without getting stuck repeatedly doing very expensive queries on what is a fairly standard survivor camp setup.
Versions and configuration
Reproduced with a save (alas, 0.5GB) in both a custom built version from April 24, 2022, and a downloaded release version 82f5658. Unlikely to be affected by changes outside of NPC activity code.
Additional context
Theories:
Further on theory 2 from more testing: Observed an NPC on the Play Now start option stuck outside a closed window while attempting to get shovel for tilling task stored inside the shelter. A nearby, open window was available for pathing, but NPC waited until window on shortest path was opened before proceeding to the tool. In my main save, at least one window is obstructed by non-passable furniture, and tools are stored near several other impassable furniture items. Combined with hundreds more objects to search through, and a large farming area, it seems plausible that the NPC was attempting a Fetch action, interrupted by an obstructed path, and reset back to querying how to do the Farming task again. This suggests to me the most likely cause: NPC Fetch pathfinding resulting in a faulty path the NPC is unable to take, looping back around to a (heavy perf-wise) query of all farm tiles and items in an area on the next action. I think perf cost of this per action attempt would scale on the basis of approximately Number of Farm Tiles * Number of Nearby Items.
Primary fix suggestion: debug the Fetch pathfinding and why it differs from the path the NPC is able to take. This should reduce the number of long-duration Fetch queries firing off continually. Secondary long term perf suggestion: figure out why these actions take so long to process and if there's anything to be done about that.