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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 3 deletions

View File

@ -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]** 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 * **[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]** 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 * **[Modding]** Add F-104 mod support
* **[UI]** Added options to the loadout editor for setting properties such as HMD choice. * **[UI]** Added options to the loadout editor for setting properties such as HMD choice.

View File

@ -1,7 +1,7 @@
import logging import logging
from dcs.point import MovingPoint from dcs.point import MovingPoint
from dcs.task import AttackGroup, WeaponType from dcs.task import AttackGroup, OptECMUsing, WeaponType
from game.theater import TheaterGroundObject from game.theater import TheaterGroundObject
from .pydcswaypointbuilder import PydcsWaypointBuilder from .pydcswaypointbuilder import PydcsWaypointBuilder
@ -32,3 +32,7 @@ class DeadIngressBuilder(PydcsWaypointBuilder):
task.params["altitudeEnabled"] = False task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True task.params["groupAttack"] = True
waypoint.tasks.append(task) 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 typing import List, Type
from dcs.point import MovingPoint 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.ato import FlightType
from game.utils import nautical_miles from game.utils import nautical_miles
@ -18,11 +18,25 @@ class JoinPointBuilder(PydcsWaypointBuilder):
Targets.All.Air.Planes.MultiroleFighters, Targets.All.Air.Planes.MultiroleFighters,
], ],
) )
elif self.flight.flight_type == FlightType.SEAD_ESCORT: elif self.flight.flight_type == FlightType.SEAD_ESCORT:
self.configure_escort_tasks( self.configure_escort_tasks(
waypoint, [Targets.All.GroundUnits.AirDefence.AAA.SAMRelated] 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 @staticmethod
def configure_escort_tasks( def configure_escort_tasks(
waypoint: MovingPoint, target_types: List[Type[TargetType]] waypoint: MovingPoint, target_types: List[Type[TargetType]]

View File

@ -1,7 +1,7 @@
import logging import logging
from dcs.point import MovingPoint from dcs.point import MovingPoint
from dcs.task import AttackGroup, WeaponType from dcs.task import AttackGroup, OptECMUsing, WeaponType
from game.theater import TheaterGroundObject from game.theater import TheaterGroundObject
from .pydcswaypointbuilder import PydcsWaypointBuilder from .pydcswaypointbuilder import PydcsWaypointBuilder
@ -32,3 +32,7 @@ class SeadIngressBuilder(PydcsWaypointBuilder):
task.params["altitudeEnabled"] = False task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True task.params["groupAttack"] = True
waypoint.tasks.append(task) 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 .default import DefaultWaypointBuilder
from .holdpoint import HoldPointBuilder from .holdpoint import HoldPointBuilder
from .joinpoint import JoinPointBuilder from .joinpoint import JoinPointBuilder
from .splitpoint import SplitPointBuilder
from .landingpoint import LandingPointBuilder from .landingpoint import LandingPointBuilder
from .ocaaircraftingress import OcaAircraftIngressBuilder from .ocaaircraftingress import OcaAircraftIngressBuilder
from .ocarunwayingress import OcaRunwayIngressBuilder from .ocarunwayingress import OcaRunwayIngressBuilder
@ -127,6 +128,7 @@ class WaypointGenerator:
FlightWaypointType.INGRESS_STRIKE: StrikeIngressBuilder, FlightWaypointType.INGRESS_STRIKE: StrikeIngressBuilder,
FlightWaypointType.INGRESS_SWEEP: SweepIngressBuilder, FlightWaypointType.INGRESS_SWEEP: SweepIngressBuilder,
FlightWaypointType.JOIN: JoinPointBuilder, FlightWaypointType.JOIN: JoinPointBuilder,
FlightWaypointType.SPLIT: SplitPointBuilder,
FlightWaypointType.LANDING_POINT: LandingPointBuilder, FlightWaypointType.LANDING_POINT: LandingPointBuilder,
FlightWaypointType.LOITER: HoldPointBuilder, FlightWaypointType.LOITER: HoldPointBuilder,
FlightWaypointType.PATROL: RaceTrackEndBuilder, FlightWaypointType.PATROL: RaceTrackEndBuilder,