Skip to content
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

Use average NPC's stats to calculate faction camp gained calories #65168

Conversation

RenechCDDA
Copy link
Member

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.

image

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

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Player Faction Base / Camp All about the player faction base/camp/site astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Apr 18, 2023
@RenechCDDA RenechCDDA force-pushed the faction_camp_calorie_counting_take_two branch from 6418bd9 to fa3ebef Compare April 20, 2023 11:05
@github-actions github-actions bot added the <Bugfix> This is a fix for a bug (or closes open issue) label Apr 20, 2023
@bombasticSlacks bombasticSlacks merged commit e853b23 into CleverRaven:master Apr 21, 2023
@RenechCDDA RenechCDDA deleted the faction_camp_calorie_counting_take_two branch April 22, 2023 00:16
katemonster33 pushed a commit to katemonster33/Cataclysm-DDA that referenced this pull request May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions Player Faction Base / Camp All about the player faction base/camp/site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Faction camp food stores always uses default calories of comestible, not actual calories
2 participants