From d95f623ca9c96a24ce269ee7e6a9af5b9d95448e Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 23 Dec 2020 18:07:12 -0800 Subject: [PATCH] Use navmesh to plan sweep missions. https://github.com/Khopa/dcs_liberation/issues/292 --- changelog.md | 2 +- gen/flights/flightplan.py | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 4b9ce9f4..0170c889 100644 --- a/changelog.md +++ b/changelog.md @@ -5,7 +5,7 @@ Saves from 2.3 are not compatible with 2.4. ## Features/Improvements * **[Flight Planner]** Air-to-air and SEAD escorts will no longer be automatically planned for packages that are not in range of threats. -* **[Flight Planner]** BARCAP, TARCAP, and CAS flights will now navigate around threat areas en route to the target area when practical. More types coming soon. +* **[Flight Planner]** BARCAP, TARCAP, CAS, and Fighter Sweep flights will now navigate around threat areas en route to the target area when practical. More types coming soon. # 2.3.3 diff --git a/gen/flights/flightplan.py b/gen/flights/flightplan.py index aef2bb53..56f52e0a 100644 --- a/gen/flights/flightplan.py +++ b/gen/flights/flightplan.py @@ -620,20 +620,22 @@ class StrikeFlightPlan(FormationFlightPlan): @dataclass(frozen=True) class SweepFlightPlan(LoiterFlightPlan): takeoff: FlightWaypoint + nav_to: List[FlightWaypoint] sweep_start: FlightWaypoint sweep_end: FlightWaypoint + nav_from: List[FlightWaypoint] land: FlightWaypoint divert: Optional[FlightWaypoint] lead_time: timedelta def iter_waypoints(self) -> Iterator[FlightWaypoint]: - yield from [ - self.takeoff, - self.hold, - self.sweep_start, - self.sweep_end, - self.land, - ] + yield self.takeoff + yield self.hold + yield from self.nav_to + yield self.sweep_start + yield self.sweep_end + yield from self.nav_from + yield self.land if self.divert is not None: yield self.divert @@ -909,9 +911,10 @@ class FlightPlanBuilder: Args: flight: The flight to generate the flight plan for. """ + assert self.package.waypoints is not None target = self.package.target.position - heading = self._heading_to_package_airfield(target) + heading = self.package.waypoints.join.heading_between_point(target) start = target.point_from_heading(heading, -self.doctrine.sweep_distance.meters) @@ -919,13 +922,19 @@ class FlightPlanBuilder: start, end = builder.sweep(start, target, self.doctrine.ingress_altitude) + hold = builder.hold(self._hold_point(flight)) + return SweepFlightPlan( package=self.package, flight=flight, lead_time=timedelta(minutes=5), takeoff=builder.takeoff(flight.departure), - hold=builder.hold(self._hold_point(flight)), + hold=hold, hold_duration=timedelta(minutes=5), + nav_to=builder.nav_path(hold.position, start.position, + self.doctrine.ingress_altitude), + nav_from=builder.nav_path(end.position, flight.arrival.position, + self.doctrine.ingress_altitude), sweep_start=start, sweep_end=end, land=builder.land(flight.arrival),