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

@@ -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

View File

@@ -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()

View File

@@ -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,