Add ECM behavior to not Air to Air flights (#1879)

* If a plane has a jammer, and it is not an air to air flight it will jam between join and split.
This commit is contained in:
SnappyComebacks
2022-01-01 16:49:04 -07:00
committed by GitHub
parent 641c21627e
commit a013d27d17
6 changed files with 45 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import logging
from dcs.point import MovingPoint
from dcs.task import AttackGroup, WeaponType
from dcs.task import AttackGroup, OptECMUsing, WeaponType
from game.theater import TheaterGroundObject
from .pydcswaypointbuilder import PydcsWaypointBuilder
@@ -32,3 +32,7 @@ class DeadIngressBuilder(PydcsWaypointBuilder):
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
# Preemptively use ECM to better avoid getting swatted.
ecm_option = OptECMUsing(value=OptECMUsing.Values.UseIfDetectedLockByRadar)
waypoint.tasks.append(ecm_option)

View File

@@ -1,7 +1,7 @@
from typing import List, Type
from dcs.point import MovingPoint
from dcs.task import ControlledTask, EngageTargets, TargetType, Targets
from dcs.task import ControlledTask, EngageTargets, OptECMUsing, TargetType, Targets
from game.ato import FlightType
from game.utils import nautical_miles
@@ -18,11 +18,25 @@ class JoinPointBuilder(PydcsWaypointBuilder):
Targets.All.Air.Planes.MultiroleFighters,
],
)
elif self.flight.flight_type == FlightType.SEAD_ESCORT:
self.configure_escort_tasks(
waypoint, [Targets.All.GroundUnits.AirDefence.AAA.SAMRelated]
)
# Let the AI use ECM to preemptively defend themselves.
ecm_option = OptECMUsing(value=OptECMUsing.Values.UseIfDetectedLockByRadar)
waypoint.tasks.append(ecm_option)
elif not self.flight.flight_type.is_air_to_air:
# Capture any non A/A type to avoid issues with SPJs that use the primary radar such as the F/A-18C.
# You can bully them with STT to not be able to fire radar guided missiles at you,
# so best choice is to not let them perform jamming for now.
# Let the AI use ECM to defend themselves.
ecm_option = OptECMUsing(value=OptECMUsing.Values.UseIfOnlyLockByRadar)
waypoint.tasks.append(ecm_option)
@staticmethod
def configure_escort_tasks(
waypoint: MovingPoint, target_types: List[Type[TargetType]]

View File

@@ -1,7 +1,7 @@
import logging
from dcs.point import MovingPoint
from dcs.task import AttackGroup, WeaponType
from dcs.task import AttackGroup, OptECMUsing, WeaponType
from game.theater import TheaterGroundObject
from .pydcswaypointbuilder import PydcsWaypointBuilder
@@ -32,3 +32,7 @@ class SeadIngressBuilder(PydcsWaypointBuilder):
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
# Preemptively use ECM to better avoid getting swatted.
ecm_option = OptECMUsing(value=OptECMUsing.Values.UseIfDetectedLockByRadar)
waypoint.tasks.append(ecm_option)

View File

@@ -0,0 +1,17 @@
from dcs.point import MovingPoint
from dcs.task import OptECMUsing
from .pydcswaypointbuilder import PydcsWaypointBuilder
class SplitPointBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None:
if not self.flight.flight_type.is_air_to_air:
# Capture any non A/A type to avoid issues with SPJs that use the primary radar such as the F/A-18C.
# You can bully them with STT to not be able to fire radar guided missiles at you,
# so best choice is to not let them perform jamming for now.
# Let the AI use ECM to defend themselves.
ecm_option = OptECMUsing(value=OptECMUsing.Values.UseIfOnlyLockByRadar)
waypoint.tasks.append(ecm_option)

View File

@@ -27,6 +27,7 @@ from .deadingress import DeadIngressBuilder
from .default import DefaultWaypointBuilder
from .holdpoint import HoldPointBuilder
from .joinpoint import JoinPointBuilder
from .splitpoint import SplitPointBuilder
from .landingpoint import LandingPointBuilder
from .ocaaircraftingress import OcaAircraftIngressBuilder
from .ocarunwayingress import OcaRunwayIngressBuilder
@@ -127,6 +128,7 @@ class WaypointGenerator:
FlightWaypointType.INGRESS_STRIKE: StrikeIngressBuilder,
FlightWaypointType.INGRESS_SWEEP: SweepIngressBuilder,
FlightWaypointType.JOIN: JoinPointBuilder,
FlightWaypointType.SPLIT: SplitPointBuilder,
FlightWaypointType.LANDING_POINT: LandingPointBuilder,
FlightWaypointType.LOITER: HoldPointBuilder,
FlightWaypointType.PATROL: RaceTrackEndBuilder,