More accurate switch-wpt index for escort split-trigger

This commit is contained in:
Raffson 2024-01-20 02:55:13 +01:00
parent 181f8583d5
commit f548b27ac5
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 11 additions and 24 deletions

View File

@ -95,6 +95,13 @@ class FlightType(Enum):
FlightType.SEAD_SWEEP,
}
@property
def is_escort_type(self) -> bool:
return self in {
FlightType.ESCORT,
FlightType.SEAD_ESCORT
}
@property
def entity_type(self) -> AirEntity:
return {

View File

@ -21,7 +21,6 @@ from dcs.task import (
RunwayAttack,
Transport,
SEAD,
SwitchWaypoint,
OptJettisonEmptyTanks,
MainTask,
PinpointStrike,
@ -34,7 +33,6 @@ from game.ato import Flight, FlightType
from game.ato.flightplans.aewc import AewcFlightPlan
from game.ato.flightplans.packagerefueling import PackageRefuelingFlightPlan
from game.ato.flightplans.theaterrefueling import TheaterRefuelingFlightPlan
from game.ato.flightwaypointtype import FlightWaypointType
class AircraftBehavior:
@ -285,32 +283,13 @@ class AircraftBehavior:
)
def configure_escort(self, group: FlyingGroup[Any], flight: Flight) -> None:
# Escort groups are actually given the CAP task so they can perform the
# Search Then Engage task, which we have to use instead of the Escort
# task for the reasons explained in JoinPointBuilder.
self.configure_task(flight, group, Escort)
if flight.flight_plan.is_formation(flight.flight_plan):
index = flight.flight_plan.get_index_of_wpt_by_type(
FlightWaypointType.SPLIT
)
if index > 0:
group.add_trigger_action(SwitchWaypoint(None, index))
else:
logging.warning(f"Couldn't determine SPLIT for {group.name}")
self.configure_behavior(
flight, group, roe=OptROE.Values.OpenFire, restrict_jettison=True
)
def configure_sead_escort(self, group: FlyingGroup[Any], flight: Flight) -> None:
# CAS is able to perform all the same tasks as SEAD using a superset of the
# available aircraft, and F-14s are not able to be SEAD despite having TALDs.
# https://forums.eagle.ru/topic/272112-cannot-assign-f-14-to-sead/
self.configure_task(flight, group, SEAD)
index = flight.flight_plan.get_index_of_wpt_by_type(FlightWaypointType.SPLIT)
if index > 0 and flight.flight_plan.is_formation(flight.flight_plan):
group.add_trigger_action(SwitchWaypoint(None, index))
if index < 1:
logging.warning(f"Couldn't determine SPLIT for {group.name}")
self.configure_behavior(
flight,
group,

View File

@ -1,7 +1,5 @@
from dcs.point import MovingPoint
from dcs.task import OptECMUsing, OptFormation, RunScript, SetUnlimitedFuelCommand
from game.settings import Settings
from dcs.task import OptECMUsing, OptFormation, RunScript, SetUnlimitedFuelCommand, SwitchWaypoint
from .pydcswaypointbuilder import PydcsWaypointBuilder
@ -34,3 +32,6 @@ class SplitPointBuilder(PydcsWaypointBuilder):
f'trigger.action.setUserFlag("split-{id(self.package)}", true)'
)
waypoint.tasks.append(script)
elif self.flight.flight_type.is_escort_type:
index = len(self.group.points)
self.group.add_trigger_action(SwitchWaypoint(None, index))