Skip to content

Commit

Permalink
Generate anti-ship missions with group attack.
Browse files Browse the repository at this point in the history
Fixes #3068.
  • Loading branch information
DanAlbert committed Jul 12, 2023
1 parent adabb61 commit efc59b1
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Saves from 8.x are not compatible with 9.0.0.
## Fixes

* **[Data]** Fixed the class of the Samuel Chase so it can't be picked for a AAA or SHORAD site.
* **[Mission Generation]** Restored previous AI behavior for anti-ship missions. A DCS update caused only a single aircraft in a flight to attack. The full flight will now attack like they used to.

# 8.1.0

Expand Down
2 changes: 1 addition & 1 deletion game/ato/flightplans/antiship.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def layout(self) -> FormationAttackLayout:
else:
raise InvalidObjectiveLocation(self.flight.flight_type, location)

return self._build(FlightWaypointType.INGRESS_BAI, targets)
return self._build(FlightWaypointType.INGRESS_ANTI_SHIP, targets)

Check warning on line 38 in game/ato/flightplans/antiship.py

View check run for this annotation

Codecov / codecov/patch

game/ato/flightplans/antiship.py#L38

Added line #L38 was not covered by tests

@staticmethod
def anti_ship_targets_for_tgo(tgo: NavalGroundObject) -> list[StrikeTarget]:
Expand Down
1 change: 1 addition & 0 deletions game/ato/flightwaypointtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ class FlightWaypointType(IntEnum):
CARGO_STOP = 30 # Stopover landing point using the LandingReFuAr waypoint type
INGRESS_AIR_ASSAULT = 31
RECOVERY_TANKER = 32
INGRESS_ANTI_SHIP = 33
45 changes: 45 additions & 0 deletions game/missiongenerator/aircraft/waypoints/antishipingress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import logging

Check warning on line 1 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L1

Added line #L1 was not covered by tests

from dcs.point import MovingPoint
from dcs.task import AttackGroup, OptFormation, WeaponType

Check warning on line 4 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L3-L4

Added lines #L3 - L4 were not covered by tests

from game.theater import NavalControlPoint, TheaterGroundObject
from game.transfers import MultiGroupTransport
from .pydcswaypointbuilder import PydcsWaypointBuilder

Check warning on line 8 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L6-L8

Added lines #L6 - L8 were not covered by tests


class AntiShipIngressBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None:

Check warning on line 12 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L11-L12

Added lines #L11 - L12 were not covered by tests
# TODO: Add common "UnitGroupTarget" base type.
group_names = []
target = self.package.target

Check warning on line 15 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L14-L15

Added lines #L14 - L15 were not covered by tests
if isinstance(target, TheaterGroundObject):
for group in target.groups:
group_names.append(group.group_name)

Check warning on line 18 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L18

Added line #L18 was not covered by tests
elif isinstance(target, MultiGroupTransport):
group_names.append(target.name)

Check warning on line 20 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L20

Added line #L20 was not covered by tests
elif isinstance(target, NavalControlPoint):
carrier_name = target.get_carrier_group_name()

Check warning on line 22 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L22

Added line #L22 was not covered by tests
if carrier_name:
group_names.append(carrier_name)

Check warning on line 24 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L24

Added line #L24 was not covered by tests
else:
logging.error(

Check warning on line 26 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L26

Added line #L26 was not covered by tests
"Unexpected target type for anti-ship mission: %s",
target.__class__.__name__,
)
return

Check warning on line 30 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L30

Added line #L30 was not covered by tests

for group_name in group_names:
miz_group = self.mission.find_group(group_name)

Check warning on line 33 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L33

Added line #L33 was not covered by tests
if miz_group is None:
logging.error(

Check warning on line 35 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L35

Added line #L35 was not covered by tests
"Could not find group for anti-ship mission %s", group_name
)
continue

Check warning on line 38 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L38

Added line #L38 was not covered by tests

task = AttackGroup(

Check warning on line 40 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L40

Added line #L40 was not covered by tests
miz_group.id, weapon_type=WeaponType.Auto, group_attack=True
)
waypoint.tasks.append(task)

Check warning on line 43 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L43

Added line #L43 was not covered by tests

waypoint.tasks.append(OptFormation.trail_open())

Check warning on line 45 in game/missiongenerator/aircraft/waypoints/antishipingress.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/antishipingress.py#L45

Added line #L45 was not covered by tests
2 changes: 2 additions & 0 deletions game/missiongenerator/aircraft/waypoints/waypointgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from game.settings import Settings
from game.unitmap import UnitMap
from game.utils import pairwise
from .antishipingress import AntiShipIngressBuilder

Check warning on line 27 in game/missiongenerator/aircraft/waypoints/waypointgenerator.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/aircraft/waypoints/waypointgenerator.py#L27

Added line #L27 was not covered by tests
from .baiingress import BaiIngressBuilder
from .casingress import CasIngressBuilder
from .deadingress import DeadIngressBuilder
Expand Down Expand Up @@ -127,6 +128,7 @@ def builder_for_waypoint(
self, waypoint: FlightWaypoint, generated_waypoint_index: int
) -> PydcsWaypointBuilder:
builders = {
FlightWaypointType.INGRESS_ANTI_SHIP: AntiShipIngressBuilder,
FlightWaypointType.INGRESS_BAI: BaiIngressBuilder,
FlightWaypointType.INGRESS_CAS: CasIngressBuilder,
FlightWaypointType.INGRESS_DEAD: DeadIngressBuilder,
Expand Down

0 comments on commit efc59b1

Please sign in to comment.