def _set_skill(self, player_coalition: str, enemy_coalition: str): """ Set skill level for all aircraft in the mission """ 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, ) elif coalition_name == enemy_coalition: skill_level = ( self.game.settings.enemy_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]))
def skill_level_for(self, unit: FlyingUnit, pilot: Optional[Pilot]) -> Skill: if self.flight.squadron.player: 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 capped_increase = min(current_level + increase, len(levels) - 1) new_level = (capped_increase, current_level)[self.game.settings.ai_pilot_levelling] return levels[new_level]
def _generate_groups( self, groups: list[CombatGroup], frontline_vector: Tuple[Point, int, int], is_player: bool, ) -> List[Tuple[VehicleGroup, CombatGroup]]: """Finds valid positions for planned groups and generates a pydcs group for them""" positioned_groups = [] position, heading, combat_width = frontline_vector spawn_heading = ( int(heading_sum(heading, -90)) if is_player else int(heading_sum(heading, 90)) ) country = self.game.player_country if is_player else self.game.enemy_country for group in groups: if group.role == CombatGroupRole.ARTILLERY: distance_from_frontline = ( self.get_artilery_group_distance_from_frontline(group) ) else: distance_from_frontline = random.randint( DISTANCE_FROM_FRONTLINE[group.role][0], DISTANCE_FROM_FRONTLINE[group.role][1], ) final_position = self.get_valid_position_for_group( position, combat_width, distance_from_frontline, heading, spawn_heading ) if final_position is not None: g = self._generate_group( self.mission.country(country), group.unit_type, group.size, final_position, heading=opposite_heading(spawn_heading), ) if is_player: g.set_skill(Skill(self.game.settings.player_skill)) else: g.set_skill(Skill(self.game.settings.enemy_vehicle_skill)) positioned_groups.append((g, group)) if group.role in [CombatGroupRole.APC, CombatGroupRole.IFV]: self.gen_infantry_group_for_group( g, is_player, self.mission.country(country), opposite_heading(spawn_heading), ) else: logging.warning(f"Unable to get valid position for {group}") return positioned_groups
def _set_skill(self, player_coalition: str, enemy_coalition: str) -> None: """ Set skill level for all aircraft in the mission """ for coalition_name, coalition in self.mission.coalition.items(): if coalition_name == player_coalition: skill_level = Skill(self.game.settings.player_skill) elif coalition_name == enemy_coalition: skill_level = Skill(self.game.settings.enemy_vehicle_skill) else: continue for country in coalition.countries.values(): for vehicle_group in country.vehicle_group: vehicle_group.set_skill(skill_level)
def _set_skill(self, player_coalition: str, enemy_coalition: str): 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 elif coalition_name == enemy_coalition: skill_level = self.game.settings.enemy_skill, self.game.settings.enemy_vehicle_skill else: continue for country in coalition.countries.values(): for plane_group in country.plane_group: for plane_unit in plane_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]))