Files
dcs-retribution/game/missiongenerator/aircraft/waypoints/racetrackend.py
tmz42 79b1d949ce AI unlimited fuel initial implementation (#227)
* Unlimited fuel for AI flights. For player flights, included at startup, for AI flights with join/split, applied at join/split.

* Unlimited fuel for AI flights. For player flights, included at startup, for AI flights with join/split, applied at join/split.

* Corrected default value of ai_unlimited_fuel to False in configure_behavior

* ai_unlimited_fuel : set argument based on setting and simplify activation section

* AI Unlimited Fuel : enable at start, disable at racetrack start/join, enable at racetrack end/split

* Correct typing : bool to Optional[bool]

---------

Co-authored-by: tmz42 <thomas.monnzie@gmail.com>
2024-01-06 21:04:57 +01:00

31 lines
1.1 KiB
Python

import logging
from dcs.point import MovingPoint
from dcs.task import SetUnlimitedFuelCommand
from game.ato.flightplans.patrolling import PatrollingFlightPlan
from .pydcswaypointbuilder import PydcsWaypointBuilder
class RaceTrackEndBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None:
flight_plan = self.flight.flight_plan
# Unlimited fuel option : enable at racetrack end. Must be first option to work.
if self.flight.squadron.coalition.game.settings.ai_unlimited_fuel:
waypoint.tasks.insert(0, SetUnlimitedFuelCommand(True))
def build(self) -> MovingPoint:
waypoint = super().build()
if not isinstance(self.flight.flight_plan, PatrollingFlightPlan):
flight_plan_type = self.flight.flight_plan.__class__.__name__
logging.error(
f"Cannot create race track for {self.flight} because "
f"{flight_plan_type} does not define a patrol."
)
return waypoint
self.waypoint.departure_time = self.flight.flight_plan.patrol_end_time
return waypoint