Skip to content

Commit

Permalink
fix: only set cached_dead_state if npc is actually dead (cataclysmb…
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 authored Sep 27, 2023
1 parent c7a9bae commit d7e3588
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,18 @@ auto Character::is_dead_state() const -> bool
}

const auto all_bps = get_all_body_parts( true );
cached_dead_state = std::any_of( all_bps.begin(), all_bps.end(), [this]( const bodypart_id & bp ) {
const bool is_dead = std::any_of( all_bps.begin(), all_bps.end(), [this]( const bodypart_id & bp ) {
return bp->essential && get_part_hp_cur( bp ) <= 0;
} );
return *cached_dead_state;
if( is_dead ) {
cached_dead_state = true;
}
return is_dead;
}

void Character::set_part_hp_cur( const bodypart_id &id, int set )
{
if( set < 0 ) {
if( set <= 0 ) {
cached_dead_state.reset();
}
Creature::set_part_hp_cur( id, set );
Expand Down

0 comments on commit d7e3588

Please sign in to comment.