Split Anti-Ship from BAI

This commit is contained in:
Raffson 2023-06-03 19:01:55 +02:00
parent 2ed85792b9
commit bbf8e69659
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
5 changed files with 41 additions and 9 deletions

View File

@ -35,7 +35,7 @@ class Builder(FormationAttackBuilder[AntiShipFlightPlan, FormationAttackLayout])
else:
raise InvalidObjectiveLocation(self.flight.flight_type, location)
return self._build(FlightWaypointType.INGRESS_BAI, targets)
return self._build(FlightWaypointType.INGRESS_ANTI_SHIP, targets)
@staticmethod
def anti_ship_targets_for_tgo(tgo: NavalGroundObject) -> list[StrikeTarget]:

View File

@ -49,3 +49,4 @@ class FlightWaypointType(IntEnum):
REFUEL = 29 # Should look for nearby tanker to refuel from.
CARGO_STOP = 30 # Stopover landing point using the LandingReFuAr waypoint type
INGRESS_AIR_ASSAULT = 31
INGRESS_ANTI_SHIP = 32

View File

@ -0,0 +1,34 @@
import logging
from dcs.point import MovingPoint
from dcs.task import AttackGroup, OptFormation, WeaponType
from game.theater import NavalControlPoint
from .pydcswaypointbuilder import PydcsWaypointBuilder
class AntiShipIngressBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None:
group_names = []
waypoint.tasks.append(OptFormation.finger_four_open())
target = self.package.target
if isinstance(target, NavalControlPoint):
carrier_name = target.get_carrier_group_name()
if carrier_name:
group_names.append(carrier_name)
else:
logging.error(
"Unexpected target type for Anti-Ship mission: %s",
target.__class__.__name__,
)
return
for group_name in group_names:
miz_group = self.mission.find_group(group_name)
if miz_group is None:
logging.error("Could not find group for Anti-Ship mission %s", group_name)
continue
task = AttackGroup(miz_group.id, weapon_type=WeaponType.Auto)
waypoint.tasks.append(task)

View File

@ -3,13 +3,14 @@ import logging
from dcs.point import MovingPoint
from dcs.task import AttackGroup, OptFormation, WeaponType
from game.theater import NavalControlPoint, TheaterGroundObject
from game.theater import TheaterGroundObject
from game.transfers import MultiGroupTransport
from .pydcswaypointbuilder import PydcsWaypointBuilder
class BaiIngressBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None:
waypoint.tasks.append(OptFormation.trail_open())
# TODO: Add common "UnitGroupTarget" base type.
group_names = []
target = self.package.target
@ -18,10 +19,6 @@ class BaiIngressBuilder(PydcsWaypointBuilder):
group_names.append(group.group_name)
elif isinstance(target, MultiGroupTransport):
group_names.append(target.name)
elif isinstance(target, NavalControlPoint):
carrier_name = target.get_carrier_group_name()
if carrier_name:
group_names.append(carrier_name)
else:
logging.error(
"Unexpected target type for BAI mission: %s",
@ -37,5 +34,3 @@ class BaiIngressBuilder(PydcsWaypointBuilder):
task = AttackGroup(miz_group.id, weapon_type=WeaponType.Auto)
waypoint.tasks.append(task)
waypoint.tasks.append(OptFormation.trail_open())

View File

@ -21,14 +21,15 @@ from game.missiongenerator.missiondata import MissionData
from game.settings import Settings
from game.utils import pairwise
from .airassaultingress import AirAssaultIngressBuilder
from .antishipingress import AntiShipIngressBuilder
from .baiingress import BaiIngressBuilder
from .landingzone import LandingZoneBuilder
from .casingress import CasIngressBuilder
from .deadingress import DeadIngressBuilder
from .default import DefaultWaypointBuilder
from .holdpoint import HoldPointBuilder
from .joinpoint import JoinPointBuilder
from .landingpoint import LandingPointBuilder
from .landingzone import LandingZoneBuilder
from .ocaaircraftingress import OcaAircraftIngressBuilder
from .ocarunwayingress import OcaRunwayIngressBuilder
from .pydcswaypointbuilder import PydcsWaypointBuilder, TARGET_WAYPOINTS
@ -138,6 +139,7 @@ class WaypointGenerator:
FlightWaypointType.REFUEL: RefuelPointBuilder,
FlightWaypointType.CARGO_STOP: CargoStopBuilder,
FlightWaypointType.INGRESS_AIR_ASSAULT: AirAssaultIngressBuilder,
FlightWaypointType.INGRESS_ANTI_SHIP: AntiShipIngressBuilder,
}
builder = builders.get(waypoint.waypoint_type, DefaultWaypointBuilder)
return builder(