Feed NPCs using their stomachs when they eat from faction camps #47720
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
Bugfixes "NPCs now eat from faction camps using their stomachs, eliminating phantom hunger pangs"
Purpose of change
Fixes #47663
Prior to this, NPCs simply teleported calories directly into their fat stores, which bypassed the entire stomach system. This was causing various oddities in behavior when they ate from faction camps compared to eating regular food.
Describe the solution
I simply created a fake food_summary item, filled it with the calories they would have otherwise teleported, and stuffed it into their bellies. The volume of the fake food is enough to fill them up without making them vomit, which is good enough for now but can certainly be improved if faction camps do more detailed food tracking in the future.
There were a few other minor changes as well:
Describe alternatives you've considered
I considered giving the fake food a fixed volume or volume dependent on calories, but it was hard to balance in a way to keep NPCs from eating too much and vomiting.
I considered giving the fake food vitamins, but vitamin deficiencies do nothing right now and if that changes in the future faction camps should be updated to track vitamins anyway.
I also considered more detailed tracking of vitamins and/or food volumes in the camp store, but that would be a much bigger sweeping change that would be better suited for after 0.F.
Testing
Scenarios I tested, using the debug tools introduced in #47716
Incidentally, these would make good unit tests but I'm entirely unsure how to create a working faction camp in a unit test, so I wasn't able to implement them :(
Additional context
While messing around with this code, I observed that the hunger variable is now completely controlled by
update_stomach()
. Thus, any calls toset_hunger()
ormod_hunger()
outside of that method do absolutely nothing long term and almost certainly need to be changed.See #47391 for examples of other places that still use
mod_hunger()