diff --git a/src/player.cpp b/src/player.cpp index bb4ffaace766a..9f62b8ddd2fc6 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -5383,10 +5383,12 @@ std::vector player::get_visible_creatures( const int range ) const std::vector player::get_targetable_creatures( const int range ) const { return g->get_creatures_if( [this, range]( const Creature & critter ) -> bool { + bool can_see = ( ( sees( critter ) && g->m.sees( pos(), critter.pos(), 100 ) ) //the call to map.sees is to make sure that even if we can see it through walls + || sees_with_infrared( critter ) ); //via a mutation or cbm we only attack targets with a line of sight + bool in_range = round( rl_dist_exact( pos(), critter.pos() ) ) <= range; // TODO: get rid of fake npcs (pos() check) - return this != &critter && pos() != critter.pos() && attitude_to( critter ) != Creature::Attitude::A_FRIENDLY && - round( rl_dist_exact( pos(), critter.pos() ) ) <= range && - ( sees( critter ) || sees_with_infrared( critter ) ); + bool valid_target = this != &critter && pos() != critter.pos() && attitude_to( critter ) != Creature::Attitude::A_FRIENDLY; + return valid_target && in_range && can_see; } ); }