Skip to content

Commit

Permalink
Don't make NPC angry if he's already dead (CleverRaven#55689)
Browse files Browse the repository at this point in the history
  • Loading branch information
Night-Pryanik authored Mar 3, 2022
1 parent 1faf786 commit 3046771
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "map.h"
#include "messages.h"
#include "monster.h"
#include "npc.h"
#include "optional.h"
#include "options.h"
#include "point.h"
Expand Down Expand Up @@ -433,6 +434,11 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri
}
critter->deal_projectile_attack( null_source ? nullptr : origin, attack, print_messages,
wp_attack );

if( critter->is_npc() ) {
critter->as_npc()->on_attacked( *origin );
}

// Critter can still dodge the projectile
// In this case hit_critter won't be set
if( attack.hit_critter != nullptr ) {
Expand Down
2 changes: 1 addition & 1 deletion src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ void npc::on_attacked( const Creature &attacker )
if( is_hallucination() ) {
die( nullptr );
}
if( attacker.is_avatar() && !is_enemy() ) {
if( attacker.is_avatar() && !is_enemy() && !is_dead() ) {
make_angry();
hit_by_player = true;
}
Expand Down
1 change: 0 additions & 1 deletion src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3642,7 +3642,6 @@ void target_ui::on_target_accepted( bool harmful )
// TODO: get rid of this. Or combine it with effect_hit_by_player
guy->hit_by_player = true; // used for morale penalty
}
guy->make_angry();
}
} else if( monster *const mon = dynamic_cast<monster *>( lt_ptr.get() ) ) {
mon->add_effect( effect_hit_by_player, 10_minutes );
Expand Down

0 comments on commit 3046771

Please sign in to comment.