From 6ef3bd5095abbeb40db4af61a3f44dea457bef99 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 28 Jul 2023 21:29:34 -0700 Subject: [PATCH] Stop gap fix for AI speed to nav points. This isn't a great fix for the reason I mention in the comment, but it's quick and actually is accurate since it looks like we don't actually handle formation speeds correctly in most cases... This is probably as "fixed" as this is going to get for now since most of the flight planning code is in the process of being rewritten. https://github.com/dcs-liberation/dcs_liberation/issues/3113 --- changelog.md | 1 + .../aircraft/waypoints/pydcswaypointbuilder.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/changelog.md b/changelog.md index 9ff662e4..7b9b1117 100644 --- a/changelog.md +++ b/changelog.md @@ -228,6 +228,7 @@ BAI/ANTISHIP/DEAD/STRIKE/BARCAP/CAS/OCA/AIR-ASSAULT (main) missions * **[Flight Planning]** Patrolling flight plans (CAS, CAP, refueling, etc) now handle TOT offsets. * **[Mission Generation]** Restored previous AI behavior for anti-ship missions. A DCS update caused only a single aircraft in a flight to attack. The full flight will now attack like they used to. * **[Mission Generation]** Fix generation of OCA Runway missions to allow LGBs to be used. +* **[Mission Generation]** Fixed AI flights flying far too slowly toward NAV points. * **[Plugins]** Fixed Lua errors in Skynet plugin that would occur whenever one coalition had no IADS nodes. * **[UI]** Fixed deleting waypoints in custom flight plans deleting the wrong waypoint. * **[UI]** Fixed flight properties UI to support F-15E S4+ laser codes. diff --git a/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py b/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py index 071792c9..598e22c8 100644 --- a/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py +++ b/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py @@ -10,6 +10,7 @@ from dcs.unitgroup import FlyingGroup from game.ato import Flight, FlightWaypoint from game.ato.flightwaypointtype import FlightWaypointType +from game.ato.traveltime import GroundSpeed from game.missiongenerator.missiondata import MissionData from game.theater import MissionTarget, TheaterUnit @@ -45,6 +46,20 @@ class PydcsWaypointBuilder: waypoint = self.group.add_waypoint( self.waypoint.position, self.waypoint.alt.meters, + # The speed we pass will be overridden for most waypoints because we'll set + # a TOT and leave the speed up to the AI, but for the few types of waypoints + # that don't have TOTs (e.g. nav points), we set a reasonable cruise speed + # to pydcs doesn't assign the default of 600kph ground speed (which is very + # slow at most altitudes). + # + # Calling GroundSpeed.for_flight isn't really a correct fix here. We ought + # to be using FlightPlan.speed_between_waypoints, but the way the waypoint + # builder is called makes it difficult to track the previous waypoint. This + # is probably good enough for a stop gap, and most of the flight planning + # code is hopefully being rewritten soon anyway. + # + # https://github.com/dcs-liberation/dcs_liberation/issues/3113 + speed=GroundSpeed.for_flight(self.flight, self.waypoint.alt).kph, name=self.dcs_name_for_waypoint(), )