-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate anti-ship missions with group attack.
Fixes #3068.
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
game/missiongenerator/aircraft/waypoints/antishipingress.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import logging | ||
|
||
from dcs.point import MovingPoint | ||
from dcs.task import AttackGroup, OptFormation, WeaponType | ||
|
||
from game.theater import NavalControlPoint, TheaterGroundObject | ||
from game.transfers import MultiGroupTransport | ||
from .pydcswaypointbuilder import PydcsWaypointBuilder | ||
|
||
|
||
class AntiShipIngressBuilder(PydcsWaypointBuilder): | ||
def add_tasks(self, waypoint: MovingPoint) -> None: | ||
# TODO: Add common "UnitGroupTarget" base type. | ||
group_names = [] | ||
target = self.package.target | ||
if isinstance(target, TheaterGroundObject): | ||
for group in target.groups: | ||
group_names.append(group.group_name) | ||
elif isinstance(target, MultiGroupTransport): | ||
group_names.append(target.name) | ||
elif isinstance(target, NavalControlPoint): | ||
carrier_name = target.get_carrier_group_name() | ||
if carrier_name: | ||
group_names.append(carrier_name) | ||
else: | ||
logging.error( | ||
"Unexpected target type for anti-ship mission: %s", | ||
target.__class__.__name__, | ||
) | ||
return | ||
|
||
for group_name in group_names: | ||
miz_group = self.mission.find_group(group_name) | ||
if miz_group is None: | ||
logging.error( | ||
"Could not find group for anti-ship mission %s", group_name | ||
) | ||
continue | ||
|
||
task = AttackGroup( | ||
miz_group.id, weapon_type=WeaponType.Auto, group_attack=True | ||
) | ||
waypoint.tasks.append(task) | ||
|
||
waypoint.tasks.append(OptFormation.trail_open()) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters