mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Increase skill level for experienced pilots.
https://github.com/dcs-liberation/dcs_liberation/issues/276
This commit is contained in:
parent
8b8d1e87e7
commit
e480519855
@ -70,7 +70,7 @@ from dcs.task import (
|
||||
)
|
||||
from dcs.terrain.terrain import Airport, NoParkingSlotError
|
||||
from dcs.triggers import Event, TriggerOnce, TriggerRule
|
||||
from dcs.unit import Unit
|
||||
from dcs.unit import Unit, Skill
|
||||
from dcs.unitgroup import FlyingGroup, ShipGroup, StaticGroup
|
||||
from dcs.unittype import FlyingType, UnitType
|
||||
|
||||
@ -80,6 +80,7 @@ from game.data.weapons import Pylon
|
||||
from game.db import GUN_RELIANT_AIRFRAMES
|
||||
from game.factions.faction import Faction
|
||||
from game.settings import Settings
|
||||
from game.squadrons import Pilot
|
||||
from game.theater.controlpoint import (
|
||||
Airfield,
|
||||
ControlPoint,
|
||||
@ -726,6 +727,30 @@ class AircraftConflictGenerator:
|
||||
return StartType.Cold
|
||||
return StartType.Warm
|
||||
|
||||
def skill_level_for(
|
||||
self, unit: FlyingUnit, pilot: Optional[Pilot], blue: bool
|
||||
) -> Skill:
|
||||
if blue:
|
||||
base_skill = Skill(self.game.settings.player_skill)
|
||||
else:
|
||||
base_skill = Skill(self.game.settings.enemy_skill)
|
||||
|
||||
if pilot is None:
|
||||
logging.error(f"Cannot determine skill level: {unit.name} has not pilot")
|
||||
return base_skill
|
||||
|
||||
levels = [
|
||||
Skill.Average,
|
||||
Skill.Good,
|
||||
Skill.High,
|
||||
Skill.Excellent,
|
||||
]
|
||||
current_level = levels.index(base_skill)
|
||||
missions_for_skill_increase = 4
|
||||
increase = pilot.record.missions_flown // missions_for_skill_increase
|
||||
new_level = min(current_level + increase, len(levels) - 1)
|
||||
return levels[new_level]
|
||||
|
||||
def _setup_group(
|
||||
self,
|
||||
group: FlyingGroup,
|
||||
@ -752,7 +777,8 @@ class AircraftConflictGenerator:
|
||||
for unit_instance in group.units:
|
||||
unit_instance.livery_id = livery
|
||||
|
||||
for idx in range(0, min(len(group.units), flight.client_count)):
|
||||
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()
|
||||
@ -763,10 +789,17 @@ class AircraftConflictGenerator:
|
||||
if group.late_activation:
|
||||
group.late_activation = False
|
||||
|
||||
# Set up F-14 Client to have pre-stored alignement
|
||||
# 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)
|
||||
)
|
||||
|
||||
@ -96,32 +96,15 @@ class TriggersGenerator:
|
||||
"""
|
||||
for coalition_name, coalition in self.mission.coalition.items():
|
||||
if coalition_name == player_coalition:
|
||||
skill_level = (
|
||||
self.game.settings.player_skill,
|
||||
self.game.settings.player_skill,
|
||||
)
|
||||
skill_level = Skill(self.game.settings.player_skill)
|
||||
elif coalition_name == enemy_coalition:
|
||||
skill_level = (
|
||||
self.game.settings.enemy_skill,
|
||||
self.game.settings.enemy_vehicle_skill,
|
||||
)
|
||||
skill_level = Skill(self.game.settings.enemy_vehicle_skill)
|
||||
else:
|
||||
continue
|
||||
|
||||
for country in coalition.countries.values():
|
||||
flying_groups = (
|
||||
country.plane_group + country.helicopter_group
|
||||
) # type: FlyingGroup
|
||||
for flying_group in flying_groups:
|
||||
for plane_unit in flying_group.units:
|
||||
if (
|
||||
plane_unit.skill != Skill.Client
|
||||
and plane_unit.skill != Skill.Player
|
||||
):
|
||||
plane_unit.skill = Skill(skill_level[0])
|
||||
|
||||
for vehicle_group in country.vehicle_group:
|
||||
vehicle_group.set_skill(Skill(skill_level[1]))
|
||||
vehicle_group.set_skill(skill_level)
|
||||
|
||||
def _gen_markers(self):
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user