Merge remote-tracking branch 'remotes/dcs-retribution/dcs-retribution/dev' into pretense-generator

This commit is contained in:
MetalStormGhost
2024-05-09 21:16:32 +03:00
25 changed files with 262 additions and 73 deletions

View File

@@ -22,6 +22,10 @@ class FlightRoster(IFlightRoster):
def iter_pilots(self) -> Iterator[Pilot | None]:
yield from self.pilots
@property
def player_count(self) -> int:
return len([p for p in self.pilots if p is not None and p.player])
def pilot_at(self, idx: int) -> Pilot | None:
return self.pilots[idx]

View File

@@ -26,6 +26,11 @@ class IFlightRoster(ABC):
def max_size(self) -> int:
...
@property
@abstractmethod
def player_count(self) -> int:
...
@abstractmethod
def resize(self, new_size: int) -> None:
...

View File

@@ -76,6 +76,12 @@ class PackageBuilder:
member.assign_tgp_laser_code(
self.laser_code_registry.alloc_laser_code()
)
# If this is a client flight, set the start_type again to match the configured default
# https://github.com/dcs-liberation/dcs_liberation/issues/1567
if flight.roster is not None and flight.roster.player_count > 0:
flight.start_type = (
squadron.coalition.game.settings.default_start_type_client
)
self.package.add_flight(flight)
return True

View File

@@ -363,7 +363,7 @@ class Debriefing:
seen = set()
captures = []
for capture in reversed(self.state_data.base_capture_events):
# The ID string in the JSON file will be the UUID generated from liberation
# The ID string in the JSON file will be the UUID generated from retribution
cp_id, new_owner_id_str, _name = capture.split("||")
# Only the most recent capture event matters.

View File

@@ -20,7 +20,7 @@ from dcs.planes import (
from dcs.point import PointAction
from dcs.ships import KUZNECOW
from dcs.terrain import NoParkingSlotError, Sinai, ParkingSlot
from dcs.terrain.sinai.airports import Nevatim
from dcs.terrain.sinai.airports import Nevatim, Ramon_Airbase
from dcs.unitgroup import (
FlyingGroup,
ShipGroup,
@@ -132,6 +132,16 @@ class FlightGroupSpawner:
for slot in cp.dcs_airport.free_parking_slots(ac_type)
if slot.slot_name in [str(n) for n in range(55, 66)]
]
elif self._check_ramon_airbase_hack(cp):
ac_type = self.flight.unit_type.dcs_unit_type
slots = [
slot
for slot in cp.dcs_airport.free_parking_slots(ac_type)
if slot.slot_name
not in [
str(n) for n in [1, 2, 3, 4, 5, 6, 13, 14, 15, 16, 17, 18, 61]
]
]
group = self._generate_at_airfield(
name=namegen.next_aircraft_name(self.country, self.flight),
airfield=cp,
@@ -215,6 +225,20 @@ class FlightGroupSpawner:
if slot.slot_name in [str(n) for n in range(55, 66)]
]
return self._generate_at_airfield(name, cp, slots)
elif self._check_ramon_airbase_hack(cp):
# TODO: get rid of the ramon airbase hack once fixed in DCS...
slots = [
slot
for slot in cp.dcs_airport.free_parking_slots(
self.flight.squadron.aircraft.dcs_unit_type
)
if slot.slot_name
not in [
str(n)
for n in [1, 2, 3, 4, 5, 6, 13, 14, 15, 16, 17, 18, 61]
]
]
return self._generate_at_airfield(name, cp, slots)
else:
return self._generate_at_airfield(name, cp)
else:
@@ -237,6 +261,13 @@ class FlightGroupSpawner:
nevatim_hack &= isinstance(cp.dcs_airport, Nevatim)
return nevatim_hack
def _check_ramon_airbase_hack(self, cp: ControlPoint) -> bool:
# TODO: get rid of the ramon airbase hack once fixed in DCS...
ramon_airbase_hack = self.flight.coalition.game.settings.nevatim_parking_fix
ramon_airbase_hack &= isinstance(self.mission.terrain, Sinai)
ramon_airbase_hack &= isinstance(cp.dcs_airport, Ramon_Airbase)
return ramon_airbase_hack
def generate_mid_mission(self) -> FlyingGroup[Any]:
assert isinstance(self.flight.state, InFlight)
name = namegen.next_aircraft_name(self.country, self.flight)

View File

@@ -756,14 +756,22 @@ class Settings:
"will not be included in automatically planned OCA packages."
),
)
default_start_type_client: StartType = choices_option(
"Default start type for Player flights",
page=MISSION_GENERATOR_PAGE,
section=GAMEPLAY_SECTION,
choices={v.value: v for v in StartType},
default=StartType.COLD,
detail=("Default start type for flights containing Player/Client slots."),
)
nevatim_parking_fix: bool = boolean_option(
"Force air-starts for all aircraft at Nevatim",
"Force air-starts for aircraft at Nevatim and Ramon Airbase inoperable parking slots",
page=MISSION_GENERATOR_PAGE,
section=GAMEPLAY_SECTION,
default=True, # TODO: set to False or remove this when DCS is fixed
detail=(
"Air-starts forced for all aircraft at Nevatim except parking slots "
"55 till 65, since those are the only ones that work."
"Air-starts forced for all aircraft at Nevatim and Ramon Airbase except parking slots "
"which are known to work as of DCS World 2.9.4.53990."
),
)
# Mission specific

View File

@@ -1,4 +1,4 @@
"""Maps generated units back to their Liberation types."""
"""Maps generated units back to their Retribution types."""
from __future__ import annotations
import itertools

View File

@@ -30,7 +30,7 @@ def _build_version_string() -> str:
return "-".join(components)
#: Current version of Liberation.
#: Current version of Retribution.
VERSION = _build_version_string()
#: The latest version of the campaign format. Increment this version whenever all