Add support for DCS 2.9's AI unlimited fuel.

This is enabled by default because I can't think of a time where it's
ever been more fun to watch the AI run out of fuel after cycling between
afterburner and speedbrake for twenty minutes.

This is only lightly tested (I verified that the task shows up
appropriately in the ME when set, not when unset, and never for
players), since the interesting part of the implementation is up to ED.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3201.
This commit is contained in:
Dan Albert 2023-11-01 17:53:19 -07:00
parent 82a200c53a
commit c010ef9994
4 changed files with 32 additions and 2 deletions

View File

@ -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. * **[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]** 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 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]** 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]** 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. * **[Modding]** Updated Community A-4E-C mod version support to 2.2.0 release.

View File

@ -20,6 +20,7 @@ from dcs.task import (
RunwayAttack, RunwayAttack,
SEAD, SEAD,
Transport, Transport,
SetUnlimitedFuelCommand,
) )
from dcs.unitgroup import FlyingGroup 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.aewc import AewcFlightPlan
from game.ato.flightplans.shiprecoverytanker import RecoveryTankerFlightPlan from game.ato.flightplans.shiprecoverytanker import RecoveryTankerFlightPlan
from game.ato.flightplans.theaterrefueling import TheaterRefuelingFlightPlan from game.ato.flightplans.theaterrefueling import TheaterRefuelingFlightPlan
from game.settings import Settings
class AircraftBehavior: class AircraftBehavior:
def __init__(self, task: FlightType) -> None: def __init__(self, task: FlightType, settings: Settings) -> None:
self.task = task self.task = task
self.settings = settings
def apply_to(self, flight: Flight, group: FlyingGroup[Any]) -> None: def apply_to(self, flight: Flight, group: FlyingGroup[Any]) -> None:
if self.task in [ if self.task in [
@ -74,6 +77,7 @@ class AircraftBehavior:
else: else:
self.configure_unknown_task(group, flight) self.configure_unknown_task(group, flight)
self.configure_unlimited_fuel(group, flight)
self.configure_eplrs(group, flight) self.configure_eplrs(group, flight)
def configure_behavior( def configure_behavior(
@ -115,6 +119,17 @@ class AircraftBehavior:
if flight.unit_type.eplrs_capable: if flight.unit_type.eplrs_capable:
group.points[0].tasks.append(EPLRS(group.id)) 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: def configure_cap(self, group: FlyingGroup[Any], flight: Flight) -> None:
group.task = CAP.name group.task = CAP.name

View File

@ -58,7 +58,9 @@ class FlightGroupConfigurator:
self.unit_map = unit_map self.unit_map = unit_map
def configure(self) -> FlightData: 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() AircraftPainter(self.flight, self.group).apply_livery()
self.setup_props() self.setup_props()
self.setup_payloads() self.setup_payloads()

View File

@ -339,6 +339,18 @@ class Settings:
) )
# Gameplay # 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_to_first_contact: bool = boolean_option(
"Fast forward mission to first contact (WIP)", "Fast forward mission to first contact (WIP)",
page=MISSION_GENERATOR_PAGE, page=MISSION_GENERATOR_PAGE,