Auto-swap ATFLIR to LITENING for land-based Hornets

Resolves #50
This commit is contained in:
Raffson 2022-12-25 16:29:49 +01:00
parent b0a0050725
commit 5c06e74659
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
4 changed files with 27 additions and 29 deletions

View File

@ -2,6 +2,7 @@
## Features/Improvements ## Features/Improvements
* **[Mission Generation]** Given a CAS flight was planned, delay ground force attack until first CAS flight is on station * **[Mission Generation]** Given a CAS flight was planned, delay ground force attack until first CAS flight is on station
* **[Mission Generation]** Add option to switch ATFLIR to LITENING automatically for ground based F-18C flights
## Fixes ## Fixes
* **[UI]** Removed deprecated options * **[UI]** Removed deprecated options

View File

@ -5,12 +5,12 @@ from datetime import datetime, timedelta
from typing import Any, List, Optional, TYPE_CHECKING 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 from dcs.planes import C_101CC, C_101EB, Su_33, FA_18C_hornet
from .flightroster import FlightRoster from .flightroster import FlightRoster
from .flightstate import FlightState, Navigating, Uninitialized from .flightstate import FlightState, Navigating, Uninitialized
from .flightstate.killed import Killed from .flightstate.killed import Killed
from .loadouts import Loadout from .loadouts import Loadout, Weapon
from ..sidc import ( from ..sidc import (
Entity, Entity,
SidcDescribable, SidcDescribable,
@ -32,6 +32,8 @@ if TYPE_CHECKING:
from .package import Package from .package import Package
from .starttype import StartType from .starttype import StartType
F18_TGP_PYLON: int = 4
class Flight(SidcDescribable): class Flight(SidcDescribable):
def __init__( def __init__(
@ -87,6 +89,15 @@ class Flight(SidcDescribable):
self._flight_plan_builder = FlightPlanBuilderTypes.for_flight(self)(self) self._flight_plan_builder = FlightPlanBuilderTypes.for_flight(self)(self)
is_f18 = self.squadron.aircraft.dcs_unit_type.id == FA_18C_hornet.id
on_land = not self.squadron.location.is_fleet
if on_land and is_f18 and self.coalition.game.settings.atflir_autoswap:
self.loadout.pylons[F18_TGP_PYLON] = Weapon.with_clsid(
str(
FA_18C_hornet.Pylon4.AN_AAQ_28_LITENING___Targeting_Pod_[1]["clsid"]
)
)
@property @property
def flight_plan(self) -> FlightPlan[Any]: def flight_plan(self) -> FlightPlan[Any]:
return self._flight_plan_builder.get_or_build() return self._flight_plan_builder.get_or_build()

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import datetime import datetime
import logging import logging
from collections.abc import Iterable from collections.abc import Iterable
from typing import Iterator, Mapping, Optional, TYPE_CHECKING, Type, Dict from typing import Iterator, Optional, TYPE_CHECKING, Type, Dict
from dcs.unittype import FlyingType from dcs.unittype import FlyingType
@ -19,14 +19,14 @@ class Loadout:
def __init__( def __init__(
self, self,
name: str, name: str,
pylons: Mapping[int, Optional[Weapon]], pylons: Dict[int, Optional[Weapon]],
date: Optional[datetime.date], date: Optional[datetime.date],
is_custom: bool = False, is_custom: bool = False,
) -> None: ) -> None:
self.name = name self.name = name
# We clear unused pylon entries on initialization, but UI actions can still # We clear unused pylon entries on initialization, but UI actions can still
# cause a pylon to be emptied, so make the optional type explicit. # cause a pylon to be emptied, so make the optional type explicit.
self.pylons: Mapping[int, Optional[Weapon]] = { self.pylons: Dict[int, Optional[Weapon]] = {
k: v for k, v in pylons.items() if v is not None k: v for k, v in pylons.items() if v is not None
} }
self.date = date self.date = date

View File

@ -173,30 +173,6 @@ class Settings:
"extremely incomplete so does not affect all weapons." "extremely incomplete so does not affect all weapons."
), ),
) )
disable_legacy_aewc: bool = boolean_option(
"Spawn invulnerable, always-available AEW&C aircraft (deprecated)",
page=CAMPAIGN_MANAGEMENT_PAGE,
section=GENERAL_SECTION,
default=True,
invert=True,
detail=(
"If checked, an invulnerable friendly AEW&C aircraft that begins the "
"mission on station will be be spawned. This behavior will be removed in a "
"future release."
),
)
disable_legacy_tanker: bool = boolean_option(
"Spawn invulnerable, always-available tanker aircraft (deprecated)",
page=CAMPAIGN_MANAGEMENT_PAGE,
section=GENERAL_SECTION,
default=True,
invert=True,
detail=(
"If checked, an invulnerable friendly tanker aircraft that begins the "
"mission on station will be be spawned. This behavior will be removed in a "
"future release."
),
)
# Pilots and Squadrons # Pilots and Squadrons
ai_pilot_levelling: bool = boolean_option( ai_pilot_levelling: bool = boolean_option(
"Allow AI pilot leveling", "Allow AI pilot leveling",
@ -379,6 +355,16 @@ class Settings:
"option only allows the player to wait on the ground.</strong>" "option only allows the player to wait on the ground.</strong>"
), ),
) )
atflir_autoswap: bool = boolean_option(
"Auto-swap ATFLIR to LITENING",
MISSION_GENERATOR_PAGE,
GAMEPLAY_SECTION,
default=True,
detail=(
"Automatically swaps ATFLIR to LITENING pod for newly generated land-based F-18 flights "
"without having to change the payload. <u>Takes effect after current turn!</u>"
),
)
default_start_type: StartType = choices_option( default_start_type: StartType = choices_option(
"Default start type for AI aircraft", "Default start type for AI aircraft",
page=MISSION_GENERATOR_PAGE, page=MISSION_GENERATOR_PAGE,