From a0fdfa11e2c93660a5bfadaad7e0621d7e0cc5db Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:07:01 +1000 Subject: [PATCH] Fix anti-runway task generation for LGBs. --- changelog.md | 1 + .../aircraft/waypoints/ocarunwayingress.py | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 5fa38ca2..c64c40ce 100644 --- a/changelog.md +++ b/changelog.md @@ -219,6 +219,7 @@ BAI/ANTISHIP/DEAD/STRIKE/BARCAP/CAS/OCA/AIR-ASSAULT (main) missions * **[Data]** Fixed the class of the Samuel Chase so it can't be picked for a AAA or SHORAD site. * **[Data]** Allow CH-47D, CH-53E and UH-60A to operate from carriers and LHAs. * **[Mission Generation]** Restored previous AI behavior for anti-ship missions. A DCS update caused only a single aircraft in a flight to attack. The full flight will now attack like they used to. +* **[Mission Generation]** Fix generation of OCA Runway missions to allow LGBs to be used. * **[Plugins]** Fixed Lua errors in Skynet plugin that would occur whenever one coalition had no IADS nodes. # 8.1.0 diff --git a/game/missiongenerator/aircraft/waypoints/ocarunwayingress.py b/game/missiongenerator/aircraft/waypoints/ocarunwayingress.py index 84cb5733..f26ed1fe 100644 --- a/game/missiongenerator/aircraft/waypoints/ocarunwayingress.py +++ b/game/missiongenerator/aircraft/waypoints/ocarunwayingress.py @@ -1,8 +1,14 @@ import logging from dcs.point import MovingPoint -from dcs.task import BombingRunway, OptFormation, WeaponType +from dcs.task import ( + Bombing, + BombingRunway, + OptFormation, + WeaponType as DcsWeaponType, +) +from game.data.weapons import WeaponType from game.theater import Airfield from .pydcswaypointbuilder import PydcsWaypointBuilder @@ -18,10 +24,25 @@ class OcaRunwayIngressBuilder(PydcsWaypointBuilder): ) return + # The BombingRunway task in DCS does not use LGBs, which necessitates special handling + # by using the Bombing task instead. See https://github.com/dcs-liberation/dcs_liberation/issues/894 + # for more details. + # The LGB work around assumes the Airfield position in DCS is on a runway, which seems + # to be the case for most if not all airfields. + if self.flight.loadout.has_weapon_of_type(WeaponType.LGB): + waypoint.tasks.append( + Bombing( + position=target.position, + group_attack=True, + weapon_type=DcsWeaponType.Guided, + altitude=waypoint.alt, + ) + ) + waypoint.tasks.append( BombingRunway( airport_id=target.airport.id, - weapon_type=WeaponType.Guided, + weapon_type=DcsWeaponType.Guided, altitude=waypoint.alt, group_attack=True, ) @@ -29,7 +50,7 @@ class OcaRunwayIngressBuilder(PydcsWaypointBuilder): waypoint.tasks.append( BombingRunway( airport_id=target.airport.id, - weapon_type=WeaponType.Bombs, + weapon_type=DcsWeaponType.Bombs, group_attack=True, ) )