Fix anti-runway task generation for LGBs.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/894.
This commit is contained in:
zhexu14 2023-07-18 10:07:01 +10:00 committed by GitHub
parent 1f73e02d15
commit a5eeb83783
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 4 deletions

View File

@ -15,6 +15,7 @@ Saves from 8.x are not compatible with 9.0.0.
* **[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.
* **[UI]** Fixed deleting waypoints in custom flight plans deleting the wrong waypoint.

View File

@ -1,8 +1,14 @@
import logging
from dcs.point import MovingPoint
from dcs.task import BombingRunway, OptFormation
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
@ -17,7 +23,21 @@ class OcaRunwayIngressBuilder(PydcsWaypointBuilder):
)
return
waypoint.tasks.append(
BombingRunway(airport_id=target.airport.id, group_attack=True)
)
# 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,
)
)
else: # Use BombingRunway task for all other weapon types
waypoint.tasks.append(
BombingRunway(airport_id=target.airport.id, group_attack=True)
)
waypoint.tasks.append(OptFormation.trail_open())