Skip to content

Commit

Permalink
consistent NPC reach range with trigdist
Browse files Browse the repository at this point in the history
  • Loading branch information
David Brown committed Dec 18, 2019
1 parent 572b78f commit 83347ff
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1357,9 +1357,17 @@ npc_action npc::method_of_attack()

// reach attacks are silent and consume no ammo so prefer these if available
int reach_range = weapon.reach_range( *this );
if( reach_range > 1 && reach_range >= dist && clear_shot_reach( pos(), tar ) ) {
add_msg( m_debug, "%s is trying a reach attack", disp_name() );
return npc_reach_attack;
if( !trigdist ) {
if( reach_range > 1 && reach_range >= dist && clear_shot_reach( pos(), tar ) ) {
add_msg( m_debug, "%s is trying a reach attack", disp_name() );
return npc_reach_attack;
}
} else {
if( reach_range > 1 && reach_range >= round( trig_dist( pos(), tar ) ) &&
clear_shot_reach( pos(), tar ) ) {
add_msg( m_debug, "%s is trying a reach attack", disp_name() );
return npc_reach_attack;
}
}

// if the best mode is within the confident range try for a shot
Expand Down

0 comments on commit 83347ff

Please sign in to comment.