Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't make NPC angry if he's already dead #55689

Merged
merged 3 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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