From e9d02730561e90a03b863bac66243d22b54c9543 Mon Sep 17 00:00:00 2001 From: Raffson Date: Sun, 21 Jul 2024 02:21:51 +0200 Subject: [PATCH] Attempt at fixing too slow helicopter speeds --- game/ato/flightplans/airassault.py | 13 +------------ game/ato/flightplans/escort.py | 2 -- game/ato/flightplans/flightplan.py | 13 ------------- game/ato/flightplans/formation.py | 6 ++++-- game/ato/flightplans/formationattack.py | 12 +----------- game/ato/package.py | 8 +++++--- game/ato/traveltime.py | 2 +- 7 files changed, 12 insertions(+), 44 deletions(-) diff --git a/game/ato/flightplans/airassault.py b/game/ato/flightplans/airassault.py index 14da523b..b383ef5e 100644 --- a/game/ato/flightplans/airassault.py +++ b/game/ato/flightplans/airassault.py @@ -65,7 +65,7 @@ class AirAssaultFlightPlan(FormationAttackFlightPlan, UiZoneDisplay): def tot_waypoint(self) -> FlightWaypoint: if self.flight.is_helo and self.layout.drop_off is not None: return self.layout.drop_off - return self.layout.targets[0] + return self.target_area_waypoint @property def ingress_time(self) -> datetime: @@ -75,13 +75,6 @@ class AirAssaultFlightPlan(FormationAttackFlightPlan, UiZoneDisplay): ) return tot - travel_time - def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None: - if waypoint is self.tot_waypoint: - return self.tot - elif waypoint is self.layout.ingress: - return self.ingress_time - return None - def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None: return None @@ -89,10 +82,6 @@ class AirAssaultFlightPlan(FormationAttackFlightPlan, UiZoneDisplay): def ctld_target_zone_radius(self) -> Distance: return meters(2500) - @property - def mission_begin_on_station_time(self) -> datetime | None: - return None - @property def mission_departure_time(self) -> datetime: return self.package.time_over_target diff --git a/game/ato/flightplans/escort.py b/game/ato/flightplans/escort.py index 53385f24..3b782e66 100644 --- a/game/ato/flightplans/escort.py +++ b/game/ato/flightplans/escort.py @@ -59,8 +59,6 @@ class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]): join = builder.join(ascent.position) if layout.pickup and layout.drop_off_ascent: join = builder.join(layout.drop_off_ascent.position) - elif layout.pickup: - join = builder.join(layout.pickup.position) split = builder.split(layout.arrival.position) if layout.drop_off: initial = builder.escort_hold( diff --git a/game/ato/flightplans/flightplan.py b/game/ato/flightplans/flightplan.py index ed582353..e6c19d31 100644 --- a/game/ato/flightplans/flightplan.py +++ b/game/ato/flightplans/flightplan.py @@ -105,19 +105,6 @@ class FlightPlan(ABC, Generic[LayoutT]): # # Plus, it's a loiter point so there's no reason to hurry. factor = 0.75 - elif ( - self.flight.is_helo - and ( - a.waypoint_type == FlightWaypointType.JOIN - or "INGRESS" in a.waypoint_type.name - or a.waypoint_type == FlightWaypointType.CUSTOM - ) - and self.package.primary_flight - and not self.package.primary_flight.flight_plan.is_airassault - ): - # Helicopter flights should be slowed down between JOIN & INGRESS - # to allow the escort to keep up while engaging targets along the way. - factor = 0.50 # TODO: Adjust if AGL. # We don't have an exact heightmap, but we should probably be performing # *some* adjustment for NTTR since the minimum altitude of the map is diff --git a/game/ato/flightplans/formation.py b/game/ato/flightplans/formation.py index 92d4aba8..407743e0 100644 --- a/game/ato/flightplans/formation.py +++ b/game/ato/flightplans/formation.py @@ -64,8 +64,10 @@ class FormationFlightPlan(LoiterFlightPlan, ABC): return min(speeds) def speed_between_waypoints(self, a: FlightWaypoint, b: FlightWaypoint) -> Speed: - if self.package.formation_speed and b in self.package_speed_waypoints: - return self.package.formation_speed + if ( + speed := self.package.formation_speed(self.flight.is_helo) + ) and b in self.package_speed_waypoints: + return speed return super().speed_between_waypoints(a, b) @property diff --git a/game/ato/flightplans/formationattack.py b/game/ato/flightplans/formationattack.py index b4d87bca..ab3d9452 100644 --- a/game/ato/flightplans/formationattack.py +++ b/game/ato/flightplans/formationattack.py @@ -11,7 +11,7 @@ from dcs import Point from game.flightplan import HoldZoneGeometry from game.theater import MissionTarget -from game.utils import Speed, meters, nautical_miles +from game.utils import meters, nautical_miles from .flightplan import FlightPlan from .formation import FormationFlightPlan, FormationLayout from .ibuilder import IBuilder @@ -33,16 +33,6 @@ class FormationAttackFlightPlan(FormationFlightPlan, ABC): self.layout.split, } | set(self.layout.targets) - def speed_between_waypoints(self, a: FlightWaypoint, b: FlightWaypoint) -> Speed: - # FlightWaypoint is only comparable by identity, so adding - # target_area_waypoint to package_speed_waypoints is useless. - if b.waypoint_type == FlightWaypointType.TARGET_GROUP_LOC: - # Should be impossible, as any package with at least one - # FormationFlightPlan flight needs a formation speed. - assert self.package.formation_speed is not None - return self.package.formation_speed - return super().speed_between_waypoints(a, b) - @property def tot_waypoint(self) -> FlightWaypoint: return self.layout.targets[0] diff --git a/game/ato/package.py b/game/ato/package.py index 84db40e2..fb56a46e 100644 --- a/game/ato/package.py +++ b/game/ato/package.py @@ -54,8 +54,7 @@ class Package(RadioFrequencyContainer): def has_players(self) -> bool: return any(flight.client_count for flight in self.flights) - @property - def formation_speed(self) -> Optional[Speed]: + def formation_speed(self, is_helo: bool) -> Optional[Speed]: """The speed of the package when in formation. If none of the flights in the package will join a formation, this @@ -66,7 +65,10 @@ class Package(RadioFrequencyContainer): """ speeds = [] for flight in self.flights: - if isinstance(flight.flight_plan, FormationFlightPlan): + if ( + isinstance(flight.flight_plan, FormationFlightPlan) + and flight.is_helo == is_helo + ): speeds.append(flight.flight_plan.best_flight_formation_speed) if not speeds: return None diff --git a/game/ato/traveltime.py b/game/ato/traveltime.py index 66afa547..118ddda4 100644 --- a/game/ato/traveltime.py +++ b/game/ato/traveltime.py @@ -30,7 +30,7 @@ class GroundSpeed: # as it can at sea level. This probably isn't great assumption, but # might. be sufficient given the wiggle room. We can come up with # another heuristic if needed. - cruise_mach = max_speed.mach() * (0.60 if flight.is_helo else 0.85) + cruise_mach = max_speed.mach() * (0.7 if flight.is_helo else 0.85) return mach(cruise_mach, altitude if not flight.is_helo else meters(0))