mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fine-tuning stuff for 'SEAD Sweep'
This commit is contained in:
parent
031feeed6f
commit
6c210c9d15
@ -19,7 +19,7 @@ if TYPE_CHECKING:
|
||||
@dataclass
|
||||
class FormationLayout(LoiterLayout, ABC):
|
||||
nav_to: list[FlightWaypoint]
|
||||
join: FlightWaypoint
|
||||
join: Optional[FlightWaypoint]
|
||||
split: FlightWaypoint
|
||||
refuel: Optional[FlightWaypoint]
|
||||
nav_from: list[FlightWaypoint]
|
||||
@ -73,10 +73,7 @@ class FormationFlightPlan(LoiterFlightPlan, ABC):
|
||||
return min(speeds)
|
||||
|
||||
def speed_between_waypoints(self, a: FlightWaypoint, b: FlightWaypoint) -> Speed:
|
||||
if b in self.package_speed_waypoints:
|
||||
# Should be impossible, as any package with at least one
|
||||
# FormationFlightPlan flight needs a formation speed.
|
||||
assert self.package.formation_speed is not None
|
||||
if self.package.formation_speed and b in self.package_speed_waypoints:
|
||||
return self.package.formation_speed
|
||||
return super().speed_between_waypoints(a, b)
|
||||
|
||||
|
||||
@ -111,9 +111,19 @@ class FormationAttackFlightPlan(FormationFlightPlan, ABC):
|
||||
)
|
||||
return tot - travel_time
|
||||
|
||||
@property
|
||||
def initial_time(self) -> timedelta:
|
||||
tot = self.tot
|
||||
travel_time = self.travel_time_between_waypoints(
|
||||
self.layout.initial, self.target_area_waypoint
|
||||
)
|
||||
return tot - travel_time
|
||||
|
||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
|
||||
if waypoint == self.layout.ingress:
|
||||
return self.ingress_time
|
||||
elif waypoint == self.layout.initial:
|
||||
return self.initial_time
|
||||
elif waypoint in self.layout.targets:
|
||||
return self.tot
|
||||
return super().tot_for_waypoint(waypoint)
|
||||
@ -127,8 +137,10 @@ class FormationAttackLayout(FormationLayout):
|
||||
|
||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||
yield self.departure
|
||||
if self.hold:
|
||||
yield self.hold
|
||||
yield from self.nav_to
|
||||
if self.join:
|
||||
yield self.join
|
||||
yield self.ingress
|
||||
if self.initial is not None:
|
||||
@ -170,6 +182,15 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
|
||||
)
|
||||
)
|
||||
|
||||
hold = None
|
||||
join = None
|
||||
if (
|
||||
self.flight is self.package.primary_flight
|
||||
or self.package.primary_flight
|
||||
and isinstance(
|
||||
self.package.primary_flight.flight_plan, FormationAttackFlightPlan
|
||||
)
|
||||
):
|
||||
hold = builder.hold(self._hold_point())
|
||||
join = builder.join(self.package.waypoints.join)
|
||||
split = builder.split(self.package.waypoints.split)
|
||||
@ -189,7 +210,9 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
|
||||
departure=builder.takeoff(self.flight.departure),
|
||||
hold=hold,
|
||||
nav_to=builder.nav_path(
|
||||
hold.position, join.position, self.doctrine.ingress_altitude
|
||||
hold.position if hold else self.flight.departure.position,
|
||||
join.position if join else ingress.position,
|
||||
self.doctrine.ingress_altitude,
|
||||
),
|
||||
join=join,
|
||||
ingress=ingress,
|
||||
|
||||
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
from typing import Any, TYPE_CHECKING, TypeGuard
|
||||
from typing import Any, TYPE_CHECKING, TypeGuard, Optional
|
||||
|
||||
from game.typeguard import self_type_guard
|
||||
from .flightplan import FlightPlan
|
||||
@ -15,7 +15,7 @@ if TYPE_CHECKING:
|
||||
|
||||
@dataclass
|
||||
class LoiterLayout(StandardLayout, ABC):
|
||||
hold: FlightWaypoint
|
||||
hold: Optional[FlightWaypoint]
|
||||
|
||||
|
||||
class LoiterFlightPlan(StandardFlightPlan[Any], ABC):
|
||||
|
||||
@ -26,6 +26,7 @@ class SweepLayout(LoiterLayout):
|
||||
|
||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||
yield self.departure
|
||||
if self.hold:
|
||||
yield self.hold
|
||||
yield from self.nav_to
|
||||
yield self.sweep_start
|
||||
|
||||
@ -458,7 +458,11 @@ class WaypointBuilder:
|
||||
assert self.flight.package.waypoints
|
||||
ingress = self.flight.package.waypoints.ingress
|
||||
ingress2tgt_dist = ingress.distance_to_point(target.position)
|
||||
threat_range = 1.1 * max([x.threat_range for x in target.strike_targets]).meters
|
||||
threat_range = nautical_miles(5).meters
|
||||
if target.strike_targets:
|
||||
threat_range = (
|
||||
1.1 * max([x.threat_range for x in target.strike_targets]).meters
|
||||
)
|
||||
hdg = target.position.heading_between_point(ingress)
|
||||
hold = target.position.point_from_heading(
|
||||
hdg, min(threat_range, ingress2tgt_dist * 0.95)
|
||||
|
||||
@ -176,6 +176,7 @@ class Package(RadioFrequencyContainer):
|
||||
FlightType.TRANSPORT,
|
||||
FlightType.AIR_ASSAULT,
|
||||
FlightType.SEAD,
|
||||
FlightType.SEAD_SWEEP,
|
||||
FlightType.TARCAP,
|
||||
FlightType.BARCAP,
|
||||
FlightType.AEWC,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user