Skip to content

Commit

Permalink
Fix eternal drowning when NPC is thrown into deep water. (#3269)
Browse files Browse the repository at this point in the history
* fix: NPCs no longer drown eternally after being thrown.

An NPC that was thrown into water would eternally drown, even after
getting back on land.

This also fixes that NPCs take damage from drowning normally while
being submerged in deep water after walking into it instead of being
thrown into it, which may not be a desirable change, since NPC
behaviour does not currently include a lot of deep water avoidance.

* fix: Disable NPCs taking damage from drowning.
  • Loading branch information
cbnbugfix2 authored Sep 27, 2023
1 parent ca88d01 commit 0bbf82d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2461,6 +2461,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set<tripoint> *nomo
if( moved ) {
const tripoint old_pos = pos();
setpos( p );
set_underwater( g->m.is_divable( p ) );
if( old_pos.x - p.x < 0 ) {
facing = FD_RIGHT;
} else {
Expand Down
7 changes: 6 additions & 1 deletion src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ void Character::suffer_while_underwater()
mod_power_level( -bio_gills->power_trigger );
} else {
add_msg_if_player( m_bad, _( "You're drowning!" ) );
apply_damage( nullptr, bodypart_id( "torso" ), rng( 1, 4 ) );
// NPCs are not currently programmed to avoid or get out of deep water,
// so disable drowning damage for them.
// https://github.com/cataclysmbnteam/Cataclysm-BN/issues/3266
if( !is_npc() ) {
apply_damage( nullptr, bodypart_id( "torso" ), rng( 1, 4 ) );
}
}
}
if( has_trait( trait_FRESHWATEROSMOSIS ) && !get_map().has_flag_ter( "SALT_WATER", pos() ) &&
Expand Down

0 comments on commit 0bbf82d

Please sign in to comment.