Skip to content

Commit

Permalink
Fixed Coughing during a cold prevents sleeping even when Dead Tired (C…
Browse files Browse the repository at this point in the history
…leverRaven#35372)

* rebalance cough

* Fix cough suppresion and make effects smaller but more frequent

* Remove fatigue effect

* changed balance to reduce fatigue restore

* Changed name to be less confusing
  • Loading branch information
Ramza13 authored and AMurkin committed Nov 13, 2019
1 parent 863b07b commit 3e9c31f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,10 @@
"type": "effect_type",
"id": "has_prospectus"
},
{
"type": "effect_type",
"id": "recently_coughed"
},
{
"type": "effect_type",
"id": "ignore_fall_damage",
Expand Down
14 changes: 6 additions & 8 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const efftype_id effect_common_cold( "common_cold" );
const efftype_id effect_contacts( "contacts" );
const efftype_id effect_controlled( "controlled" );
const efftype_id effect_cough_suppress( "cough_suppress" );
const efftype_id effect_recently_coughed( "recently_coughed" );
const efftype_id effect_crushed( "crushed" );
const efftype_id effect_darkness( "darkness" );
const efftype_id effect_disinfected( "disinfected" );
Expand Down Expand Up @@ -5123,6 +5124,10 @@ int Character::item_store_cost( const item &it, const item & /* container */, bo

void Character::cough( bool harmful, int loudness )
{
if( has_effect( effect_cough_suppress ) ) {
return;
}

if( harmful ) {
const int stam = get_stamina();
const int malus = get_stamina_max() * 0.05; // 5% max stamina
Expand All @@ -5132,10 +5137,6 @@ void Character::cough( bool harmful, int loudness )
}
}

if( has_effect( effect_cough_suppress ) ) {
return;
}

if( !is_npc() ) {
add_msg( m_bad, _( "You cough heavily." ) );
}
Expand All @@ -5144,10 +5145,7 @@ void Character::cough( bool harmful, int loudness )

moves -= 80;

if( has_effect( effect_sleep ) && !has_effect( effect_narcosis ) &&
( ( harmful && one_in( 3 ) ) || one_in( 10 ) ) ) {
wake_up();
}
add_effect( effect_recently_coughed, 5_minutes );
}


Expand Down
4 changes: 4 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const efftype_id effect_common_cold( "common_cold" );
const efftype_id effect_contacts( "contacts" );
const efftype_id effect_corroding( "corroding" );
const efftype_id effect_cough_suppress( "cough_suppress" );
const efftype_id effect_recently_coughed( "recently_coughed" );
const efftype_id effect_darkness( "darkness" );
const efftype_id effect_datura( "datura" );
const efftype_id effect_deaf( "deaf" );
Expand Down Expand Up @@ -2885,6 +2886,9 @@ void player::update_needs( int rate_multiplier )
sleep.set_duration( 1_turns );
mod_fatigue( -25 );
} else {
if( has_effect( effect_recently_coughed ) ) {
recovered *= .5;
}
mod_fatigue( -recovered );
if( get_option< bool >( "SLEEP_DEPRIVATION" ) ) {
// Sleeping on the ground, no bionic = 1x rest_modifier
Expand Down

0 comments on commit 3e9c31f

Please sign in to comment.