diff --git a/game/theater/conflicttheater.py b/game/theater/conflicttheater.py index 33a48b8c..1da19a05 100644 --- a/game/theater/conflicttheater.py +++ b/game/theater/conflicttheater.py @@ -335,13 +335,20 @@ class MizCampaignLoader: f"No control point near the final waypoint of {group.name}" ) + convoy_origin = waypoints[0] + convoy_destination = waypoints[-1] + # Snap the begin and end points to the control points. waypoints[0] = origin.position waypoints[-1] = destination.position front_line_id = f"{origin.id}|{destination.id}" front_lines[front_line_id] = ComplexFrontLine(origin, waypoints) - self.control_points[origin.id].connect(self.control_points[destination.id]) - self.control_points[destination.id].connect(self.control_points[origin.id]) + self.control_points[origin.id].connect( + self.control_points[destination.id], convoy_origin + ) + self.control_points[destination.id].connect( + self.control_points[origin.id], convoy_destination + ) return front_lines def objective_info(self, group: Group) -> Tuple[ControlPoint, Distance]: diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index 0803b393..2be2feb2 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -267,6 +267,7 @@ class ControlPoint(MissionTarget, ABC): # TODO: Should be Airbase specific. self.has_frontline = has_frontline self.connected_points: List[ControlPoint] = [] + self.convoy_spawns: Dict[ControlPoint, Point] = {} self.base: Base = Base() self.cptype = cptype # TODO: Should be Airbase specific. @@ -392,8 +393,9 @@ class ControlPoint(MissionTarget, ABC): ... # TODO: Should be Airbase specific. - def connect(self, to: ControlPoint) -> None: + def connect(self, to: ControlPoint, convoy_location: Point) -> None: self.connected_points.append(to) + self.convoy_spawns[to] = convoy_location self.stances[to.id] = CombatStance.DEFENSIVE @abstractmethod diff --git a/gen/convoys.py b/gen/convoys.py index ff9f9ccc..520902ea 100644 --- a/gen/convoys.py +++ b/gen/convoys.py @@ -31,14 +31,9 @@ class ConvoyGenerator: self.generate_convoy_for(transfer) def generate_convoy_for(self, transfer: RoadTransferOrder) -> None: - # TODO: Add convoy spawn points to campaign so these can start on/near a road. - # Groups that start with an on-road waypoint that are not on a road will move to - # the road one at a time. Spawning them arbitrarily at the control point spawns - # them on the runway (or in a FOB structure) and they'll take forever to get to - # a road. - origin = transfer.position.position next_hop = transfer.path()[0] - destination = next_hop.position + origin = transfer.position.convoy_spawns[next_hop] + destination = next_hop.convoy_spawns[transfer.position] group = self._create_mixed_unit_group( f"Convoy {next(self.count)}",