Improved Strike mission generation.

- B52, A-20, and Tu-22 will level bomb targets
- When there is an unit group as target, all the units are now engaged instead of only the first unit of the group
This commit is contained in:
Khopa 2020-11-07 02:13:17 +01:00
parent 040db055fd
commit d9511a7edd
5 changed files with 56 additions and 39 deletions

View File

@ -955,23 +955,10 @@ COMMON_OVERRIDE = {
PLANE_PAYLOAD_OVERRIDES: Dict[Type[PlaneType], Dict[Type[Task], str]] = { PLANE_PAYLOAD_OVERRIDES: Dict[Type[PlaneType], Dict[Type[Task], str]] = {
B_1B: { B_1B: COMMON_OVERRIDE,
CAS: "GBU-38*16, CBU-97*20", B_52H: COMMON_OVERRIDE,
PinpointStrike: "GBU-31*8, GBU-38*32", F_117A: COMMON_OVERRIDE,
GroundAttack: "GBU-31*8, GBU-38*32", F_15E: COMMON_OVERRIDE,
},
B_52H: {
PinpointStrike: "AGM-86C*20",
GroundAttack: "Mk 82*51",
},
F_117A: {
PinpointStrike: "GBU-10*2",
},
F_15E: {
CAS: "AIM-120B*2,AIM-9M*2,FUEL,GBU-12*4,GBU-38*4,AGM-65D*2",
GroundAttack: "AIM-120B*2,AIM-9M*2,FUEL*3,CBU-97*12",
PinpointStrike: "AIM-120B*2,AIM-9M*2,FUEL,GBU-31*4,AGM-154C*2",
},
FA_18C_hornet: { FA_18C_hornet: {
CAP: "CAP HEAVY", CAP: "CAP HEAVY",
Intercept: "CAP HEAVY", Intercept: "CAP HEAVY",
@ -995,12 +982,8 @@ PLANE_PAYLOAD_OVERRIDES: Dict[Type[PlaneType], Dict[Type[Task], str]] = {
Tu_160: { Tu_160: {
PinpointStrike: "Kh-65*12", PinpointStrike: "Kh-65*12",
}, },
Tu_22M3: { Tu_22M3: COMMON_OVERRIDE,
GroundAttack: "FAB-500*33, FAB-250*36", Tu_95MS: COMMON_OVERRIDE,
},
Tu_95MS: {
PinpointStrike: "Kh-65*6",
},
A_10A: COMMON_OVERRIDE, A_10A: COMMON_OVERRIDE,
A_10C: COMMON_OVERRIDE, A_10C: COMMON_OVERRIDE,
A_10C_2: COMMON_OVERRIDE, A_10C_2: COMMON_OVERRIDE,

View File

@ -29,7 +29,7 @@ from dcs.planes import (
P_51D_30_NA, P_51D_30_NA,
SpitfireLFMkIX, SpitfireLFMkIX,
SpitfireLFMkIXCW, SpitfireLFMkIXCW,
Su_33, Su_33, A_20G, Tu_22M3, B_52H,
) )
from dcs.point import MovingPoint, PointAction from dcs.point import MovingPoint, PointAction
from dcs.task import ( from dcs.task import (
@ -54,7 +54,7 @@ from dcs.task import (
SEAD, SEAD,
StartCommand, StartCommand,
Targets, Targets,
Task, Task, WeaponType,
) )
from dcs.terrain.terrain import Airport from dcs.terrain.terrain import Airport
from dcs.translation import String from dcs.translation import String
@ -1054,7 +1054,7 @@ class AircraftConflictGenerator:
def configure_strike(self, group: FlyingGroup, package: Package, def configure_strike(self, group: FlyingGroup, package: Package,
flight: Flight, flight: Flight,
dynamic_runways: Dict[str, RunwayData]) -> None: dynamic_runways: Dict[str, RunwayData]) -> None:
group.task = PinpointStrike.name group.task = GroundAttack.name
self._setup_group(group, GroundAttack, package, flight, dynamic_runways) self._setup_group(group, GroundAttack, package, flight, dynamic_runways)
self.configure_behavior( self.configure_behavior(
group, group,
@ -1347,7 +1347,7 @@ class SeadIngressBuilder(PydcsWaypointBuilder):
class StrikeIngressBuilder(PydcsWaypointBuilder): class StrikeIngressBuilder(PydcsWaypointBuilder):
def build(self) -> MovingPoint: def build(self) -> MovingPoint:
if self.group.units[0].unit_type == B_17G: if self.group.units[0].unit_type in [B_17G, A_20G, B_52H, Tu_22M3]:
return self.build_bombing() return self.build_bombing()
else: else:
return self.build_strike() return self.build_strike()
@ -1370,7 +1370,7 @@ class StrikeIngressBuilder(PydcsWaypointBuilder):
bombing.params["attackQtyLimit"] = False bombing.params["attackQtyLimit"] = False
bombing.params["directionEnabled"] = False bombing.params["directionEnabled"] = False
bombing.params["altitudeEnabled"] = False bombing.params["altitudeEnabled"] = False
bombing.params["weaponType"] = 2032 bombing.params["weaponType"] = WeaponType.Bombs.value
bombing.params["groupAttack"] = True bombing.params["groupAttack"] = True
waypoint.tasks.append(bombing) waypoint.tasks.append(bombing)
return waypoint return waypoint
@ -1378,14 +1378,38 @@ class StrikeIngressBuilder(PydcsWaypointBuilder):
def build_strike(self) -> MovingPoint: def build_strike(self) -> MovingPoint:
waypoint = super().build() waypoint = super().build()
for i, t in enumerate(self.waypoint.targets): i = 0
waypoint.tasks.append(Bombing(t.position)) for target in self.waypoint.targets:
if self.group.units[0].unit_type == JF_17 and i < 4:
self.group.add_nav_target_point(t.position, "PP" + str(i + 1)) targets = [target]
if self.group.units[0].unit_type == F_14B and i == 0: # If the target type is a group of units,
self.group.add_nav_target_point(t.position, "ST") # then target each unit in the group with a Bombing task on their position
if self.group.units[0].unit_type == AJS37 and i < 9: # (It is not perfect, we should have an engage Group task instead,
self.group.add_nav_target_point(t.position, "M" + str(i + 1)) # but we don't have the group ref in the model there)
# TODO : for building group, engage all the buildings as well
if isinstance(target, TheaterGroundObject):
if len(target.units) > 0:
targets = target.units
for t in targets:
bombing = Bombing(t.position)
# If there is only one target, drop all ordnance in one pass
if len(self.waypoint.targets) == 1 and len(targets) == 1:
bombing.params["expend"] = "All"
bombing.params["weaponType"] = WeaponType.Auto.value
bombing.params["groupAttack"] = True
waypoint.tasks.append(bombing)
print(bombing)
# Register special waypoints
if self.group.units[0].unit_type == JF_17 and i < 4:
self.group.add_nav_target_point(t.position, "PP" + str(i + 1))
if self.group.units[0].unit_type == F_14B and i == 0:
self.group.add_nav_target_point(t.position, "ST")
if self.group.units[0].unit_type == AJS37 and i < 9:
self.group.add_nav_target_point(t.position, "M" + str(i + 1))
i = i + 1
return waypoint return waypoint

View File

@ -6,7 +6,7 @@ from typing import Dict, List, Optional, TYPE_CHECKING
from dcs.mapping import Point from dcs.mapping import Point
from dcs.point import MovingPoint, PointAction from dcs.point import MovingPoint, PointAction
from dcs.unittype import UnitType from dcs.unittype import FlyingType
from game import db from game import db
from theater.controlpoint import ControlPoint, MissionTarget from theater.controlpoint import ControlPoint, MissionTarget
@ -128,7 +128,7 @@ class FlightWaypoint:
class Flight: class Flight:
def __init__(self, package: Package, unit_type: UnitType, count: int, def __init__(self, package: Package, unit_type: FlyingType, count: int,
from_cp: ControlPoint, flight_type: FlightType, from_cp: ControlPoint, flight_type: FlightType,
start_type: str) -> None: start_type: str) -> None:
self.package = package self.package = package

View File

@ -15,7 +15,8 @@
"Ka_50", "Ka_50",
"Mi_8MT", "Mi_8MT",
"Mi_24V", "Mi_24V",
"Tu_22M3" "Tu_22M3",
"Tu_95MS"
], ],
"awacs": [ "awacs": [
"A_50" "A_50"

View File

@ -1,8 +1,10 @@
from __future__ import annotations from __future__ import annotations
import itertools
from typing import List, TYPE_CHECKING from typing import List, TYPE_CHECKING
from dcs.mapping import Point from dcs.mapping import Point
from dcs.unit import Unit
from dcs.unitgroup import Group from dcs.unitgroup import Group
if TYPE_CHECKING: if TYPE_CHECKING:
@ -93,6 +95,13 @@ class TheaterGroundObject(MissionTarget):
def group_identifier(self) -> str: def group_identifier(self) -> str:
return "{}|{}".format(self.category, self.group_id) return "{}|{}".format(self.category, self.group_id)
@property
def units(self) -> List[Unit]:
"""
:return: all the units at this location
"""
return list(itertools.chain.from_iterable([g.units for g in self.groups]))
@property @property
def name_abbrev(self) -> str: def name_abbrev(self) -> str:
return ABBREV_NAME[self.category] return ABBREV_NAME[self.category]