mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
@@ -80,6 +80,8 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
self.tacan = channel
|
||||
self.tcn_name = callsign
|
||||
|
||||
self.initialize_fuel()
|
||||
|
||||
# Only used by transport missions.
|
||||
self.cargo = cargo
|
||||
|
||||
@@ -204,19 +206,19 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
|
||||
self.roster.clear()
|
||||
self.squadron.claim_inventory(-self.count)
|
||||
|
||||
def max_takeoff_fuel(self) -> Optional[float]:
|
||||
# Special case so Su 33 and C101 can take off
|
||||
def initialize_fuel(self) -> None:
|
||||
unit_type = self.unit_type.dcs_unit_type
|
||||
self.fuel = unit_type.fuel_max
|
||||
# Special cases where we want less fuel for takeoff
|
||||
if unit_type == Su_33:
|
||||
if self.flight_type.is_air_to_air:
|
||||
return Su_33.fuel_max / 2.2
|
||||
self.fuel = Su_33.fuel_max / 2.2
|
||||
else:
|
||||
return Su_33.fuel_max * 0.8
|
||||
self.fuel = Su_33.fuel_max * 0.8
|
||||
elif unit_type in {C_101EB, C_101CC}:
|
||||
return unit_type.fuel_max * 0.5
|
||||
self.fuel = unit_type.fuel_max * 0.5
|
||||
elif unit_type == Hercules:
|
||||
return unit_type.fuel_max * 0.75
|
||||
return None
|
||||
self.fuel = unit_type.fuel_max * 0.75
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.__str__()
|
||||
|
||||
@@ -82,9 +82,7 @@ class FlightState(ABC):
|
||||
|
||||
def estimate_fuel(self) -> float:
|
||||
"""Returns the estimated remaining fuel **in kilograms**."""
|
||||
if (max_takeoff_fuel := self.flight.max_takeoff_fuel()) is not None:
|
||||
return max_takeoff_fuel
|
||||
return self.flight.unit_type.dcs_unit_type.fuel_max
|
||||
return self.flight.fuel
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
|
||||
@@ -200,6 +200,10 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
||||
def helicopter(self) -> bool:
|
||||
return self.dcs_unit_type.helicopter
|
||||
|
||||
@property
|
||||
def max_fuel(self) -> float:
|
||||
return self.dcs_unit_type.fuel_max
|
||||
|
||||
@cached_property
|
||||
def max_speed(self) -> Speed:
|
||||
return kph(self.dcs_unit_type.max_speed)
|
||||
|
||||
@@ -76,3 +76,4 @@ class Migrator:
|
||||
try_set_attr(f, "frequency")
|
||||
try_set_attr(f, "tacan")
|
||||
try_set_attr(f, "tcn_name")
|
||||
try_set_attr(f, "fuel", f.unit_type.max_fuel)
|
||||
|
||||
@@ -249,12 +249,4 @@ class FlightGroupConfigurator:
|
||||
)
|
||||
fuel = 100
|
||||
for unit, pilot in zip(self.group.units, self.flight.roster.pilots):
|
||||
if pilot is not None and pilot.player:
|
||||
unit.fuel = fuel
|
||||
elif (max_takeoff_fuel := self.flight.max_takeoff_fuel()) is not None:
|
||||
unit.fuel = max_takeoff_fuel
|
||||
else:
|
||||
# pydcs arbitrarily reduces the fuel of in-flight spawns by 10%. We do
|
||||
# our own tracking, so undo that.
|
||||
# https://github.com/pydcs/dcs/commit/303a81a8e0c778599fe136dd22cb2ae8123639a6
|
||||
unit.fuel = self.flight.unit_type.dcs_unit_type.fuel_max
|
||||
unit.fuel = fuel
|
||||
|
||||
Reference in New Issue
Block a user