Skip to content

Commit

Permalink
Merge pull request #36232 from davidpwbrown/npc_reach_diagonal
Browse files Browse the repository at this point in the history
Consistent NPC reach range with trigdist
  • Loading branch information
ZhilkinSerg authored Dec 18, 2019
2 parents c3ae589 + 83347ff commit e81d01a
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 e81d01a

Please sign in to comment.