-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support pathfinding avoiding sharp objects (barbed wire etc) #37964
Conversation
Moving this to WIP because there's now some weird unintended behaviour in manual movement. Working on it. |
Removed WIP tag, the test cases I was using are replicable in master with pit traps and auto-travel. |
Did significantly more testing with overmap auto-move. This PR appears to fully resolve the "raspberry bush problem" at the expense of making raspberry bushes and other sharp objects effectively impassable terrain for automove. I think that's a good thing but it's entirely possible I have missed an edge case. This PR makes territory fully bordered by sharp objects un-navigable by auto-move, so if that causes problems I'm not aware of, please let me know. |
I think thats fine, automove shouldnt do anything risky or annoying, the player can do that themselves if they want to. |
I feel like that should only be false for unintelligent monsters like zombies or the blob. It's hard to have a pet dog right now when they routinely impale themselves on barbed wire and jagged wreckage because they won't path around it. |
@jeremyshannon thanks for the tip. Opening a separate issue for that, this PR does add a JSON flag to allow that to be specified per monster. |
Summary
SUMMARY: Bugfixes "Avoid sharp things in player pathfinding"
Purpose of change
Fixes #37928 by preventing the player from auto-pathing into sharp things (barbed wire fences etc).
Describe the solution
I added a new pathfinding setting, to avoid sharp things, and set it to default true for the player and NPCs and false for monsters.
I made sharp items unpathable if avoid_sharp=true, because there is an issue with route_adjacent in activity_item_handling.cpp. In farming, route_adjacent is called. That method looks up the closest adjacent square to the target "to be planted" square, and if there is a valid path, regardless of cost, it will go to the first valid adjacent square. So I couldn't just give sharp objects a high cost, because path cost isn't taken into account in route_adjacent if the high-cost tile is the destination adjacent tile.
Describe alternatives you've considered
I considered just adding sharp-object-avoidance to the avoid_traps behaviour. This still seems like a reasonable alternative if there is going to never be a situation where pathfinding should avoid either traps or sharp things but not the other.
Testing
I did quite a lot of testing with pathfinding related to farming automation. I did not do a lot of testing related to non-farm-automation pathfinding.
Example of the types of setups I was testing:
Additional context
This is my second C++ commit of any significance, I've picked a couple doozies between fuel consumption and pathfinding. I would not be at all surprised if I have made some rookie mistakes and welcome all feedback.
I also expect, but have not confirmed, that this commit will fix some other annoyances with player auto-pathfinding into bushes and barbed wires.