mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Add patrol configuration to unit data files.
This allows altitude/speed of AEW&C and tankers to be configured.
This commit is contained in:
parent
30763b5401
commit
a75688f89c
@ -29,7 +29,7 @@ from game.radio.channels import (
|
|||||||
ViggenRadioChannelAllocator,
|
ViggenRadioChannelAllocator,
|
||||||
NoOpChannelAllocator,
|
NoOpChannelAllocator,
|
||||||
)
|
)
|
||||||
from game.utils import Speed, kph
|
from game.utils import Distance, Speed, feet, kph, knots
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from gen.aircraft import FlightData
|
from gen.aircraft import FlightData
|
||||||
@ -90,12 +90,29 @@ class RadioConfig:
|
|||||||
}[config.get("namer", "default")]
|
}[config.get("namer", "default")]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class PatrolConfig:
|
||||||
|
altitude: Optional[Distance]
|
||||||
|
speed: Optional[Speed]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_data(cls, data: dict[str, Any]) -> PatrolConfig:
|
||||||
|
altitude = data.get("altitude", None)
|
||||||
|
speed = data.get("altitude", None)
|
||||||
|
return PatrolConfig(
|
||||||
|
feet(altitude) if altitude is not None else None,
|
||||||
|
knots(speed) if speed is not None else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class AircraftType(UnitType[FlyingType]):
|
class AircraftType(UnitType[FlyingType]):
|
||||||
carrier_capable: bool
|
carrier_capable: bool
|
||||||
lha_capable: bool
|
lha_capable: bool
|
||||||
always_keeps_gun: bool
|
always_keeps_gun: bool
|
||||||
max_group_size: int
|
max_group_size: int
|
||||||
|
patrol_altitude: Optional[Distance]
|
||||||
|
patrol_speed: Optional[Speed]
|
||||||
intra_flight_radio: Optional[Radio]
|
intra_flight_radio: Optional[Radio]
|
||||||
channel_allocator: Optional[RadioChannelAllocator]
|
channel_allocator: Optional[RadioChannelAllocator]
|
||||||
channel_namer: Type[ChannelNamer]
|
channel_namer: Type[ChannelNamer]
|
||||||
@ -192,6 +209,7 @@ class AircraftType(UnitType[FlyingType]):
|
|||||||
raise KeyError(f"Missing required price field: {data_path}") from ex
|
raise KeyError(f"Missing required price field: {data_path}") from ex
|
||||||
|
|
||||||
radio_config = RadioConfig.from_data(data.get("radios", {}))
|
radio_config = RadioConfig.from_data(data.get("radios", {}))
|
||||||
|
patrol_config = PatrolConfig.from_data(data.get("patrol", {}))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
introduction = data["introduced"]
|
introduction = data["introduced"]
|
||||||
@ -214,6 +232,8 @@ class AircraftType(UnitType[FlyingType]):
|
|||||||
lha_capable=data.get("lha_capable", False),
|
lha_capable=data.get("lha_capable", False),
|
||||||
always_keeps_gun=data.get("always_keeps_gun", False),
|
always_keeps_gun=data.get("always_keeps_gun", False),
|
||||||
max_group_size=data.get("max_group_size", aircraft.group_size_max),
|
max_group_size=data.get("max_group_size", aircraft.group_size_max),
|
||||||
|
patrol_altitude=patrol_config.altitude,
|
||||||
|
patrol_speed=patrol_config.speed,
|
||||||
intra_flight_radio=radio_config.intra_flight,
|
intra_flight_radio=radio_config.intra_flight,
|
||||||
channel_allocator=radio_config.channel_allocator,
|
channel_allocator=radio_config.channel_allocator,
|
||||||
channel_namer=radio_config.channel_namer,
|
channel_namer=radio_config.channel_namer,
|
||||||
|
|||||||
@ -16,17 +16,6 @@ from functools import cached_property
|
|||||||
from typing import Iterator, List, Optional, Set, TYPE_CHECKING, Tuple
|
from typing import Iterator, List, Optional, Set, TYPE_CHECKING, Tuple
|
||||||
|
|
||||||
from dcs.mapping import Point
|
from dcs.mapping import Point
|
||||||
from dcs.planes import (
|
|
||||||
E_3A,
|
|
||||||
E_2C,
|
|
||||||
A_50,
|
|
||||||
IL_78M,
|
|
||||||
KC130,
|
|
||||||
KC135MPRS,
|
|
||||||
KC_135,
|
|
||||||
KJ_2000,
|
|
||||||
S_3B_Tanker,
|
|
||||||
)
|
|
||||||
from dcs.unit import Unit
|
from dcs.unit import Unit
|
||||||
from shapely.geometry import Point as ShapelyPoint
|
from shapely.geometry import Point as ShapelyPoint
|
||||||
|
|
||||||
@ -1092,15 +1081,8 @@ class FlightPlanBuilder:
|
|||||||
|
|
||||||
orbit_location = self.aewc_orbit(location)
|
orbit_location = self.aewc_orbit(location)
|
||||||
|
|
||||||
# As high as possible to maximize detection and on-station time.
|
if flight.unit_type.patrol_altitude is not None:
|
||||||
if flight.unit_type.dcs_unit_type == E_2C:
|
patrol_alt = flight.unit_type.patrol_altitude
|
||||||
patrol_alt = feet(30000)
|
|
||||||
elif flight.unit_type.dcs_unit_type == E_3A:
|
|
||||||
patrol_alt = feet(35000)
|
|
||||||
elif flight.unit_type.dcs_unit_type == A_50:
|
|
||||||
patrol_alt = feet(33000)
|
|
||||||
elif flight.unit_type.dcs_unit_type == KJ_2000:
|
|
||||||
patrol_alt = feet(40000)
|
|
||||||
else:
|
else:
|
||||||
patrol_alt = feet(25000)
|
patrol_alt = feet(25000)
|
||||||
|
|
||||||
@ -1680,31 +1662,17 @@ class FlightPlanBuilder:
|
|||||||
builder = WaypointBuilder(flight, self.game, self.is_player)
|
builder = WaypointBuilder(flight, self.game, self.is_player)
|
||||||
|
|
||||||
tanker_type = flight.unit_type
|
tanker_type = flight.unit_type
|
||||||
if tanker_type.dcs_unit_type is KC_135:
|
if tanker_type.patrol_altitude is not None:
|
||||||
# ~300 knots IAS.
|
altitude = tanker_type.patrol_altitude
|
||||||
speed = knots(445)
|
|
||||||
altitude = feet(24000)
|
|
||||||
elif tanker_type.dcs_unit_type is KC135MPRS:
|
|
||||||
# ~300 knots IAS.
|
|
||||||
speed = knots(440)
|
|
||||||
altitude = feet(23000)
|
|
||||||
elif tanker_type.dcs_unit_type is KC130:
|
|
||||||
# ~210 knots IAS, roughly the max for the KC-130 at altitude.
|
|
||||||
speed = knots(370)
|
|
||||||
altitude = feet(22000)
|
|
||||||
elif tanker_type.dcs_unit_type is S_3B_Tanker:
|
|
||||||
# ~265 knots IAS.
|
|
||||||
speed = knots(320)
|
|
||||||
altitude = feet(12000)
|
|
||||||
elif tanker_type.dcs_unit_type is IL_78M:
|
|
||||||
# ~280 knots IAS.
|
|
||||||
speed = knots(400)
|
|
||||||
altitude = feet(21000)
|
|
||||||
else:
|
else:
|
||||||
# ~280 knots IAS.
|
|
||||||
speed = knots(400)
|
|
||||||
altitude = feet(21000)
|
altitude = feet(21000)
|
||||||
|
|
||||||
|
if tanker_type.patrol_speed is not None:
|
||||||
|
speed = tanker_type.patrol_speed
|
||||||
|
else:
|
||||||
|
# ~280 knots IAS at 21000.
|
||||||
|
speed = knots(400)
|
||||||
|
|
||||||
racetrack = builder.race_track(racetrack_start, racetrack_end, altitude)
|
racetrack = builder.race_track(racetrack_start, racetrack_end, altitude)
|
||||||
|
|
||||||
return RefuelingFlightPlan(
|
return RefuelingFlightPlan(
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
description: The A-50 is an AWACS plane.
|
description: The A-50 is an AWACS plane.
|
||||||
max_group_size: 1
|
max_group_size: 1
|
||||||
price: 50
|
price: 50
|
||||||
|
patrol:
|
||||||
|
altitude: 33000
|
||||||
variants:
|
variants:
|
||||||
A-50: null
|
A-50: null
|
||||||
|
|||||||
@ -8,5 +8,7 @@ manufacturer: Northrop Grumman
|
|||||||
origin: USA
|
origin: USA
|
||||||
price: 50
|
price: 50
|
||||||
role: AEW&C
|
role: AEW&C
|
||||||
|
patrol:
|
||||||
|
altitude: 30000
|
||||||
variants:
|
variants:
|
||||||
E-2C Hawkeye: {}
|
E-2C Hawkeye: {}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
description: The E-3A is a AWACS aicraft.
|
description: The E-3A is a AWACS aicraft.
|
||||||
price: 50
|
price: 50
|
||||||
max_group_size: 1
|
max_group_size: 1
|
||||||
|
patrol:
|
||||||
|
altitude: 35000
|
||||||
variants:
|
variants:
|
||||||
E-3A: null
|
E-3A: null
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
price: 20
|
price: 20
|
||||||
max_group_size: 1
|
max_group_size: 1
|
||||||
|
patrol:
|
||||||
|
# ~280 knots IAS.
|
||||||
|
speed: 400
|
||||||
|
altitude: 21000
|
||||||
variants:
|
variants:
|
||||||
IL-78M: null
|
IL-78M: null
|
||||||
|
|||||||
@ -8,5 +8,9 @@ manufacturer: Beoing
|
|||||||
origin: USA
|
origin: USA
|
||||||
price: 25
|
price: 25
|
||||||
role: Tanker
|
role: Tanker
|
||||||
|
patrol:
|
||||||
|
# ~300 knots IAS.
|
||||||
|
speed: 445
|
||||||
|
altitude: 24000
|
||||||
variants:
|
variants:
|
||||||
KC-135 Stratotanker: {}
|
KC-135 Stratotanker: {}
|
||||||
|
|||||||
@ -5,5 +5,9 @@ manufacturer: Lockheed Martin
|
|||||||
origin: USA
|
origin: USA
|
||||||
price: 25
|
price: 25
|
||||||
role: Tanker
|
role: Tanker
|
||||||
|
patrol:
|
||||||
|
# ~210 knots IAS, roughly the max for the KC-130 at altitude.
|
||||||
|
speed: 370
|
||||||
|
altitude: 22000
|
||||||
variants:
|
variants:
|
||||||
KC-130: {}
|
KC-130: {}
|
||||||
|
|||||||
@ -7,5 +7,9 @@ manufacturer: Boeing
|
|||||||
origin: USA
|
origin: USA
|
||||||
price: 25
|
price: 25
|
||||||
role: Tanker
|
role: Tanker
|
||||||
|
patrol:
|
||||||
|
# 300 knots IAS.
|
||||||
|
speed: 440
|
||||||
|
altitude: 23000
|
||||||
variants:
|
variants:
|
||||||
KC-135 Stratotanker MPRS: {}
|
KC-135 Stratotanker MPRS: {}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
price: 50
|
price: 50
|
||||||
|
patrol:
|
||||||
|
altitude: 40000
|
||||||
variants:
|
variants:
|
||||||
KJ-2000: null
|
KJ-2000: null
|
||||||
|
|||||||
@ -16,5 +16,9 @@ origin: USA
|
|||||||
price: 20
|
price: 20
|
||||||
max_group_size: 1
|
max_group_size: 1
|
||||||
role: Carrier-based Tanker
|
role: Carrier-based Tanker
|
||||||
|
patrol:
|
||||||
|
# ~265 knots IAS.
|
||||||
|
speed: 320
|
||||||
|
altitude: 12000
|
||||||
variants:
|
variants:
|
||||||
S-3B Tanker: {}
|
S-3B Tanker: {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user