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

fix: impossible hibernation #2011

Merged

Conversation

leoCottret
Copy link
Collaborator

@leoCottret leoCottret commented Oct 12, 2022

Summary

SUMMARY: Bugfixes "Fix impossible hibernation"

Fixes #2010

Purpose of change

  1. Hibernation could only be triggered with an obscure system taking into account the possible calories you could burn in a day. Even if it could be triggered, the mechanic wasn't clear enough for the average player

Describe the solution

  • now you can hibernate when you're above 90% of maximum stored calories, it's just as simple as that
  • it was also impossible to hibernate since your character would wake up after your fatigue level reached 0. I added an extra condition to ignore the fatigue level
  • also, the rate of hunger was divided by 7 when hibernating, but it did close to nothing. I even tried to reduce it by 100000, this didn't change a thing. So I used a system to compensate the lost calories, taking into account the metabolic rate of the player

Describe alternatives you've considered

  • fixing the bug that makes hunger rate modifications ignored (instead of my 3rd change in Describe the solution)

Testing

  • Tested with light eater, fast metabolism, very fast metabolism, high thirst
  • Being either too thirsty or hungry will wake you up
  • With very fast metabolism, you can almost go through the 7 days of hibernations, from 17500 to ~8000 calories

@leoCottret leoCottret changed the title fix impossible hibernation Fix impossible hibernation Oct 13, 2022
@Coolthulhu Coolthulhu self-assigned this Oct 15, 2022
src/character.cpp Outdated Show resolved Hide resolved
@Coolthulhu
Copy link
Member

the rate of hunger was divided by 7 when hibernating, but it did close to nothing. I even tried to reduce it by 100000, this didn't change a thing. So I used a system to compensate the lost calories, taking into account the metabolic rate of the player

That would suggest something is not working right. This needs to be tested and either fixed or at least made known.

@Coolthulhu Coolthulhu removed their assignment Oct 22, 2022
@scarf005 scarf005 added the src changes related to source code. label Oct 26, 2022
@leoCottret leoCottret marked this pull request as draft October 27, 2022 14:54
@leoCottret leoCottret marked this pull request as ready for review November 10, 2022 21:33
@leoCottret leoCottret marked this pull request as draft November 10, 2022 21:33
@leoCottret
Copy link
Collaborator Author

leoCottret commented Nov 19, 2022

I suppose it's due to a rounding to 1 (probably from the function that updates the stomach).
Setting it to 0 does stop the calories consumption, but anything slightly above will give a similar consumption.

@leoCottret leoCottret marked this pull request as ready for review November 19, 2022 17:27
src/character.cpp Outdated Show resolved Hide resolved
@scarf005 scarf005 changed the title Fix impossible hibernation fix: impossible hibernation Nov 13, 2023
@github-actions github-actions bot added the tests changes related to tests label Dec 2, 2023
@cataclysmbnteam cataclysmbnteam deleted a comment from autofix-ci bot Dec 2, 2023
`kcal_per_time` used `bmr()`, which did not take account of `rates.hunger`.
@scarf005
Copy link
Member

scarf005 commented Dec 2, 2023

Testing

Cataclysm: Bright Nights - f8ca9882cb0e_01

Cataclysm: Bright Nights - f8ca9882cb0e_02

  1. changed time to day 0, 00:00:00.
  2. added bear trait
  3. resetted all basic needs.
  4. slept.
  5. was able to hibernate ~7 days.

Describe Changes

turns out kcal_per_time did not take account of rates.hunger because it used Character::bmr(). at first naively tried kcal_per_time * rates.hunger but it didn't work because it squared metabolic_rate_base.

kcal_per_time 
= bmr() * N
= metabolic_rate_base() * N

rates.hunger
= calc_needs_rates()
= metabolic_rate() * N
= metabolic_rate_base()

therefore, kcal_per_time * rates.hunger = metabolic_rate_base() ^ 2 * N

extracted value into metabolic_base_kcals and multiplied it instead.

Alternatives

buff hibernation metabolic rate further from current 2 to 2.x?

Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The missile is eepy

@scarf005 scarf005 added this pull request to the merge queue Dec 6, 2023
Merged via the queue into cataclysmbnteam:upload with commit 3eb1e89 Dec 6, 2023
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code. tests changes related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to hibernate
5 participants