Fix group targeting for multi-group TGOs.

AI flights were only getting a single Attack Group task against multi-
group TGOs (currently only a small group of SAMs like the SA-10, I
believe), so the AI would never attack the point defense SA-15 or AAA
groups.
This commit is contained in:
Dan Albert 2021-05-24 19:26:03 -07:00
parent e94657875f
commit d15bfaac76
2 changed files with 66 additions and 50 deletions

View File

@ -9,10 +9,8 @@ Saves from 2.5 are not compatible with 3.0.
* **[Campaign]** Ground units must now be recruited at a base with a factory and transferred to their destination. When buying units in the UI, the purchase will automatically be fulfilled at the closest factory, and a transfer will be created on the next turn.
* **[Campaign]** Non-control point FOBs will no longer spawn.
* **[Campaign AI]** AI now considers Ju-88s for CAS, strike, and DEAD missions.
* **[Campaign AI]** Fix purchase of aircraft by priority (the faction's list was being used as the priority list rather than the game's).
* **[Campaign AI]** AI planned AEW&C missions will now be scheduled ASAP.
* **[Flight Planner]** Desired mission length is now configurable (defaults to 60 minutes). A BARCAP will be planned every 30 minutes. Other packages will simply have their takeoffs spread out or compressed such that the last flight will take off around the mission end time.
* **[Flight Planner]** AI strike flight plans now include the correct target actions for building groups.
* **[Flight Planner]** Flight plans now include bullseye waypoints.
* **[Flight Planner]** Differentiated SEAD and SEAD escort. SEAD is tasked with suppressing the package target, SEAD escort is tasked with protecting the package from all SAMs along its route.
* **[Flight Planner]** Planned airspeed increased to 0.85 mach for supersonic airframes and 85% of max speed for subsonic.
@ -34,10 +32,13 @@ Saves from 2.5 are not compatible with 3.0.
## Fixes
* **[Campaign AI]** Fix purchase of aircraft by priority (the faction's list was being used as the priority list rather than the game's).
* **[Campaign AI]** Fixed bug causing AI to over-purchase cheap aircraft.
* **[Campaign AI]** Auto planner will no longer attempt to plan missions for which the faction has no compatible aircraft.
* **[Campaign AI]** Stop purchasing aircraft after the first unaffordable package to attempt to complete more packages rather than filling airfields with cheap escorts that will never be used.
* **[Campaign]** Fixed bug where offshore strike locations were being used to spawn ship objectives.
* **[Flight Planner]** AI strike flight plans now include the correct target actions for building groups.
* **[Flight Planner]** AI BAI/DEAD/SEAD flights now have tasks to attack all groups at the target location, not just the primary group (for multi-group SAM sites).
# 2.5.1

View File

@ -1737,29 +1737,32 @@ class BaiIngressBuilder(PydcsWaypointBuilder):
waypoint = super().build()
# TODO: Add common "UnitGroupTarget" base type.
target_group = self.package.target
if isinstance(target_group, TheaterGroundObject):
group_name = target_group.group_name
elif isinstance(target_group, MultiGroupTransport):
group_name = target_group.name
group_names = []
target = self.package.target
if isinstance(target, TheaterGroundObject):
for group in target.groups:
group_names.append(group.name)
elif isinstance(target, MultiGroupTransport):
group_names.append(target.name)
else:
logging.error(
"Unexpected target type for BAI mission: %s",
target_group.__class__.__name__,
target.__class__.__name__,
)
return waypoint
group = self.mission.find_group(group_name)
if group is None:
logging.error("Could not find group for BAI mission %s", group_name)
return waypoint
for group_name in group_names:
group = self.mission.find_group(group_name)
if group is None:
logging.error("Could not find group for BAI mission %s", group_name)
continue
task = AttackGroup(group.id, weapon_type=WeaponType.Auto)
task.params["attackQtyLimit"] = False
task.params["directionEnabled"] = False
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
task = AttackGroup(group.id, weapon_type=WeaponType.Auto)
task.params["attackQtyLimit"] = False
task.params["directionEnabled"] = False
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
return waypoint
@ -1796,23 +1799,29 @@ class CasIngressBuilder(PydcsWaypointBuilder):
class DeadIngressBuilder(PydcsWaypointBuilder):
def build(self) -> MovingPoint:
waypoint = super().build()
target_group = self.package.target
if isinstance(target_group, TheaterGroundObject):
tgroup = self.mission.find_group(target_group.group_name)
if tgroup is not None:
task = AttackGroup(tgroup.id, weapon_type=WeaponType.Auto)
task.params["expend"] = "All"
task.params["attackQtyLimit"] = False
task.params["directionEnabled"] = False
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
else:
logging.error(
f"Could not find group for DEAD mission {target_group.group_name}"
)
self.register_special_waypoints(self.waypoint.targets)
target = self.package.target
if not isinstance(target, TheaterGroundObject):
logging.error(
"Unexpected target type for DEAD mission: %s",
target.__class__.__name__,
)
return waypoint
for group in target.groups:
miz_group = self.mission.find_group(group.name)
if miz_group is None:
logging.error(f"Could not find group for DEAD mission {group.name}")
continue
task = AttackGroup(miz_group.id, weapon_type=WeaponType.Auto)
task.params["expend"] = "All"
task.params["attackQtyLimit"] = False
task.params["directionEnabled"] = False
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
return waypoint
@ -1864,23 +1873,29 @@ class OcaRunwayIngressBuilder(PydcsWaypointBuilder):
class SeadIngressBuilder(PydcsWaypointBuilder):
def build(self) -> MovingPoint:
waypoint = super().build()
target_group = self.package.target
if isinstance(target_group, TheaterGroundObject):
tgroup = self.mission.find_group(target_group.group_name)
if tgroup is not None:
task = AttackGroup(tgroup.id, weapon_type=WeaponType.Guided)
task.params["expend"] = "All"
task.params["attackQtyLimit"] = False
task.params["directionEnabled"] = False
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
else:
logging.error(
f"Could not find group for SEAD mission {target_group.group_name}"
)
self.register_special_waypoints(self.waypoint.targets)
target = self.package.target
if not isinstance(target, TheaterGroundObject):
logging.error(
"Unexpected target type for SEAD mission: %s",
target.__class__.__name__,
)
return waypoint
for group in target.groups:
miz_group = self.mission.find_group(group.name)
if miz_group is None:
logging.error(f"Could not find group for SEAD mission {group.name}")
continue
task = AttackGroup(miz_group.id, weapon_type=WeaponType.Guided)
task.params["expend"] = "All"
task.params["attackQtyLimit"] = False
task.params["directionEnabled"] = False
task.params["altitudeEnabled"] = False
task.params["groupAttack"] = True
waypoint.tasks.append(task)
return waypoint