Skip to content

Commit

Permalink
AI goals: do not protect units hidden from the AI
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsc committed Dec 7, 2018
1 parent 8160d9a commit d0f1b27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ai/composite/goal.cpp
Expand Up @@ -263,8 +263,12 @@ void protect_goal::add_targets(std::back_insert_iterator< std::vector< target >>
const unit_filter ufilt{ vconfig(criteria) };
for (const unit &u : units)
{
//TODO: we will protect hidden units, by not testing for invisibility to current side
if (ufilt(u)) {
// 'protect_unit' can be set to any unit of any side -> exclude hidden units
// unless they are visible to the AI side (e.g. allies with shared vision).
// As is done in other parts of the AI, units under fog/shroud count as visible to the AI.
if (ufilt(u)
&& (!u.invisible(u.get_location()) || u.is_visible_to_team(current_team(), false)))
{
DBG_AI_GOAL << "side " << get_side() << ": in " << goal_type << ": " << u.get_location() << " should be protected\n";
items.insert(u.get_location());
}
Expand Down

0 comments on commit d0f1b27

Please sign in to comment.