From b7ad1048bd7e3da1d2fdb30c8131e0ed66db07da Mon Sep 17 00:00:00 2001 From: Raffson Date: Sun, 21 Jul 2024 19:50:00 +0200 Subject: [PATCH] Perturb join waypoint for helicopters --- game/ato/flightplans/escort.py | 3 ++- game/ato/flightplans/formationattack.py | 1 + game/ato/flightplans/waypointbuilder.py | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/game/ato/flightplans/escort.py b/game/ato/flightplans/escort.py index 3b782e66..bdae0ac1 100644 --- a/game/ato/flightplans/escort.py +++ b/game/ato/flightplans/escort.py @@ -11,6 +11,7 @@ from .formationattack import ( ) from .waypointbuilder import WaypointBuilder from .. import FlightType +from ...utils import feet class EscortFlightPlan(FormationAttackFlightPlan): @@ -34,7 +35,7 @@ class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]): hold = builder.hold(self._hold_point()) join_pos = ( - self.package.waypoints.ingress + WaypointBuilder.perturb(self.package.waypoints.ingress, feet(500)) if self.flight.is_helo else self.package.waypoints.join ) diff --git a/game/ato/flightplans/formationattack.py b/game/ato/flightplans/formationattack.py index 0c8b8475..65c72c82 100644 --- a/game/ato/flightplans/formationattack.py +++ b/game/ato/flightplans/formationattack.py @@ -193,6 +193,7 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC): join_pos = self.package.waypoints.join if self.flight.is_helo: join_pos = self.package.waypoints.ingress + join_pos = WaypointBuilder.perturb(join_pos, feet(500)) join = builder.join(join_pos) split = builder.split(self._get_split()) refuel = self._build_refuel(builder) diff --git a/game/ato/flightplans/waypointbuilder.py b/game/ato/flightplans/waypointbuilder.py index 03e25577..ebeec5b8 100644 --- a/game/ato/flightplans/waypointbuilder.py +++ b/game/ato/flightplans/waypointbuilder.py @@ -790,8 +790,7 @@ class WaypointBuilder: return previous_threatened and next_threatened @staticmethod - def perturb(point: Point) -> Point: - deviation = nautical_miles(1) + def perturb(point: Point, deviation: Distance = nautical_miles(1)) -> Point: x_adj = random.randint(int(-deviation.meters), int(deviation.meters)) y_adj = random.randint(int(-deviation.meters), int(deviation.meters)) return point + Vector2(x_adj, y_adj)