Skip to content

Commit

Permalink
suffer: move stimulant based suffering into its own function
Browse files Browse the repository at this point in the history
Move the stimulant based suffering into its own function.
  • Loading branch information
mlangsdorf committed Nov 8, 2019
1 parent 36d2be8 commit aedaa08
Showing 1 changed file with 60 additions and 64 deletions.
124 changes: 60 additions & 64 deletions src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,66 @@ void Character::suffer_from_artifacts()

void Character::suffer_from_stimulants( const int current_stim )
{
if( current_stim == 0 ) {
return;
// Stim +250 kills
if( current_stim > 210 ) {
if( one_turn_in( 2_minutes ) && !has_effect( effect_downed ) ) {
add_msg_if_player( m_bad, _( "Your muscles spasm!" ) );
if( !has_effect( effect_downed ) ) {
add_msg_if_player( m_bad, _( "You fall to the ground!" ) );
add_effect( effect_downed, rng( 6_turns, 20_turns ) );
}
}
}
if( current_stim > 170 ) {
if( !has_effect( effect_winded ) && calendar::once_every( 10_minutes ) ) {
add_msg( m_bad, _( "You feel short of breath." ) );
add_effect( effect_winded, 10_minutes + 1_turns );
}
}
if( current_stim > 110 ) {
if( !has_effect( effect_shakes ) && calendar::once_every( 10_minutes ) ) {
add_msg( _( "You shake uncontrollably." ) );
add_effect( effect_shakes, 15_minutes + 1_turns );
}
}
if( current_stim > 75 ) {
if( !one_turn_in( 2_minutes ) && !has_effect( effect_nausea ) ) {
add_msg( _( "You feel nauseous…" ) );
add_effect( effect_nausea, 5_minutes );
}
}

//stim -200 or painkillers 240 kills
if( current_stim < -160 || get_painkiller() > 200 ) {
if( one_turn_in( 3_minutes ) && !in_sleep_state() ) {
add_msg_if_player( m_bad, _( "You black out!" ) );
const time_duration dur = rng( 30_minutes, 60_minutes );
add_effect( effect_downed, dur );
add_effect( effect_blind, dur );
fall_asleep( dur );
}
}
if( current_stim < -120 || get_painkiller() > 160 ) {
if( !has_effect( effect_winded ) && calendar::once_every( 10_minutes ) ) {
add_msg( m_bad, _( "Your breathing slows down." ) );
add_effect( effect_winded, 10_minutes + 1_turns );
}
}
if( current_stim < -85 || get_painkiller() > 145 ) {
if( one_turn_in( 15_seconds ) && !has_effect( effect_sleep ) ) {
add_msg_if_player( m_bad, _( "You feel dizzy for a moment." ) );
mod_moves( -rng( 10, 30 ) );
if( one_in( 3 ) && !has_effect( effect_downed ) ) {
add_msg_if_player( m_bad, _( "You stumble and fall over!" ) );
add_effect( effect_downed, rng( 3_turns, 10_turns ) );
}
}
}
if( current_stim < -60 || get_painkiller() > 130 ) {
if( calendar::once_every( 10_minutes ) ) {
add_msg( m_warning, _( "You feel tired…" ) );
mod_fatigue( rng( 1, 2 ) );
}
}
}

Expand Down Expand Up @@ -1382,68 +1440,6 @@ void Character::suffer()
suffer_from_radiation();
suffer_from_bad_bionics();
suffer_from_stimulants( current_stim );
// Stim +250 kills
if( current_stim > 210 ) {
if( one_turn_in( 2_minutes ) && !has_effect( effect_downed ) ) {
add_msg_if_player( m_bad, _( "Your muscles spasm!" ) );
if( !has_effect( effect_downed ) ) {
add_msg_if_player( m_bad, _( "You fall to the ground!" ) );
add_effect( effect_downed, rng( 6_turns, 20_turns ) );
}
}
}
if( current_stim > 170 ) {
if( !has_effect( effect_winded ) && calendar::once_every( 10_minutes ) ) {
add_msg( m_bad, _( "You feel short of breath." ) );
add_effect( effect_winded, 10_minutes + 1_turns );
}
}
if( current_stim > 110 ) {
if( !has_effect( effect_shakes ) && calendar::once_every( 10_minutes ) ) {
add_msg( _( "You shake uncontrollably." ) );
add_effect( effect_shakes, 15_minutes + 1_turns );
}
}
if( current_stim > 75 ) {
if( !one_turn_in( 2_minutes ) && !has_effect( effect_nausea ) ) {
add_msg( _( "You feel nauseous…" ) );
add_effect( effect_nausea, 5_minutes );
}
}

//stim -200 or painkillers 240 kills
if( current_stim < -160 || get_painkiller() > 200 ) {
if( one_turn_in( 3_minutes ) && !in_sleep_state() ) {
add_msg_if_player( m_bad, _( "You black out!" ) );
const time_duration dur = rng( 30_minutes, 60_minutes );
add_effect( effect_downed, dur );
add_effect( effect_blind, dur );
fall_asleep( dur );
}
}
if( current_stim < -120 || get_painkiller() > 160 ) {
if( !has_effect( effect_winded ) && calendar::once_every( 10_minutes ) ) {
add_msg( m_bad, _( "Your breathing slows down." ) );
add_effect( effect_winded, 10_minutes + 1_turns );
}
}
if( current_stim < -85 || get_painkiller() > 145 ) {
if( one_turn_in( 15_seconds ) && !has_effect( effect_sleep ) ) {
add_msg_if_player( m_bad, _( "You feel dizzy for a moment." ) );
mod_moves( -rng( 10, 30 ) );
if( one_in( 3 ) && !has_effect( effect_downed ) ) {
add_msg_if_player( m_bad, _( "You stumble and fall over!" ) );
add_effect( effect_downed, rng( 3_turns, 10_turns ) );
}
}
}
if( current_stim < -60 || get_painkiller() > 130 ) {
if( calendar::once_every( 10_minutes ) ) {
add_msg( m_warning, _( "You feel tired…" ) );
mod_fatigue( rng( 1, 2 ) );
}
}

int sleep_deprivation = !in_sleep_state() ? get_sleep_deprivation() : 0;
// Stimulants can lessen the PERCEIVED effects of sleep deprivation, but
// they do nothing to cure it. As such, abuse is even more dangerous now.
Expand Down

0 comments on commit aedaa08

Please sign in to comment.