From f0558c4c1e5fb78efd246891863c9e2749cac6f5 Mon Sep 17 00:00:00 2001 From: Khopa Date: Fri, 23 Apr 2021 23:45:14 +0200 Subject: [PATCH] Fixed ai_flight_planner for maps lacking frontlines (such as battle of britain on The Channel map) --- gen/flights/ai_flight_planner.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/gen/flights/ai_flight_planner.py b/gen/flights/ai_flight_planner.py index 944f2479..69453b37 100644 --- a/gen/flights/ai_flight_planner.py +++ b/gen/flights/ai_flight_planner.py @@ -456,15 +456,25 @@ class ObjectiveFinder: BUT! prefer Cvs. Everybody likes CVs! """ from_frontline = 0 + cp = None + first_friendly_cp = None for c in self.game.theater.controlpoints: - if c.is_carrier and c.is_friendly(self.is_player): - return c - if c.is_friendly(self.is_player) and c.has_frontline: - if c.distance_to(self.front_lines().__next__()) > from_frontline: - from_frontline = c.distance_to(self.front_lines().__next__()) - cp = c - return cp + if c.is_friendly(self.is_player): + if first_friendly_cp is None: + first_friendly_cp = c + if c.is_carrier: + return c + if c.has_active_frontline: + if c.distance_to(self.front_lines().__next__()) > from_frontline: + from_frontline = c.distance_to(self.front_lines().__next__()) + cp = c + + # If no frontlines on the map, return the first friendly cp + if cp is None: + return first_friendly_cp + else: + return cp def enemy_control_points(self) -> Iterator[ControlPoint]: """Iterates over all enemy control points."""