npc: improve NPC omt_destination finding #30288
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Bugfixes "npc: improve NPC omt_destination finding"
Purpose of change
Playing with NPCs on a city size 0 world is immensely frustrating, because the game slows to a crawl as they spend every turn looking through a 900 overmap tile radius for terrain that isn't there. Make some changes to improve performance under those conditions.
Describe the solution
Increase the number of locations that NPCs will search in order to satisfy their needs.
Reduce the search radius that NPCs will search for a destinationlocation from 900 overmap tiles to 150.
Don't search for destinations if the city size is 0.
If an NPC can't find a destination for any reason, just have them pick a random location and go there instead of having them repeat the searchon the next turn.
Describe alternatives you've considered
The mapgen code should create the lists of possible omt_destinations, but that's going to be a fairly involved bit of code that is beyond the scope of this quick-fix PR.