Use average NPC's stats to calculate faction camp gained calories #65168
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 "Faction camps now distribute calories based on actual calories and not default calories"
Purpose of change
Fixes #50805
Describe the solution
Initialize a blank npc. Pass it to character::compute_effective_nutrients so it calculates calories from components, instead of simply taking the default.
We use this 'average NPC' as a baseline since we can't (reasonably) know what NPCs are going to eat the food at the time of adding it to the larder. By avoiding using the player avatar we avoid extra crediting/penalizing for CBMs, mutations, etc. that they may have.
Describe alternatives you've considered
Implement some sort of hellish tracking & averaging system to more accurately determine the actual nutritional value your NPCs would get based on past distributions
Testing
Made 1 meat jerky (default 348 calories) out of porkbelly+salt water, worth 975 calories with those ingredients. Installed expanded digestive system CBM on my character, making the inherited meat jerky worth 1,462 calories (to me). Used distribute food mission, got 975 calories, as expected for average NPC. The player character's mutations/CBMs/etc do not influence the outcome, but inherited calories from crafting do.
Repeated test with 5x meat jerky (same method). Received 4,875 calories. Confirmed this is the correct amount.
Debug spawn meat jerky. Distribute food, get 348 calories. Confirmed this is the default amount - and correct for a debug spawned item.
Additional context
Special thanks to @bombasticSlacks