Add BAI missions.

BAI is used for attacking ground vehicles as opposed to buildings like
strike does, and not air defenses like DEAD does. Unlike strike, BAI is
tolerant of moving targets.

Fixes https://github.com/Khopa/dcs_liberation/issues/216
This commit is contained in:
Dan Albert
2020-11-16 21:05:53 -08:00
parent 8bd00bf450
commit 9fb33526a7
6 changed files with 80 additions and 11 deletions

View File

@@ -64,6 +64,7 @@ class FlightWaypointType(Enum):
INGRESS_ESCORT = 19
INGRESS_DEAD = 20
INGRESS_SWEEP = 21
INGRESS_BAI = 22
class FlightWaypoint:

View File

@@ -629,7 +629,9 @@ class FlightPlanBuilder:
custom_targets: Optional[List[Unit]]) -> FlightPlan:
# TODO: Flesh out mission types.
task = flight.flight_type
if task == FlightType.BARCAP:
if task == FlightType.BAI:
return self.generate_bai(flight)
elif task == FlightType.BARCAP:
return self.generate_barcap(flight)
elif task == FlightType.CAS:
return self.generate_cas(flight)
@@ -702,6 +704,23 @@ class FlightPlanBuilder:
return self.strike_flightplan(flight, location, targets)
def generate_bai(self, flight: Flight) -> StrikeFlightPlan:
"""Generates a BAI flight plan.
Args:
flight: The flight to generate the flight plan for.
"""
location = self.package.target
if not isinstance(location, TheaterGroundObject):
raise InvalidObjectiveLocation(flight.flight_type, location)
targets: List[StrikeTarget] = []
for group in location.groups:
targets.append(StrikeTarget(f"{group.id}", group))
return self.strike_flightplan(flight, location, targets)
def generate_barcap(self, flight: Flight) -> BarCapFlightPlan:
"""Generate a BARCAP flight at a given location.
@@ -965,7 +984,9 @@ class FlightPlanBuilder:
@staticmethod
def target_waypoint(flight: Flight, builder: WaypointBuilder,
target: StrikeTarget) -> FlightWaypoint:
if flight.flight_type == FlightType.DEAD:
if flight.flight_type == FlightType.BAI:
return builder.bai_group(target)
elif flight.flight_type == FlightType.DEAD:
return builder.dead_point(target)
elif flight.flight_type == FlightType.SEAD:
return builder.sead_point(target)
@@ -1068,7 +1089,6 @@ class FlightPlanBuilder:
assert self.package.waypoints is not None
builder = WaypointBuilder(self.game.conditions, flight, self.doctrine,
targets)
# sead_types = {FlightType.DEAD, FlightType.SEAD}
if flight.flight_type is FlightType.SEAD:
ingress = builder.ingress_sead(self.package.waypoints.ingress,
location)
@@ -1076,6 +1096,9 @@ class FlightPlanBuilder:
elif flight.flight_type is FlightType.DEAD:
ingress = builder.ingress_dead(self.package.waypoints.ingress,
location)
elif flight.flight_type is FlightType.BAI:
ingress = builder.ingress_bai(self.package.waypoints.ingress,
location)
else:
ingress = builder.ingress_strike(self.package.waypoints.ingress,
location)

View File

@@ -5,6 +5,7 @@ from typing import List, Optional, Tuple, Union
from dcs.mapping import Point
from dcs.unit import Unit
from dcs.unitgroup import VehicleGroup
from game.data.doctrine import Doctrine
from game.utils import nm_to_meter
@@ -17,7 +18,7 @@ from ..runways import RunwayAssigner
@dataclass(frozen=True)
class StrikeTarget:
name: str
target: Union[TheaterGroundObject, Unit]
target: Union[VehicleGroup, TheaterGroundObject, Unit]
class WaypointBuilder:
@@ -168,6 +169,11 @@ class WaypointBuilder:
objective: MissionTarget) -> FlightWaypoint:
return self._ingress(FlightWaypointType.INGRESS_ESCORT, position,
objective)
def ingress_bai(self, position: Point,
objective: MissionTarget) -> FlightWaypoint:
return self._ingress(FlightWaypointType.INGRESS_BAI, position,
objective)
def ingress_dead(self, position:Point,
objective: MissionTarget) -> FlightWaypoint:
@@ -211,6 +217,9 @@ class WaypointBuilder:
waypoint.name = "EGRESS"
return waypoint
def bai_group(self, target: StrikeTarget) -> FlightWaypoint:
return self._target_point(target, f"ATTACK {target.name}")
def dead_point(self, target: StrikeTarget) -> FlightWaypoint:
return self._target_point(target, f"STRIKE {target.name}")