mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Perform coalition-wide mission planning.
Mission planning on a per-control point basis lacked the context it needed to make good decisions, and the ability to make larger missions that pulled aircraft from multiple airfields. The per-CP planners have been replaced in favor of a global planner per coalition. The planner generates a list of potential missions in order of priority and then allocates aircraft to the proposed flights until no missions remain. Mission planning behavior has changed: * CAP flights will now only be generated for airfields within a predefined threat range of an enemy airfield. * CAS, SEAD, and strike missions get escorts. Strike missions get a SEAD flight. * CAS, SEAD, and strike missions will not be planned unless they have an escort available. * Missions may originate from multiple airfields. There's more to do: * The range limitations imposed on the mission planner should take aircraft range limitations into account. * Air superiority aircraft like the F-15 should be preferred for CAP over multi-role aircraft like the F/A-18 since otherwise we run the risk of running out of ground attack capable aircraft even though there are still unused aircraft. * Mission priorities may need tuning. * Target areas could be analyzed for potential threats, allowing escort flights to be optional or omitted if there is no threat to defend against. For example, late game a SEAD flight for a strike mission probably is not necessary. * SAM threat should be judged by how close the extent of the SAM's range is to friendly locations, not the distance to the site itself. An SA-10 30 nm away is more threatening than an SA-6 25 nm away. * Much of the planning behavior should be factored out into the coalition's doctrine. But as-is this is an improvement over the existing behavior, so those things can be follow ups. The potential regression in behavior here is that we're no longer planning multiple cycles of missions. Each objective will get one CAP. I think this fits better with the turn cycle of the game, as a CAP flight should be able to remain on station for the duration of the turn (especially with refueling). Note that this does break save compatibility as the old planner was a part of the game object, and since that class is now gone it can't be unpickled.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
from PySide2.QtCore import Signal
|
||||
from PySide2.QtWidgets import QGroupBox, QHBoxLayout, QComboBox, QLabel
|
||||
|
||||
from game import Game
|
||||
|
||||
|
||||
class QChooseAirbase(QGroupBox):
|
||||
|
||||
selected_airbase_changed = Signal(str)
|
||||
|
||||
def __init__(self, game:Game, title=""):
|
||||
super(QChooseAirbase, self).__init__(title)
|
||||
self.game = game
|
||||
|
||||
self.layout = QHBoxLayout()
|
||||
self.depart_from_label = QLabel("Airbase : ")
|
||||
self.depart_from = QComboBox()
|
||||
|
||||
for i, cp in enumerate([b for b in self.game.theater.controlpoints if b.captured and b.id in self.game.planners]):
|
||||
self.depart_from.addItem(str(cp.name), cp)
|
||||
self.depart_from.setCurrentIndex(0)
|
||||
self.depart_from.currentTextChanged.connect(self._on_airbase_selected)
|
||||
self.layout.addWidget(self.depart_from_label)
|
||||
self.layout.addWidget(self.depart_from)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def _on_airbase_selected(self):
|
||||
selected = self.depart_from.currentText()
|
||||
self.selected_airbase_changed.emit(selected)
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from dcs.planes import PlaneType
|
||||
|
||||
from game import Game
|
||||
from gen.ato import Package
|
||||
from gen.flights.ai_flight_planner import FlightPlanner
|
||||
from gen.flights.flightplan import FlightPlanBuilder
|
||||
from gen.flights.flight import Flight, FlightType
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.widgets.QFlightSizeSpinner import QFlightSizeSpinner
|
||||
@@ -31,6 +31,8 @@ class QFlightCreator(QDialog):
|
||||
self.game = game
|
||||
self.package = package
|
||||
|
||||
self.planner = FlightPlanBuilder(self.game, is_player=True)
|
||||
|
||||
self.setWindowTitle("Create flight")
|
||||
self.setWindowIcon(EVENT_ICONS["strike"])
|
||||
|
||||
@@ -93,7 +95,7 @@ class QFlightCreator(QDialog):
|
||||
size = self.flight_size_spinner.value()
|
||||
|
||||
flight = Flight(aircraft, size, origin, task)
|
||||
self.populate_flight_plan(flight, task)
|
||||
self.planner.populate_flight_plan(flight, self.package.target)
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
self.created.emit(flight)
|
||||
@@ -102,77 +104,3 @@ class QFlightCreator(QDialog):
|
||||
def on_aircraft_changed(self, index: int) -> None:
|
||||
new_aircraft = self.aircraft_selector.itemData(index)
|
||||
self.airfield_selector.change_aircraft(new_aircraft)
|
||||
|
||||
@property
|
||||
def planner(self) -> FlightPlanner:
|
||||
return self.game.planners[self.airfield_selector.currentData().id]
|
||||
|
||||
def populate_flight_plan(self, flight: Flight, task: FlightType) -> None:
|
||||
# TODO: Flesh out mission types.
|
||||
if task == FlightType.ANTISHIP:
|
||||
logging.error("Anti-ship flight plan generation not implemented")
|
||||
elif task == FlightType.BAI:
|
||||
logging.error("BAI flight plan generation not implemented")
|
||||
elif task == FlightType.BARCAP:
|
||||
self.generate_cap(flight)
|
||||
elif task == FlightType.CAP:
|
||||
self.generate_cap(flight)
|
||||
elif task == FlightType.CAS:
|
||||
self.generate_cas(flight)
|
||||
elif task == FlightType.DEAD:
|
||||
self.generate_sead(flight)
|
||||
elif task == FlightType.ELINT:
|
||||
logging.error("ELINT flight plan generation not implemented")
|
||||
elif task == FlightType.EVAC:
|
||||
logging.error("Evac flight plan generation not implemented")
|
||||
elif task == FlightType.EWAR:
|
||||
logging.error("EWar flight plan generation not implemented")
|
||||
elif task == FlightType.INTERCEPTION:
|
||||
logging.error("Intercept flight plan generation not implemented")
|
||||
elif task == FlightType.LOGISTICS:
|
||||
logging.error("Logistics flight plan generation not implemented")
|
||||
elif task == FlightType.RECON:
|
||||
logging.error("Recon flight plan generation not implemented")
|
||||
elif task == FlightType.SEAD:
|
||||
self.generate_sead(flight)
|
||||
elif task == FlightType.STRIKE:
|
||||
self.generate_strike(flight)
|
||||
elif task == FlightType.TARCAP:
|
||||
self.generate_cap(flight)
|
||||
elif task == FlightType.TROOP_TRANSPORT:
|
||||
logging.error(
|
||||
"Troop transport flight plan generation not implemented"
|
||||
)
|
||||
|
||||
def generate_cas(self, flight: Flight) -> None:
|
||||
if not isinstance(self.package.target, FrontLine):
|
||||
logging.error(
|
||||
"Could not create flight plan: CAS missions only valid for "
|
||||
"front lines"
|
||||
)
|
||||
return
|
||||
self.planner.generate_cas(flight, self.package.target)
|
||||
|
||||
def generate_cap(self, flight: Flight) -> None:
|
||||
if isinstance(self.package.target, TheaterGroundObject):
|
||||
logging.error(
|
||||
"Could not create flight plan: CAP missions for strike targets "
|
||||
"not implemented"
|
||||
)
|
||||
return
|
||||
if isinstance(self.package.target, FrontLine):
|
||||
self.planner.generate_frontline_cap(flight, self.package.target)
|
||||
else:
|
||||
self.planner.generate_barcap(flight, self.package.target)
|
||||
|
||||
def generate_sead(self, flight: Flight) -> None:
|
||||
self.planner.generate_sead(flight, self.package.target)
|
||||
|
||||
def generate_strike(self, flight: Flight) -> None:
|
||||
if not isinstance(self.package.target, TheaterGroundObject):
|
||||
logging.error(
|
||||
"Could not create flight plan: strike missions for capture "
|
||||
"points not implemented"
|
||||
)
|
||||
return
|
||||
self.planner.generate_strike(flight, self.package.target)
|
||||
|
||||
@@ -3,6 +3,7 @@ from PySide2.QtWidgets import QDialog, QPushButton
|
||||
|
||||
from game import Game
|
||||
from gen.flights.flight import Flight
|
||||
from gen.flights.flightplan import FlightPlanBuilder
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointInfoBox import QFlightWaypointInfoBox
|
||||
|
||||
@@ -19,7 +20,7 @@ class QAbstractMissionGenerator(QDialog):
|
||||
self.setWindowTitle(title)
|
||||
self.setWindowIcon(EVENT_ICONS["strike"])
|
||||
self.flight_waypoint_list = flight_waypoint_list
|
||||
self.planner = self.game.planners[self.flight.from_cp.id]
|
||||
self.planner = FlightPlanBuilder(self.game, is_player=True)
|
||||
|
||||
self.selected_waypoints = []
|
||||
self.wpt_info = QFlightWaypointInfoBox()
|
||||
|
||||
@@ -3,6 +3,7 @@ from PySide2.QtWidgets import QFrame, QGridLayout, QLabel, QPushButton, QVBoxLay
|
||||
|
||||
from game import Game
|
||||
from gen.flights.flight import Flight
|
||||
from gen.flights.flightplan import FlightPlanBuilder
|
||||
from qt_ui.windows.mission.flight.generator.QCAPMissionGenerator import QCAPMissionGenerator
|
||||
from qt_ui.windows.mission.flight.generator.QCASMissionGenerator import QCASMissionGenerator
|
||||
from qt_ui.windows.mission.flight.generator.QSEADMissionGenerator import QSEADMissionGenerator
|
||||
@@ -19,7 +20,7 @@ class QFlightWaypointTab(QFrame):
|
||||
super(QFlightWaypointTab, self).__init__()
|
||||
self.flight = flight
|
||||
self.game = game
|
||||
self.planner = self.game.planners[self.flight.from_cp.id]
|
||||
self.planner = FlightPlanBuilder(self.game, is_player=True)
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
|
||||
Reference in New Issue
Block a user