Use convoy spawn points defined by the campaign.

The start/end points of the waypoints that define the course of the
front line also define the spawn points for convoys. Use them.

https://github.com/Khopa/dcs_liberation/issues/824
This commit is contained in:
Dan Albert 2021-04-18 23:57:13 -07:00
parent d4679e0029
commit d11c9a4615
3 changed files with 14 additions and 10 deletions

View File

@ -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]:

View File

@ -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

View File

@ -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)}",