Skip to content

Commit

Permalink
Merge pull request #77622 from Night-Pryanik/flee
Browse files Browse the repository at this point in the history
Fleeing NPCs will now attack player that got too close
  • Loading branch information
Maleclypse authored Nov 17, 2024
2 parents 0461e7d + d44d34d commit 48c3096
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ void npc::act_on_danger_assessment()
add_msg_debug( debugmode::DF_NPC_COMBATAI, "%s upgrades reposition to flat out retreat.", name );
mem_combat.repositioning = false; // we're not just moving, we're running.
warn_about( "run_away", run_away_for );
set_attitude( NPCATT_FLEE_TEMP );
if( mem_combat.panic > 5 && is_player_ally() && sees( player_character.pos_bub() ) ) {
// consider warning player about panic
int panic_alert = rl_dist( pos(), player_character.pos() ) - player_character.get_per();
Expand Down Expand Up @@ -1368,7 +1369,11 @@ void npc::move()
action = method_of_fleeing();
} else if( ( target == &player_character && attitude == NPCATT_FLEE_TEMP ) ||
has_effect( effect_npc_run_away ) ) {
action = method_of_fleeing();
if( hp_percentage() > 30 && target && rl_dist( pos(), target->pos() ) <= 1 ) {
action = method_of_attack();
} else {
action = method_of_fleeing();
}
} else if( has_effect( effect_asthma ) && ( has_charges( itype_inhaler, 1 ) ||
has_charges( itype_oxygen_tank, 1 ) ||
has_charges( itype_smoxygen_tank, 1 ) ) ) {
Expand Down

0 comments on commit 48c3096

Please sign in to comment.