diff --git a/changelog.md b/changelog.md index f0d09d6e..95f4228a 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ Saves from 8.x are not compatible with 9.0.0. * **[Flight Planning]** Laser codes that are pre-assigned to weapons at mission start can now be chosen from a list in the loadout UI. This does not affect the aircraft's TGP, just the weapons. Currently only implemented for the F-15E S4+ and F-16C. * **[Mission Generation]** Configured target and initial points for F-15E S4+. * **[Mission Generation]** Added a package kneeboard page that shows the radio frequencies, tasks, and laser codes for each member of your package. +* **[Mission Generation]** Added option to generate AI flights with unlimited fuel (enabled by default). * **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate. * **[Modding]** Unit variants can now set a display name separate from their ID. * **[Modding]** Updated Community A-4E-C mod version support to 2.2.0 release. diff --git a/game/missiongenerator/aircraft/aircraftbehavior.py b/game/missiongenerator/aircraft/aircraftbehavior.py index c61c5030..6d44d392 100644 --- a/game/missiongenerator/aircraft/aircraftbehavior.py +++ b/game/missiongenerator/aircraft/aircraftbehavior.py @@ -20,6 +20,7 @@ from dcs.task import ( RunwayAttack, SEAD, Transport, + SetUnlimitedFuelCommand, ) from dcs.unitgroup import FlyingGroup @@ -27,11 +28,13 @@ from game.ato import Flight, FlightType from game.ato.flightplans.aewc import AewcFlightPlan from game.ato.flightplans.shiprecoverytanker import RecoveryTankerFlightPlan from game.ato.flightplans.theaterrefueling import TheaterRefuelingFlightPlan +from game.settings import Settings class AircraftBehavior: - def __init__(self, task: FlightType) -> None: + def __init__(self, task: FlightType, settings: Settings) -> None: self.task = task + self.settings = settings def apply_to(self, flight: Flight, group: FlyingGroup[Any]) -> None: if self.task in [ @@ -74,6 +77,7 @@ class AircraftBehavior: else: self.configure_unknown_task(group, flight) + self.configure_unlimited_fuel(group, flight) self.configure_eplrs(group, flight) def configure_behavior( @@ -115,6 +119,17 @@ class AircraftBehavior: if flight.unit_type.eplrs_capable: group.points[0].tasks.append(EPLRS(group.id)) + def configure_unlimited_fuel(self, group: FlyingGroup[Any], flight: Flight) -> None: + if not flight.client_count and self.settings.ai_has_unlimited_fuel: + # This task is prepended according to the notes from the DCS changelog: + # + # NEW: Advanced Waypoint Action for Unlimited Fuel Option for AI. Please + # note the task must be at the top of Advanced Waypoint Actions list to + # make sure it works properly. + # + # https://www.digitalcombatsimulator.com/en/news/changelog/openbeta/2.9.0.46801/ + group.points[0].tasks.insert(0, SetUnlimitedFuelCommand(True)) + def configure_cap(self, group: FlyingGroup[Any], flight: Flight) -> None: group.task = CAP.name diff --git a/game/missiongenerator/aircraft/flightgroupconfigurator.py b/game/missiongenerator/aircraft/flightgroupconfigurator.py index f1e13a2f..11bc26ad 100644 --- a/game/missiongenerator/aircraft/flightgroupconfigurator.py +++ b/game/missiongenerator/aircraft/flightgroupconfigurator.py @@ -58,7 +58,9 @@ class FlightGroupConfigurator: self.unit_map = unit_map def configure(self) -> FlightData: - AircraftBehavior(self.flight.flight_type).apply_to(self.flight, self.group) + AircraftBehavior(self.flight.flight_type, self.game.settings).apply_to( + self.flight, self.group + ) AircraftPainter(self.flight, self.group).apply_livery() self.setup_props() self.setup_payloads() diff --git a/game/settings/settings.py b/game/settings/settings.py index 93a2a11e..8f740933 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -339,6 +339,18 @@ class Settings: ) # Gameplay + ai_has_unlimited_fuel: bool = boolean_option( + "Unlimited fuel for AI flights", + page=MISSION_GENERATOR_PAGE, + section=GAMEPLAY_SECTION, + default=True, + detail=( + "If enabled, AI-only flights will have unlimited fuel. This can be " + "disabled to force AI flights to play by the same rules as players, but be " + "warned that the DCS AI is not particularly fuel conscious, so will often " + "run out of fuel when players would not." + ), + ) fast_forward_to_first_contact: bool = boolean_option( "Fast forward mission to first contact (WIP)", page=MISSION_GENERATOR_PAGE,