diff --git a/game/ground_forces/ai_ground_planner.py b/game/ground_forces/ai_ground_planner.py index 86dc8f60..a5cfb9f0 100644 --- a/game/ground_forces/ai_ground_planner.py +++ b/game/ground_forces/ai_ground_planner.py @@ -151,7 +151,12 @@ class GroundPlanner: while available > 0: if len(self.connected_enemy_cp) > 0: enemy_cp: ControlPoint = random.choice(self.connected_enemy_cp) - frontline_stance = self.cp.stances[enemy_cp.id] + frontline_stance = self.cp.stances.get(enemy_cp.id) + if not frontline_stance: + logging.warning( + f"{self.cp.name} lost its frontline stance for {enemy_cp.name}" + ) + frontline_stance = CombatStance.DEFENSIVE group_size_choice = GROUP_SIZES_BY_COMBAT_STANCE[frontline_stance] if role == CombatGroupRole.SHORAD: count = 1 diff --git a/game/missiongenerator/aircraft/aircraftbehavior.py b/game/missiongenerator/aircraft/aircraftbehavior.py index ccaa0520..119e8068 100644 --- a/game/missiongenerator/aircraft/aircraftbehavior.py +++ b/game/missiongenerator/aircraft/aircraftbehavior.py @@ -351,6 +351,8 @@ class AircraftBehavior: preferred_task: Type[MainTask], fallback_task: Optional[Type[MainTask]] = None, ) -> None: + ac_type = flight.unit_type.dcs_unit_type.id + # Not all aircraft are always compatible with the preferred task, # so a common fallback is to use CAS instead. # Sometimes it's also the other way around, @@ -362,8 +364,12 @@ class AircraftBehavior: group.task = preferred_task.name elif fallback_task and fallback_task in flight.unit_type.dcs_unit_type.tasks: group.task = fallback_task.name + elif flight.unit_type.dcs_unit_type.task_default and preferred_task == Nothing: + group.task = flight.unit_type.dcs_unit_type.task_default.name + logging.warning( + f"{ac_type} is not capable of 'Nothing', using default task '{group.task}'" + ) else: - ac_type = flight.unit_type.dcs_unit_type.id fallback_part = f" nor {fallback_task.name}" if fallback_task else "" raise RuntimeError( f"{ac_type} is neither capable of {preferred_task.name}"