Allow harriers to operate from FOBs/FARPs

Resolve #109
This commit is contained in:
Raffson 2023-05-28 21:05:17 +02:00
parent b8cb1a6273
commit 7582040d41
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
5 changed files with 37 additions and 10 deletions

View File

@ -14,11 +14,13 @@
* **[Modding]** Support for SW mod v2.55 * **[Modding]** Support for SW mod v2.55
* **[Modding]** Support for Spanish & Australian Naval Assets v3.2.0 by desdemicabina * **[Modding]** Support for Spanish & Australian Naval Assets v3.2.0 by desdemicabina
* **[Modding]** Support for Iron Dome v1.2 by IDF Mods Project * **[Modding]** Support for Iron Dome v1.2 by IDF Mods Project
* **[NewGameWizard]** Re-organized generator options & show the regular settings menu instead of the limited "Difficulty & Automation" page. * **[New Game Wizard]** Re-organized generator options & show the regular settings menu instead of the limited "Difficulty & Automation" page.
* **[Campaign Management]** Ability to operate harriers from FOBs/FARPs for <ins>__human pilots only__</ins>. Please note that the autoplanner won't generate flights for harriers at FOBs/FARPs, which means you need to plan your missions manually.
## Fixes ## Fixes
* **[New Game Wizard]** Settings would not persist when going back to a previous page. * **[New Game Wizard]** Settings would not persist when going back to a previous page (obsolete due to overhaul).
* **[Mission Generation]** Unused aircraft are no longer claimed, fixing a bug where these aircraft would no longer be available after aborting the mission. * **[Mission Generation]** Unused aircraft are no longer claimed, fixing a bug where these aircraft would no longer be available after aborting the mission.
* **[Mission Generation]** Fixed (potential) bug in helipad assignments at FOBs/FARPs.
# Retribution v1.1.1 (hotfix) # Retribution v1.1.1 (hotfix)

View File

@ -7,6 +7,7 @@ from typing import Any, List, Optional, TYPE_CHECKING
from dcs import Point from dcs import Point
from dcs.planes import C_101CC, C_101EB, Su_33, FA_18C_hornet from dcs.planes import C_101CC, C_101EB, Su_33, FA_18C_hornet
from game.dcs.aircrafttype import AircraftType
from pydcs_extensions.hercules.hercules import Hercules from pydcs_extensions.hercules.hercules import Hercules
from .flightroster import FlightRoster from .flightroster import FlightRoster
from .flightstate import FlightState, Navigating, Uninitialized from .flightstate import FlightState, Navigating, Uninitialized
@ -23,7 +24,6 @@ from ..sidc import (
Status, Status,
SymbolSet, SymbolSet,
) )
from game.dcs.aircrafttype import AircraftType
if TYPE_CHECKING: if TYPE_CHECKING:
from game.sim.gameupdateevents import GameUpdateEvents from game.sim.gameupdateevents import GameUpdateEvents
@ -228,6 +228,8 @@ class Flight(SidcDescribable, RadioFrequencyContainer, TacanContainer):
self.fuel = unit_type.fuel_max * 0.5 self.fuel = unit_type.fuel_max * 0.5
elif unit_type == Hercules: elif unit_type == Hercules:
self.fuel = unit_type.fuel_max * 0.75 self.fuel = unit_type.fuel_max * 0.75
elif self.departure.cptype.name in ["FARP", "FOB"] and not self.is_helo:
self.fuel = unit_type.fuel_max * 0.75
def __repr__(self) -> str: def __repr__(self) -> str:
return self.__str__() return self.__str__()

View File

@ -7,6 +7,7 @@ from dcs.country import Country
from dcs.mapping import Vector2 from dcs.mapping import Vector2
from dcs.mission import StartType as DcsStartType from dcs.mission import StartType as DcsStartType
from dcs.planes import F_14A, Su_33 from dcs.planes import F_14A, Su_33
from dcs.point import PointAction
from dcs.ships import KUZNECOW from dcs.ships import KUZNECOW
from dcs.terrain import Airport, NoParkingSlotError from dcs.terrain import Airport, NoParkingSlotError
from dcs.unitgroup import FlyingGroup, ShipGroup, StaticGroup from dcs.unitgroup import FlyingGroup, ShipGroup, StaticGroup
@ -118,9 +119,16 @@ class FlightGroupSpawner:
) )
return self._generate_at_group(name, carrier_group) return self._generate_at_group(name, carrier_group)
elif isinstance(cp, Fob): elif isinstance(cp, Fob):
if not self.flight.unit_type.helicopter: is_heli = self.flight.squadron.aircraft.helicopter
is_vtol = not is_heli and self.flight.squadron.aircraft.lha_capable
if not is_heli and not is_vtol:
raise RuntimeError( raise RuntimeError(
f"Cannot spawn fixed-wing aircraft at {cp} because it is a FOB" f"Cannot spawn non-VTOL aircraft at {cp} because it is a FOB"
)
pilot_count = len(self.flight.roster.pilots)
if is_vtol and self.flight.roster.player_count != pilot_count:
raise RuntimeError(
f"VTOL aircraft at {cp} must be piloted by humans exclusively."
) )
return self._generate_at_cp_helipad(name, cp) return self._generate_at_cp_helipad(name, cp)
elif isinstance(cp, Airfield): elif isinstance(cp, Airfield):
@ -252,13 +260,18 @@ class FlightGroupSpawner:
group = self._generate_at_group(name, helipad) group = self._generate_at_group(name, helipad)
group.points[0].type = "TakeOffGround"
group.points[0].action = PointAction.FromGroundArea
if self.start_type is StartType.WARM: if self.start_type is StartType.WARM:
group.points[0].type = "TakeOffParkingHot" group.points[0].type = "TakeOffGroundHot"
group.points[0].action = PointAction.FromGroundAreaHot
hpad = helipad.units[0] hpad = helipad.units[0]
for i in range(self.flight.count): for i in range(self.flight.count):
group.units[i].position = hpad.position pos = cp.helipads.pop(0)
group.units[i].position = pos
group.units[i].heading = hpad.heading group.units[i].heading = hpad.heading
group.units[i].parking_id = str(i + 1) cp.helipads.append(pos)
return group return group
def dcs_start_type(self) -> DcsStartType: def dcs_start_type(self) -> DcsStartType:

View File

@ -264,6 +264,14 @@ class Squadron:
def can_auto_assign_mission( def can_auto_assign_mission(
self, location: MissionTarget, task: FlightType, size: int, this_turn: bool self, location: MissionTarget, task: FlightType, size: int, this_turn: bool
) -> bool: ) -> bool:
if (
self.location.cptype.name in ["FOB", "FARP"]
and not self.aircraft.helicopter
):
# AI harriers can't handle FOBs/FARPs
# AI has a hard time taking off and will not land back at FOB/FARP
# thus, disable auto-planning
return False
if not self.can_auto_assign(task): if not self.can_auto_assign(task):
return False return False
if this_turn and not self.can_fulfill_flight(size): if this_turn and not self.can_fulfill_flight(size):

View File

@ -103,7 +103,7 @@ class ControlPointType(Enum):
AIRCRAFT_CARRIER_GROUP = 1 AIRCRAFT_CARRIER_GROUP = 1
#: A group with a Tarawa carrier (Helicopters & Harrier). #: A group with a Tarawa carrier (Helicopters & Harrier).
LHA_GROUP = 2 LHA_GROUP = 2
#: A FARP, with slots for helicopters #: A FARP, with slots for helicopters & harrier
FARP = 4 FARP = 4
#: A FOB (ground units only) #: A FOB (ground units only)
FOB = 5 FOB = 5
@ -1474,7 +1474,9 @@ class Fob(ControlPoint, RadioFrequencyContainer, CTLD):
# FOBs and FARPs are the same class, distinguished only by non-FARP FOBs having # FOBs and FARPs are the same class, distinguished only by non-FARP FOBs having
# zero parking. # zero parking.
# https://github.com/dcs-liberation/dcs_liberation/issues/2378 # https://github.com/dcs-liberation/dcs_liberation/issues/2378
return aircraft.helicopter and self.total_aircraft_parking > 0 return (
aircraft.helicopter or aircraft.lha_capable
) and self.total_aircraft_parking > 0
@property @property
def heading(self) -> Heading: def heading(self) -> Heading: