mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add an option to prefer primary tasked aircraft.
We're still using mostly the same aircraft selection as we have before we added squadrons: the closest aircraft is the best choice. This adds an option to obey the primary task set by the campaign designer (can be overridden by players), even if the squadron is farther away than one that is capable of it as a secondary task. I don't expect this option to live very long. I'm making it optional for now to give people a chance to test it, but it'll either replace the old selection strategy or will be removed. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1892.
This commit is contained in:
@@ -23,6 +23,7 @@ class AirWing:
|
||||
self.squadrons: dict[AircraftType, list[Squadron]] = defaultdict(list)
|
||||
self.squadron_defs = SquadronDefLoader(game, faction).load()
|
||||
self.squadron_def_generator = SquadronDefGenerator(faction)
|
||||
self.settings = game.settings
|
||||
|
||||
def unclaim_squadron_def(self, squadron: Squadron) -> None:
|
||||
if squadron.aircraft in self.squadron_defs:
|
||||
@@ -66,6 +67,17 @@ class AirWing:
|
||||
key=lambda s: best_aircraft.index(s.aircraft),
|
||||
)
|
||||
)
|
||||
|
||||
if self.settings.prefer_squadrons_with_matching_primary_task:
|
||||
return sorted(
|
||||
ordered,
|
||||
key=lambda s: (
|
||||
# This looks like the opposite of what we want because False sorts
|
||||
# before True.
|
||||
s.primary_task != task,
|
||||
s.location.distance_to(location),
|
||||
),
|
||||
)
|
||||
return ordered
|
||||
|
||||
def best_squadron_for(
|
||||
|
||||
@@ -31,6 +31,7 @@ class Squadron:
|
||||
role: str
|
||||
aircraft: AircraftType
|
||||
livery: Optional[str]
|
||||
primary_task: FlightType
|
||||
auto_assignable_mission_types: set[FlightType]
|
||||
operating_bases: OperatingBases
|
||||
female_pilot_percentage: int
|
||||
@@ -416,6 +417,7 @@ class Squadron:
|
||||
def create_from(
|
||||
cls,
|
||||
squadron_def: SquadronDef,
|
||||
primary_task: FlightType,
|
||||
base: ControlPoint,
|
||||
coalition: Coalition,
|
||||
game: Game,
|
||||
@@ -428,6 +430,7 @@ class Squadron:
|
||||
squadron_def.role,
|
||||
squadron_def.aircraft,
|
||||
squadron_def.livery,
|
||||
primary_task,
|
||||
squadron_def.auto_assignable_mission_types,
|
||||
squadron_def.operating_bases,
|
||||
squadron_def.female_pilot_percentage,
|
||||
|
||||
Reference in New Issue
Block a user