From 8dac4eca55df4cd71369b3be18aa5260ed53a98e Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 23 Jan 2021 14:29:10 -0800 Subject: [PATCH] Don't plan strikes against non-strike targets. FOB strucutres can't be repaired and the player can't target them. SAMs are targeted by DEAD already, so considering them for strike double plans the mission. Fixes https://github.com/Khopa/dcs_liberation/issues/686 --- changelog.md | 2 ++ gen/flights/ai_flight_planner.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/changelog.md b/changelog.md index 83cd6b34..63d218bd 100644 --- a/changelog.md +++ b/changelog.md @@ -49,6 +49,8 @@ Saves from 2.3 are not compatible with 2.4. * **[Units]** Submarines have been removed for now as they aren't wholly functional. * **[Units]** Fixed "FACTION ERROR : Unable to find OliverHazardPerryGroupGenerator in pydcs" error at startup. * **[Flight Planner]** Fixed not being able to create custom waypoints for buildings. +* **[Flight Planner]** Strike missions will no longer be automatically planned against SAMs. +* **[Flight Planner]** Strike missions will no longer be automatically planned against FOB structures. # 2.3.4 diff --git a/gen/flights/ai_flight_planner.py b/gen/flights/ai_flight_planner.py index 45c9d1e6..f4479cf5 100644 --- a/gen/flights/ai_flight_planner.py +++ b/gen/flights/ai_flight_planner.py @@ -26,6 +26,7 @@ from game.procurement import AircraftProcurementRequest from game.theater import ( Airfield, ControlPoint, + Fob, FrontLine, MissionTarget, OffMapSpawn, @@ -33,6 +34,7 @@ from game.theater import ( TheaterGroundObject, ) from game.theater.theatergroundobject import ( + BuildingGroundObject, EwrGroundObject, NavalGroundObject, VehicleGroupGroundObject, @@ -346,12 +348,35 @@ class ObjectiveFinder: found_targets: Set[str] = set() for enemy_cp in self.enemy_control_points(): for ground_object in enemy_cp.ground_objects: + # TODO: Reuse ground_object.mission_types. + # The mission types for ground objects are currently not + # accurate because we include things like strike and BAI for all + # targets since they have different planning behavior (waypoint + # generation is better for players with strike when the targets + # are stationary, AI behavior against weaker air defenses is + # better with BAI), so that's not a useful filter. Once we have + # better control over planning profiles and target dependent + # loadouts we can clean this up. if isinstance(ground_object, VehicleGroupGroundObject): # BAI target, not strike target. continue + if isinstance(ground_object, NavalGroundObject): # Anti-ship target, not strike target. continue + + if isinstance(ground_object, SamGroundObject): + # SAMs are targeted by DEAD. No need to double plan. + continue + + is_building = isinstance(ground_object, BuildingGroundObject) + is_fob = isinstance(enemy_cp, Fob) + if is_building and is_fob and ground_object.airbase_group: + # This is the FOB structure itself. Can't be repaired or + # targeted by the player, so shouldn't be targetable by the + # AI. + continue + if ground_object.is_dead: continue if ground_object.name in found_targets: