From 04a8040292198f821e27f2b065af42e991576749 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 17 Jul 2021 15:37:45 -0700 Subject: [PATCH] Prevent carriers from claiming most TGOs. The naval CP generators will only spawn ships, so if any of the other TGO types were closest to the CV or LHA they just would not be generated. --- changelog.md | 2 ++ game/theater/conflicttheater.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 16a2c500..4b131551 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,8 @@ Saves from 3.x are not compatible with 5.0. ## Fixes +* **[Campaign]** Naval control points will no longer claim ground objectives during campaign generation and prevent them from spawning. + # 4.1.0 Saves from 4.0.0 are compatible with 4.1.0. diff --git a/game/theater/conflicttheater.py b/game/theater/conflicttheater.py index 43cd2c9d..95e53ac9 100644 --- a/game/theater/conflicttheater.py +++ b/game/theater/conflicttheater.py @@ -389,8 +389,10 @@ class MizCampaignLoader: origin, list(reversed(waypoints)) ) - def objective_info(self, near: Positioned) -> Tuple[ControlPoint, Distance]: - closest = self.theater.closest_control_point(near.position) + def objective_info( + self, near: Positioned, allow_naval: bool = False + ) -> Tuple[ControlPoint, Distance]: + closest = self.theater.closest_control_point(near.position, allow_naval) distance = meters(closest.position.distance_to_point(near.position)) return closest, distance @@ -402,7 +404,7 @@ class MizCampaignLoader: ) for ship in self.ships: - closest, distance = self.objective_info(ship) + closest, distance = self.objective_info(ship, allow_naval=True) closest.preset_locations.ships.append( PointWithHeading.from_point(ship.position, ship.units[0].heading) ) @@ -644,10 +646,14 @@ class ConflictTheater: def enemy_points(self) -> List[ControlPoint]: return list(self.control_points_for(player=False)) - def closest_control_point(self, point: Point) -> ControlPoint: + def closest_control_point( + self, point: Point, allow_naval: bool = False + ) -> ControlPoint: closest = self.controlpoints[0] closest_distance = point.distance_to_point(closest.position) for control_point in self.controlpoints[1:]: + if control_point.is_fleet and not allow_naval: + continue distance = point.distance_to_point(control_point.position) if distance < closest_distance: closest = control_point