Tweak STRIKE ingress tasks

Use carpet-bombing instead, combine all tasks to better support guided/unguided attacks
This commit is contained in:
Raffson 2023-03-12 01:02:33 +01:00
parent d75c6d7e9a
commit cebcee8d32
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 21 additions and 18 deletions

View File

@ -129,10 +129,9 @@ class WaypointBuilder:
position = divert.position position = divert.position
altitude_type: AltitudeReference altitude_type: AltitudeReference
if isinstance(divert, OffMapSpawn): if isinstance(divert, OffMapSpawn):
if self.is_helo: altitude = (
altitude = meters(500) meters(500) if self.is_helo else self.doctrine.rendezvous_altitude
else: )
altitude = self.doctrine.rendezvous_altitude
altitude_type = "BARO" altitude_type = "BARO"
else: else:
altitude = meters(0) altitude = meters(0)

View File

@ -3,9 +3,9 @@ import copy
from dcs import Point from dcs import Point
from dcs.planes import B_17G, B_52H, Tu_22M3, B_1B from dcs.planes import B_17G, B_52H, Tu_22M3, B_1B
from dcs.point import MovingPoint from dcs.point import MovingPoint
from dcs.task import Bombing, Expend, OptFormation, WeaponType from dcs.task import Bombing, Expend, OptFormation, WeaponType, CarpetBombing
from game.utils import mach, Distance from game.utils import mach
from .pydcswaypointbuilder import PydcsWaypointBuilder from .pydcswaypointbuilder import PydcsWaypointBuilder
@ -13,15 +13,12 @@ class StrikeIngressBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None: def add_tasks(self, waypoint: MovingPoint) -> None:
bomber = self.group.units[0].unit_type in [B_17G, Tu_22M3] bomber = self.group.units[0].unit_type in [B_17G, Tu_22M3]
bomber_guided = self.group.units[0].unit_type in [B_1B, B_52H] bomber_guided = self.group.units[0].unit_type in [B_1B, B_52H]
if bomber_guided:
self.add_strike_tasks(waypoint, WeaponType.Guided)
self.add_bombing_tasks(waypoint)
elif bomber:
self.add_bombing_tasks(waypoint)
else:
self.add_strike_tasks(waypoint)
waypoint.tasks.append(OptFormation.trail_open()) waypoint.tasks.append(OptFormation.trail_open())
if bomber_guided or not bomber:
self.add_strike_tasks(waypoint, WeaponType.Guided)
waypoint.tasks.append(OptFormation.ww2_bomber_element_close())
self.add_bombing_tasks(waypoint)
def add_bombing_tasks(self, waypoint: MovingPoint) -> None: def add_bombing_tasks(self, waypoint: MovingPoint) -> None:
targets = self.waypoint.targets targets = self.waypoint.targets
@ -32,9 +29,15 @@ class StrikeIngressBuilder(PydcsWaypointBuilder):
for target in targets[1:]: for target in targets[1:]:
center += target.position center += target.position
center /= len(targets) center /= len(targets)
ga = True if self.flight.count > 1 else False avg_spacing = 0.0
bombing = Bombing( for t in targets:
center, weapon_type=WeaponType.Bombs, expend=Expend.All, group_attack=ga avg_spacing += center.distance_to_point(t.position)
avg_spacing /= len(targets)
bombing = CarpetBombing(
center,
weapon_type=WeaponType.Bombs,
expend=Expend.All,
carpet_length=avg_spacing,
) )
waypoint.tasks.append(bombing) waypoint.tasks.append(bombing)
@ -49,7 +52,8 @@ class StrikeIngressBuilder(PydcsWaypointBuilder):
bombing.params["expend"] = Expend.All.value bombing.params["expend"] = Expend.All.value
waypoint.tasks.append(bombing) waypoint.tasks.append(bombing)
waypoint.speed = mach(0.85, Distance.from_feet(20000)).meters_per_second doctrine = self.flight.coalition.doctrine
waypoint.speed = mach(0.85, doctrine.ingress_altitude).meters_per_second
# Register special waypoints # Register special waypoints
self.register_special_waypoints(self.waypoint.targets) self.register_special_waypoints(self.waypoint.targets)