Skip to content

Commit

Permalink
Added check for being on ground for several cases of falling down (Cl…
Browse files Browse the repository at this point in the history
…everRaven#55128)

* Added check for being on ground for several cases of falling down

* A few more
  • Loading branch information
Night-Pryanik authored Feb 6, 2022
1 parent 54ca282 commit 8fa0f1f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4316,7 +4316,7 @@ cata::optional<int> mutagen_actor::use( Character &p, item &it, bool, const trip

p.add_msg_if_player( m_category.mutagen_message() );

if( one_in( 6 ) ) {
if( one_in( 6 ) && !p.is_on_ground() ) {
p.add_msg_player_or_npc( m_bad,
_( "You suddenly feel dizzy, and collapse to the ground." ),
_( "<npcname> suddenly collapses to the ground!" ) );
Expand Down
24 changes: 16 additions & 8 deletions src/player_hardcoded_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static void eff_fun_datura( Character &u, effect &it )
}
if( dur > 600_minutes && one_in( 768 ) ) {
u.mod_pain( rng( -3, -24 ) );
if( dur > 800_minutes && one_in( 16 ) ) {
if( dur > 800_minutes && one_in( 16 ) && !u.is_on_ground() ) {
u.add_msg_if_player( m_bad,
_( "You're experiencing loss of basic motor skills and blurred vision. Your mind recoils in horror, unable to communicate with your spinal column." ) );
u.add_msg_if_player( m_bad, _( "You stagger and fall!" ) );
Expand Down Expand Up @@ -779,7 +779,7 @@ static void eff_fun_hypovolemia( Character &u, effect &it )
u.mod_stamina( -500 * intense );
break;
case 6:
if( one_in( 2 ) ) {
if( one_in( 2 ) && !u.is_on_ground() ) {
warning = _( "You drop to the ground, fighting to keep yourself conscious." );
u.add_effect( effect_downed, rng( 1_minutes, 2_minutes ) );
break;
Expand Down Expand Up @@ -907,8 +907,10 @@ static void eff_fun_redcells_anemia( Character &u, effect &it )
u.add_effect( effect_lying_down, rng( 2_minutes, 5_minutes ) );
break;
case 6:
u.add_msg_if_player( m_bad, _( "You must sit down for a moment. Just a moment." ) );
u.add_effect( effect_downed, rng( 1_minutes, 2_minutes ) );
if( !u.is_on_ground() ) {
u.add_msg_if_player( m_bad, _( "You must sit down for a moment. Just a moment." ) );
u.add_effect( effect_downed, rng( 1_minutes, 2_minutes ) );
}
break;
case 7: // 7-9 empty for variability, as messages stack on higher intensity
case 8:
Expand Down Expand Up @@ -1349,7 +1351,9 @@ void Character::hardcoded_effects( effect &it )
add_miss_reason( _( "Your muscles are locking up and you can't fight effectively." ), 4 );
if( one_in( 3072 ) ) {
add_msg_if_player( m_bad, _( "Your muscles spasm." ) );
schedule_effect( effect_downed, rng( 1_turns, 4_turns ), false, 0, true );
if( !is_on_ground() ) {
schedule_effect( effect_downed, rng( 1_turns, 4_turns ), false, 0, true );
}
schedule_effect( effect_stunned, rng( 1_turns, 4_turns ) );
if( one_in( 10 ) ) {
mod_pain( rng( 1, 10 ) );
Expand Down Expand Up @@ -1598,7 +1602,9 @@ void Character::hardcoded_effects( effect &it )
add_msg_if_player( m_bad, _( "You lose control of your body as it begins to convulse!" ) );
time_duration td = rng( 30_seconds, 4_minutes );
schedule_effect( effect_motor_seizure, td );
schedule_effect( effect_downed, td );
if( !is_on_ground() ) {
schedule_effect( effect_downed, td );
}
schedule_effect( effect_stunned, td );
if( one_in( 3 ) ) {
add_msg_if_player( m_bad, _( "You lose consciousness!" ) );
Expand Down Expand Up @@ -1628,7 +1634,7 @@ void Character::hardcoded_effects( effect &it )
}
}
} else if( limb == "leg" ) {
if( dice( 4, 4 ) > get_dex() ) {
if( dice( 4, 4 ) > get_dex() && !is_on_ground() ) {
schedule_effect( effect_downed, rng( 5_seconds, 10_seconds ) );
} else {
add_msg_if_player( m_neutral, _( "However, you manage to keep your footing." ) );
Expand All @@ -1640,7 +1646,9 @@ void Character::hardcoded_effects( effect &it )
add_msg_if_player( m_bad,
_( "You suddenly lose all muscle tone, and can't support your own weight!" ) );
schedule_effect( effect_motor_seizure, rng( 1_seconds, 2_seconds ) );
schedule_effect( effect_downed, rng( 5_seconds, 10_seconds ) );
if( !is_on_ground() ) {
schedule_effect( effect_downed, rng( 5_seconds, 10_seconds ) );
}
}
mod *= 2;
/* fallthrough */
Expand Down
12 changes: 7 additions & 5 deletions src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,9 +1289,9 @@ void suffer::from_stimulants( Character &you, const int current_stim )
{
// Stim +250 kills
if( current_stim > 210 ) {
if( one_turn_in( 2_minutes ) && !you.has_effect( effect_downed ) ) {
if( one_turn_in( 2_minutes ) && !you.is_on_ground() ) {
you.add_msg_if_player( m_bad, _( "Your muscles spasm!" ) );
if( !you.has_effect( effect_downed ) ) {
if( !you.is_on_ground() ) {
you.add_msg_if_player( m_bad, _( "You fall to the ground!" ) );
you.add_effect( effect_downed, rng( 6_turns, 20_turns ) );
}
Expand Down Expand Up @@ -1321,7 +1321,9 @@ void suffer::from_stimulants( Character &you, const int current_stim )
if( one_turn_in( 3_minutes ) && !you.in_sleep_state() ) {
you.add_msg_if_player( m_bad, _( "You black out!" ) );
const time_duration dur = rng( 30_minutes, 60_minutes );
you.add_effect( effect_downed, dur );
if( !you.is_on_ground() ) {
you.add_effect( effect_downed, dur );
}
you.add_effect( effect_blind, dur );
you.fall_asleep( dur );
}
Expand All @@ -1336,7 +1338,7 @@ void suffer::from_stimulants( Character &you, const int current_stim )
if( one_turn_in( 15_seconds ) && !you.has_effect( effect_sleep ) ) {
you.add_msg_if_player( m_bad, _( "You feel dizzy for a moment." ) );
you.mod_moves( -rng( 10, 30 ) );
if( one_in( 3 ) && !you.has_effect( effect_downed ) ) {
if( one_in( 3 ) && !you.is_on_ground() ) {
you.add_msg_if_player( m_bad, _( "You stumble and fall over!" ) );
you.add_effect( effect_downed, rng( 3_turns, 10_turns ) );
}
Expand Down Expand Up @@ -1516,7 +1518,7 @@ void suffer::without_sleep( Character &you, const int sleep_deprivation )
you.moves -= 10;
you.add_msg_player_or_npc( m_warning, _( "Your shaking legs make you stumble." ),
_( "<npcname> stumbles." ) );
if( !you.has_effect( effect_downed ) && one_in( 10 ) ) {
if( !you.is_on_ground() && one_in( 10 ) ) {
you.add_msg_player_or_npc( m_bad, _( "You fall over!" ), _( "<npcname> falls over!" ) );
you.add_effect( effect_downed, rng( 3_turns, 10_turns ) );
}
Expand Down

0 comments on commit 8fa0f1f

Please sign in to comment.