Plan more ANTI-SHIP against ship-groups with air-defences

This commit is contained in:
Raffson 2024-12-23 18:06:11 +01:00
parent dd7e4c908e
commit a06e9d0ec7
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 12 additions and 6 deletions

View File

@ -8,8 +8,4 @@ from game.htn import CompoundTask, Method
class AttackShips(CompoundTask[TheaterState]):
def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]:
for ship in state.enemy_ships:
# Ammo depots are targeted based on the needs of the front line by
# ReduceEnemyFrontLineCapacity. No reason to target them before that front
# line is active.
if ship.has_live_radar_sam:
yield [PlanAntiShip(ship)]
yield [PlanAntiShip(ship)]

View File

@ -7,12 +7,16 @@ from game.commander.missionproposals import EscortType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater.theatergroundobject import NavalGroundObject
from game.utils import meters
@dataclass
class PlanAntiShip(PackagePlanningTask[NavalGroundObject]):
def preconditions_met(self, state: TheaterState) -> bool:
if self.target not in state.threatening_air_defenses:
if (
self.target not in state.threatening_air_defenses
and not self.target.is_naval_control_point
):
return False
if not self.target_area_preconditions_met(state, ignore_iads=True):
return False
@ -24,5 +28,11 @@ class PlanAntiShip(PackagePlanningTask[NavalGroundObject]):
def propose_flights(self) -> None:
size = self.get_flight_size()
if self.target.max_detection_range() > meters(0):
size = 4 # attempt to saturate ship's air-defences
self.propose_flight(FlightType.ANTISHIP, size)
self.propose_flight(FlightType.ESCORT, 2, EscortType.AirToAir)
self.propose_flight(FlightType.ANTISHIP, size)
self.propose_flight(FlightType.ESCORT, 2, EscortType.AirToAir)
if self.target.max_detection_range() > meters(0):
self.propose_flight(FlightType.SEAD, 2, EscortType.Sead)