Tweak ingress waypoint tasks for OCA-Runway, STRIKE & FighterSweep

This commit is contained in:
Raffson 2023-06-03 19:04:25 +02:00
parent 962c64d065
commit b318bc4941
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 35 additions and 15 deletions

View File

@ -1,7 +1,7 @@
import logging import logging
from dcs.point import MovingPoint from dcs.point import MovingPoint
from dcs.task import BombingRunway, OptFormation from dcs.task import BombingRunway, OptFormation, WeaponType
from game.theater import Airfield from game.theater import Airfield
from .pydcswaypointbuilder import PydcsWaypointBuilder from .pydcswaypointbuilder import PydcsWaypointBuilder
@ -10,6 +10,7 @@ from .pydcswaypointbuilder import PydcsWaypointBuilder
class OcaRunwayIngressBuilder(PydcsWaypointBuilder): class OcaRunwayIngressBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None: def add_tasks(self, waypoint: MovingPoint) -> None:
target = self.package.target target = self.package.target
waypoint.tasks.append(OptFormation.trail_open())
if not isinstance(target, Airfield): if not isinstance(target, Airfield):
logging.error( logging.error(
"Unexpected target type for runway bombing mission: %s", "Unexpected target type for runway bombing mission: %s",
@ -18,6 +19,17 @@ class OcaRunwayIngressBuilder(PydcsWaypointBuilder):
return return
waypoint.tasks.append( waypoint.tasks.append(
BombingRunway(airport_id=target.airport.id, group_attack=True) BombingRunway(
airport_id=target.airport.id,
weapon_type=WeaponType.Guided,
altitude=waypoint.alt,
group_attack=True,
)
)
waypoint.tasks.append(
BombingRunway(
airport_id=target.airport.id,
weapon_type=WeaponType.Bombs,
group_attack=True,
)
) )
waypoint.tasks.append(OptFormation.trail_open())

View File

@ -34,13 +34,21 @@ class StrikeIngressBuilder(PydcsWaypointBuilder):
for t in targets: for t in targets:
avg_spacing += center.distance_to_point(t.position) avg_spacing += center.distance_to_point(t.position)
avg_spacing /= len(targets) avg_spacing /= len(targets)
bombing = CarpetBombing( if self.group.task == "Ground Attack":
center, bombing = CarpetBombing(
weapon_type=WeaponType.Bombs, center,
expend=Expend.All, weapon_type=WeaponType.Bombs,
carpet_length=avg_spacing, expend=Expend.All,
altitude=waypoint.alt, carpet_length=avg_spacing,
) altitude=waypoint.alt,
)
else:
bombing = Bombing(
center,
weapon_type=WeaponType.Bombs,
expend=Expend.All,
altitude=waypoint.alt,
)
waypoint.tasks.append(bombing) waypoint.tasks.append(bombing)
def add_strike_tasks( def add_strike_tasks(

View File

@ -10,6 +10,11 @@ from .pydcswaypointbuilder import PydcsWaypointBuilder
class SweepIngressBuilder(PydcsWaypointBuilder): class SweepIngressBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None: def add_tasks(self, waypoint: MovingPoint) -> None:
if self.flight.count < 4:
waypoint.tasks.append(OptFormation.line_abreast_open())
else:
waypoint.tasks.append(OptFormation.spread_four_open())
if not isinstance(self.flight.flight_plan, SweepFlightPlan): if not isinstance(self.flight.flight_plan, SweepFlightPlan):
flight_plan_type = self.flight.flight_plan.__class__.__name__ flight_plan_type = self.flight.flight_plan.__class__.__name__
logging.error( logging.error(
@ -27,8 +32,3 @@ class SweepIngressBuilder(PydcsWaypointBuilder):
], ],
) )
) )
if self.flight.count < 4:
waypoint.tasks.append(OptFormation.line_abreast_open())
else:
waypoint.tasks.append(OptFormation.spread_four_open())