RndName 1bb7e1bf47 Change SEAD task to Search and Engage for ARM weapon
SEAD flights will have the Search and Engage Group Task instead of the current AttackGroup task when the flight has ARM weapons in the Loadout. This resolves an issue with AI not able to attack a SAM when skynet is used. This is due to the RADAR not emitting and the AI therefore just diving into the SAM.
Non-ARM Loadouts will still use the AttackGroup task. This ensures that for example the ADM-141 TALD used by the F-14s will work correctly
2022-04-02 10:16:11 +02:00

55 lines
2.4 KiB
Python

import logging
from dcs.point import MovingPoint
from dcs.task import AttackGroup, EngageGroup, OptECMUsing, WeaponType as DcsWeaponType
from game.data.weapons import WeaponType
from game.theater import TheaterGroundObject
from .pydcswaypointbuilder import PydcsWaypointBuilder
class SeadIngressBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None:
self.register_special_waypoints(self.waypoint.targets)
target = self.package.target
if not isinstance(target, TheaterGroundObject):
logging.error(
"Unexpected target type for SEAD mission: %s",
target.__class__.__name__,
)
return
for group in target.groups:
miz_group = self.mission.find_group(group.group_name)
if miz_group is None:
logging.error(
f"Could not find group for SEAD mission {group.group_name}"
)
continue
if self.flight.loadout.has_weapon_of_type(WeaponType.ARM):
# Special handling for ARM Weapon types:
# The SEAD flight will Search for the targeted group and then engage it
# if it is found only. This will prevent AI from having huge problems
# when skynet is enabled and the Radar is not emitting. They dive
# into the SAM instead of waiting for it to come alive
engage_task = EngageGroup(miz_group.id)
engage_task.params["weaponType"] = DcsWeaponType.Guided.value
waypoint.tasks.append(engage_task)
else:
# All non ARM types like Decoys will use the normal AttackGroup Task
attack_task = AttackGroup(
miz_group.id, weapon_type=DcsWeaponType.Guided
)
attack_task.params["expend"] = "All"
attack_task.params["attackQtyLimit"] = False
attack_task.params["directionEnabled"] = False
attack_task.params["altitudeEnabled"] = False
attack_task.params["groupAttack"] = True
waypoint.tasks.append(attack_task)
# Preemptively use ECM to better avoid getting swatted.
ecm_option = OptECMUsing(value=OptECMUsing.Values.UseIfDetectedLockByRadar)
waypoint.tasks.append(ecm_option)