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

Fix antennae handling for auto attacking #37686

Merged
merged 4 commits into from
Feb 4, 2020
Merged
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
8 changes: 5 additions & 3 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5383,10 +5383,12 @@ std::vector<Creature *> player::get_visible_creatures( const int range ) const
std::vector<Creature *> 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;
} );
}

Expand Down