mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Replace client count with player pilots.
https://github.com/dcs-liberation/dcs_liberation/issues/276
This commit is contained in:
@@ -751,6 +751,16 @@ class AircraftConflictGenerator:
|
||||
new_level = min(current_level + increase, len(levels) - 1)
|
||||
return levels[new_level]
|
||||
|
||||
def set_skill(self, unit: FlyingUnit, pilot: Optional[Pilot], blue: bool) -> None:
|
||||
if pilot is None or not pilot.player:
|
||||
unit.skill = self.skill_level_for(unit, pilot, blue)
|
||||
return
|
||||
|
||||
if self.use_client:
|
||||
unit.set_client()
|
||||
else:
|
||||
unit.set_player()
|
||||
|
||||
def _setup_group(
|
||||
self,
|
||||
group: FlyingGroup,
|
||||
@@ -777,29 +787,17 @@ class AircraftConflictGenerator:
|
||||
for unit_instance in group.units:
|
||||
unit_instance.livery_id = livery
|
||||
|
||||
num_clients = min(len(group.units), flight.client_count)
|
||||
for idx in range(0, num_clients):
|
||||
unit = group.units[idx]
|
||||
if self.use_client:
|
||||
unit.set_client()
|
||||
else:
|
||||
unit.set_player()
|
||||
|
||||
for unit, pilot in zip(group.units, flight.pilots):
|
||||
player = pilot is not None and pilot.player
|
||||
self.set_skill(unit, pilot, blue=flight.departure.captured)
|
||||
# Do not generate player group with late activation.
|
||||
if group.late_activation:
|
||||
if player and group.late_activation:
|
||||
group.late_activation = False
|
||||
|
||||
# Set up F-14 Client to have pre-stored alignment
|
||||
if unit_type is F_14B:
|
||||
unit.set_property(F_14B.Properties.INSAlignmentStored.id, True)
|
||||
|
||||
for idx in range(num_clients, len(group.units)):
|
||||
unit = group.units[idx]
|
||||
pilot = flight.pilots[idx]
|
||||
unit.skill = self.skill_level_for(
|
||||
unit, pilot, blue=flight.departure.captured
|
||||
)
|
||||
|
||||
group.points[0].tasks.append(
|
||||
OptReactOnThreat(OptReactOnThreat.Values.EvadeFire)
|
||||
)
|
||||
|
||||
@@ -228,7 +228,6 @@ class Flight:
|
||||
self.loadout = Loadout.default_for(self)
|
||||
self.start_type = start_type
|
||||
self.use_custom_loadout = False
|
||||
self.client_count = 0
|
||||
self.custom_name = custom_name
|
||||
|
||||
# Only used by transport missions.
|
||||
@@ -247,6 +246,10 @@ class Flight:
|
||||
def count(self) -> int:
|
||||
return len(self.pilots)
|
||||
|
||||
@property
|
||||
def client_count(self) -> int:
|
||||
return len([p for p in self.pilots if p is not None and p.player])
|
||||
|
||||
@property
|
||||
def unit_type(self) -> Type[FlyingType]:
|
||||
return self.squadron.aircraft
|
||||
|
||||
Reference in New Issue
Block a user