Improve AI SEAD capabilities

This commit is contained in:
Raffson
2023-04-15 20:44:57 +02:00
parent bf23ee4e8f
commit fad48ebaed
4 changed files with 48 additions and 8 deletions

View File

@@ -190,6 +190,10 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
ingress_type, self.package.waypoints.ingress, self.package.target
)
initial = None
if ingress_type == FlightWaypointType.INGRESS_SEAD:
initial = builder.sead_search(self.package.target)
return FormationAttackLayout(
departure=builder.takeoff(self.flight.departure),
hold=hold,
@@ -198,6 +202,7 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
),
join=join,
ingress=ingress,
initial=initial,
targets=target_waypoints,
split=split,
refuel=refuel,

View File

@@ -290,12 +290,9 @@ class WaypointBuilder:
return self._target_area(f"STRIKE {target.name}", target)
def sead_area(self, target: MissionTarget) -> FlightWaypoint:
# Set flyover with ingress altitude to allow the flight to search and engage
# the target group at the ingress alt without suicide dive
return self._target_area(
f"SEAD on {target.name}",
target,
flyover=True,
altitude=self.doctrine.ingress_altitude,
alt_type="BARO",
)
@@ -316,8 +313,8 @@ class WaypointBuilder:
# plan.
return self._target_area(f"ASSAULT {target.name}", target)
@staticmethod
def _target_area(
self,
name: str,
location: MissionTarget,
flyover: bool = False,
@@ -425,6 +422,29 @@ class WaypointBuilder:
pretty_name="Orbit",
)
def sead_search(self, target: MissionTarget) -> FlightWaypoint:
"""Creates custom waypoint for AI SEAD flights
to avoid having them fly all the way to the SAM site.
Args:
target: Target information.
"""
# Use the threat range as offset distance to avoid flying all the way to the SAM site
assert self.flight.package.waypoints
ingress = self.flight.package.waypoints.ingress
threat_range = 1.1 * max([x.threat_range for x in target.strike_targets]).meters
hdg = target.position.heading_between_point(ingress)
hold = target.position.point_from_heading(hdg, threat_range)
return FlightWaypoint(
"SEAD Search",
FlightWaypointType.CUSTOM,
hold,
self.doctrine.ingress_altitude,
alt_type="BARO",
description="Anchor and search from this point",
pretty_name="SEAD Search",
)
@staticmethod
def escort_hold(start: Point, altitude: Distance) -> FlightWaypoint:
"""Creates custom waypoint for escort flights that need to hold.