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 shivering mechanism #60991

Closed
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/character_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ void Character::update_bodytemp()
/* Cache calls to g->get_temperature( player position ), used in several places in function */
const units::temperature player_local_temp = weather_man.get_temperature( pos() );
// NOTE : visit weather.h for some details on the numbers used
// Converts temperature to Celsius/10
// Converts temperature to Celsius/100
int Ctemperature = static_cast<int>( 100 * units::to_celcius( player_local_temp ) );
const w_point weather = *weather_man.weather_precise;
int vehwindspeed = 0;
Expand All @@ -427,7 +427,8 @@ void Character::update_bodytemp()
const bool use_floor_warmth = can_use_floor_warmth();
const furn_id furn_at_pos = here.furn( pos() );
const cata::optional<vpart_reference> boardable = vp.part_with_feature( "BOARDABLE", true );
// Temperature norms
// Temperature norms, unit is Celsius/100
// This means which temperature is comfortable for a naked person
// Ambient normal temperature is lower while asleep
const int ambient_norm = has_sleep ? 3100 : 1900;

Expand Down Expand Up @@ -484,7 +485,8 @@ void Character::update_bodytemp()
continue;
}

// This adjusts the temperature scale to match the bodytemp scale,
// 0.01c is 5 body temp unit so it needs to times 5 to scale to match the bodytemp scale,
// but this will change current behavior,
// it needs to be reset every iteration
int adjusted_temp = Ctemperature - ambient_norm;
// Represents the fact that the body generates heat when it is cold.
Expand Down Expand Up @@ -738,13 +740,17 @@ void Character::update_bodytemp()
// Note: Numbers are based off of BODYTEMP at the top of weather.h
// If torso is BODYTEMP_COLD which is 34C, the early stages of hypothermia begin
// constant shivering will prevent the player from falling asleep.
// Lowering this threshold to BODYTEMP_VERY_COLD because currently temp_cur is added up
// by numbers that are in different unit.
// Otherwise, if any other body part is BODYTEMP_VERY_COLD, or 31C
// AND you have frostbite, then that also prevents you from sleeping
if( in_sleep_state() && !has_effect( effect_narcosis ) ) {
if( bp == body_part_torso && temp_after <= BODYTEMP_COLD && !has_bionic( bio_sleep_shutdown ) ) {
if( bp == body_part_torso && temp_after <= BODYTEMP_VERY_COLD &&
get_fatigue() <= fatigue_levels::DEAD_TIRED && !has_bionic( bio_sleep_shutdown ) ) {
add_msg( m_warning, _( "Your shivering prevents you from sleeping." ) );
wake_up();
} else if( bp != body_part_torso && temp_after <= BODYTEMP_VERY_COLD &&
get_fatigue() <= fatigue_levels::DEAD_TIRED &&
has_effect( effect_frostbite ) && !has_bionic( bio_sleep_shutdown ) ) {
add_msg( m_warning, _( "You are too cold. Your frostbite prevents you from sleeping." ) );
wake_up();
Expand Down