Don't scrub missions with unplannable escort types

The check for whether or not the escort is actually needed happens later, and thus the mission can still be scrubbed if it's too dangerous. However, missions should not be scrubbed when a particular escort type is unplannable, yet not needed. Only if the primary flight type is not plannable should the mission immediately be scrubbed
This commit is contained in:
Raffson 2023-09-23 16:51:26 +02:00
parent 167d048232
commit 389037e6bf
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
7 changed files with 19 additions and 14 deletions

View File

@ -9,6 +9,7 @@ from game.theater import MissionTarget
class EscortType(Enum):
AirToAir = auto()
Sead = auto()
Refuel = auto()
@dataclass(frozen=True)

View File

@ -154,17 +154,17 @@ class PackageFulfiller:
missing_types: Set[FlightType] = set()
escorts = []
for proposed_flight in mission.flights:
if proposed_flight.escort_type is not None:
# Escorts are planned after the primary elements of the package.
# If the package does not need escorts they may be pruned.
escorts.append(proposed_flight)
continue
if not self.air_wing_can_plan(proposed_flight.task):
# This air wing can never plan this mission type because they do not
# have compatible aircraft or squadrons. Skip fulfillment so that we
# don't place the purchase request.
missing_types.add(proposed_flight.task)
break
if proposed_flight.escort_type is not None:
# Escorts are planned after the primary elements of the package.
# If the package does not need escorts they may be pruned.
escorts.append(proposed_flight)
continue
with tracer.trace("Flight planning"):
self.plan_flight(
mission,

View File

@ -1,9 +1,9 @@
from __future__ import annotations
from dataclasses import dataclass
from random import randint
from game.ato.flighttype import FlightType
from game.commander.missionproposals import EscortType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.transfers import CargoShip
@ -24,4 +24,4 @@ class PlanAntiShipping(PackagePlanningTask[CargoShip]):
def propose_flights(self) -> None:
size = self.get_flight_size()
self.propose_flight(FlightType.ANTISHIP, size)
self.propose_common_escorts()
self.propose_flight(FlightType.ESCORT, 2, EscortType.AirToAir)

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from game.ato.flighttype import FlightType
from game.commander.missionproposals import EscortType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater import FrontLine
@ -31,5 +32,5 @@ class PlanCas(PackagePlanningTask[FrontLine]):
def propose_flights(self) -> None:
size = self.get_flight_size()
self.propose_flight(FlightType.CAS, size)
self.propose_flight(FlightType.TARCAP, 2)
self.propose_flight(FlightType.SEAD_SWEEP, 2)
self.propose_flight(FlightType.TARCAP, 2, EscortType.AirToAir)
self.propose_flight(FlightType.SEAD_SWEEP, 2, EscortType.Sead)

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from game.ato.flighttype import FlightType
from game.commander.missionproposals import EscortType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater.theatergroundobject import IadsGroundObject
@ -39,8 +40,8 @@ class PlanDead(PackagePlanningTask[IadsGroundObject]):
# also threatened by SAMs. We don't want to include a SEAD escort if the
# package is *only* threatened by the target though. Could be improved, but
# needs a decent refactor to the escort planning to do so.
if self.target.has_live_radar_sam:
self.propose_flight(FlightType.SEAD, 2)
self.propose_common_escorts()
if self.target.has_live_radar_sam:
self.propose_flight(FlightType.SEAD, 2, EscortType.Sead)
if self.target.control_point.coalition.game.settings.autoplan_tankers_for_dead:
self.propose_flight(FlightType.REFUELING, 1)
self.propose_flight(FlightType.REFUELING, 1, EscortType.Refuel)

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from game.ato.flighttype import FlightType
from game.commander.missionproposals import EscortType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater import ControlPoint
@ -30,4 +31,4 @@ class PlanOcaStrike(PackagePlanningTask[ControlPoint]):
self.propose_flight(FlightType.OCA_AIRCRAFT, 2)
self.propose_common_escorts()
if self.target.coalition.game.settings.autoplan_tankers_for_oca:
self.propose_flight(FlightType.REFUELING, 1)
self.propose_flight(FlightType.REFUELING, 1, EscortType.Refuel)

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from game.ato.flighttype import FlightType
from game.commander.missionproposals import EscortType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater.theatergroundobject import TheaterGroundObject
@ -25,4 +26,4 @@ class PlanStrike(PackagePlanningTask[TheaterGroundObject]):
self.propose_flight(FlightType.STRIKE, min(4, (tgt_count // 2) + tgt_count % 2))
self.propose_common_escorts()
if self.target.coalition.game.settings.autoplan_tankers_for_strike:
self.propose_flight(FlightType.REFUELING, 1)
self.propose_flight(FlightType.REFUELING, 1, EscortType.Refuel)