From a013d27d17bfc3863ecb9574ebd15683a7e7d7c1 Mon Sep 17 00:00:00 2001 From: SnappyComebacks <74509817+SnappyComebacks@users.noreply.github.com> Date: Sat, 1 Jan 2022 16:49:04 -0700 Subject: [PATCH] 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. --- changelog.md | 1 + .../aircraft/waypoints/deadingress.py | 6 +++++- .../aircraft/waypoints/joinpoint.py | 16 +++++++++++++++- .../aircraft/waypoints/seadingress.py | 6 +++++- .../aircraft/waypoints/splitpoint.py | 17 +++++++++++++++++ .../aircraft/waypoints/waypointgenerator.py | 2 ++ 6 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 game/missiongenerator/aircraft/waypoints/splitpoint.py diff --git a/changelog.md b/changelog.md index bf9fa408..ee03b816 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ Saves from 5.x are not compatible with 6.0. * **[Mission Generation]** Added an option to fast-forward mission generation until the point of first contact (WIP). * **[Mission Generation]** Add Option to enforce the Easy Communication setting for the mission * **[Flight Planning]** Added the ability to plan tankers for recovery on package flights. AI does not plan. +* **[Flight Planning]** Air to Ground flights now have ECM enabled on lock at the join point, and SEAD/DEAD also have ECM enabled on detection and lock at ingress. * **[Modding]** Add F-104 mod support * **[UI]** Added options to the loadout editor for setting properties such as HMD choice. diff --git a/game/missiongenerator/aircraft/waypoints/deadingress.py b/game/missiongenerator/aircraft/waypoints/deadingress.py index 826afa70..b1e31485 100644 --- a/game/missiongenerator/aircraft/waypoints/deadingress.py +++ b/game/missiongenerator/aircraft/waypoints/deadingress.py @@ -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) diff --git a/game/missiongenerator/aircraft/waypoints/joinpoint.py b/game/missiongenerator/aircraft/waypoints/joinpoint.py index 1842c823..7e7ebb8a 100644 --- a/game/missiongenerator/aircraft/waypoints/joinpoint.py +++ b/game/missiongenerator/aircraft/waypoints/joinpoint.py @@ -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]] diff --git a/game/missiongenerator/aircraft/waypoints/seadingress.py b/game/missiongenerator/aircraft/waypoints/seadingress.py index 22cd75c6..ea0cee99 100644 --- a/game/missiongenerator/aircraft/waypoints/seadingress.py +++ b/game/missiongenerator/aircraft/waypoints/seadingress.py @@ -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) diff --git a/game/missiongenerator/aircraft/waypoints/splitpoint.py b/game/missiongenerator/aircraft/waypoints/splitpoint.py new file mode 100644 index 00000000..1ec079d3 --- /dev/null +++ b/game/missiongenerator/aircraft/waypoints/splitpoint.py @@ -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) diff --git a/game/missiongenerator/aircraft/waypoints/waypointgenerator.py b/game/missiongenerator/aircraft/waypoints/waypointgenerator.py index 86ed3944..c3adabc9 100644 --- a/game/missiongenerator/aircraft/waypoints/waypointgenerator.py +++ b/game/missiongenerator/aircraft/waypoints/waypointgenerator.py @@ -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,