Improve (SEAD) Escort tasking

- Always use holding point when it's a formation attack FP
- More accurate index for SPLIT wpt in triggered action

cleanup
This commit is contained in:
Raffson 2023-03-05 17:45:24 +01:00
parent 0f093d5f54
commit 843bb30b99
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
4 changed files with 32 additions and 15 deletions

View File

@ -8,8 +8,6 @@ from .formationattack import (
FormationAttackLayout, FormationAttackLayout,
) )
from .waypointbuilder import WaypointBuilder from .waypointbuilder import WaypointBuilder
from .. import FlightType
from ...utils import Distance
class EscortFlightPlan(FormationAttackFlightPlan): class EscortFlightPlan(FormationAttackFlightPlan):
@ -32,10 +30,8 @@ class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]):
join = builder.join(self.package.waypoints.join) join = builder.join(self.package.waypoints.join)
split = builder.split(self.package.waypoints.split) split = builder.split(self.package.waypoints.split)
refuel = builder.refuel(self.package.waypoints.refuel) refuel = builder.refuel(self.package.waypoints.refuel)
initial = None
if self.package.primary_task == FlightType.STRIKE:
initial = builder.escort_hold( initial = builder.escort_hold(
self.package.waypoints.initial, Distance.from_feet(20000) self.package.waypoints.initial, self.doctrine.ingress_altitude
) )
return FormationAttackLayout( return FormationAttackLayout(

View File

@ -72,6 +72,15 @@ class FlightPlan(ABC, Generic[LayoutT]):
"""A list of all waypoints in the flight plan, in order.""" """A list of all waypoints in the flight plan, in order."""
return list(self.iter_waypoints()) return list(self.iter_waypoints())
def get_index_of_wpt_by_type(self, wpt_type: FlightWaypointType) -> int:
index = 0
for wpt in self.waypoints:
if wpt and not wpt.only_for_player:
index += 1
if wpt.waypoint_type == wpt_type:
return index
return -1
def iter_waypoints(self) -> Iterator[FlightWaypoint]: def iter_waypoints(self) -> Iterator[FlightWaypoint]:
"""Iterates over all waypoints in the flight plan, in order.""" """Iterates over all waypoints in the flight plan, in order."""
yield from self.layout.iter_waypoints() yield from self.layout.iter_waypoints()

View File

@ -29,6 +29,7 @@ from dcs.unitgroup import FlyingGroup
from game.ato import Flight, FlightType from game.ato import Flight, FlightType
from game.ato.flightplans.aewc import AewcFlightPlan from game.ato.flightplans.aewc import AewcFlightPlan
from game.ato.flightplans.theaterrefueling import TheaterRefuelingFlightPlan from game.ato.flightplans.theaterrefueling import TheaterRefuelingFlightPlan
from game.ato.flightwaypointtype import FlightWaypointType
class AircraftBehavior: class AircraftBehavior:
@ -272,8 +273,14 @@ class AircraftBehavior:
# Search Then Engage task, which we have to use instead of the Escort # Search Then Engage task, which we have to use instead of the Escort
# task for the reasons explained in JoinPointBuilder. # task for the reasons explained in JoinPointBuilder.
group.task = Escort.name group.task = Escort.name
if flight.package.primary_task == FlightType.STRIKE: if flight.flight_plan.is_formation(flight.flight_plan):
group.add_trigger_action(SwitchWaypoint(None, 5)) 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( self.configure_behavior(
flight, group, roe=OptROE.Values.OpenFire, restrict_jettison=True flight, group, roe=OptROE.Values.OpenFire, restrict_jettison=True
) )
@ -283,15 +290,18 @@ class AircraftBehavior:
# available aircraft, and F-14s are not able to be SEAD despite having TALDs. # 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/ # https://forums.eagle.ru/topic/272112-cannot-assign-f-14-to-sead/
group.task = SEAD.name group.task = SEAD.name
if flight.package.primary_task == FlightType.STRIKE: index = flight.flight_plan.get_index_of_wpt_by_type(FlightWaypointType.SPLIT)
group.add_trigger_action(SwitchWaypoint(None, 5)) 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( self.configure_behavior(
flight, flight,
group, group,
roe=OptROE.Values.OpenFire, roe=OptROE.Values.OpenFire,
# ASM includes ARMs and TALDs (among other things, but those are the useful # Guided includes ARMs and TALDs (among other things, but those are the useful
# weapons for SEAD). # weapons for SEAD).
rtb_winchester=OptRTBOnOutOfAmmo.Values.ASM, rtb_winchester=OptRTBOnOutOfAmmo.Values.Guided,
restrict_jettison=True, restrict_jettison=True,
mission_uses_gun=False, mission_uses_gun=False,
) )

View File

@ -118,8 +118,10 @@ class AircraftGenerator:
) )
self.unit_map.add_aircraft(group, flight) self.unit_map.add_aircraft(group, flight)
if ( if (
package.primary_task == FlightType.STRIKE package.primary_flight is not None
and package.primary_flight is not None and package.primary_flight.flight_plan.is_formation(
package.primary_flight.flight_plan
)
): ):
splittrigger = TriggerOnce(Event.NoEvent, f"Split-{id(package)}") splittrigger = TriggerOnce(Event.NoEvent, f"Split-{id(package)}")
splittrigger.add_condition(FlagIsTrue(flag=f"split-{id(package)}")) splittrigger.add_condition(FlagIsTrue(flag=f"split-{id(package)}"))