mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Make the default loadout code more resilient.
It can now cope with the payload overrides defined in the db.
This commit is contained in:
parent
f2e35c185b
commit
a654c8229a
29
game/db.py
29
game/db.py
@ -1024,23 +1024,24 @@ COMMON_OVERRIDE = {
|
||||
This is a list of mappings from the FlightType of a Flight to the type of payload defined in the
|
||||
resources/payloads/UNIT_TYPE.lua file. A Flight has no concept of a PyDCS task, so COMMON_OVERRIDE cannot be
|
||||
used here. This is used in the payload editor, for setting the default loadout of an object.
|
||||
The left element is the FlightType name, and the right element is what is used in the lua file.
|
||||
The left element is the FlightType name, and the right element is a tuple containing what is used in the lua file.
|
||||
Some aircraft differ from the standard loadout names, so those have been included here too.
|
||||
"""
|
||||
|
||||
EXPANDED_TASK_PAYLOAD_OVERRIDE = {
|
||||
"TARCAP": "CAP",
|
||||
"BARCAP": "CAP",
|
||||
"CAS": "CAS",
|
||||
"INTERCEPTION": "CAP",
|
||||
"STRIKE": "STRIKE",
|
||||
"ANTISHIP": "ANTISHIP",
|
||||
"SEAD": "SEAD",
|
||||
"DEAD": "SEAD",
|
||||
"ESCORT": "CAP",
|
||||
"BAI": "CAS",
|
||||
"SWEEP": "CAP",
|
||||
"OCA_RUNWAY": "STRIKE",
|
||||
"OCA_AIRCRAFT": "CAS"
|
||||
"TARCAP": ("CAP", "CAP HEAVY"),
|
||||
"BARCAP": ("CAP", "CAP HEAVY"),
|
||||
"CAS": ("CAS","CAS MAVERICK F"),
|
||||
"INTERCEPTION": ("CAP", "CAP HEAVY"),
|
||||
"STRIKE": ("STRIKE"),
|
||||
"ANTISHIP": ("ANTISHIP"),
|
||||
"SEAD": ("SEAD"),
|
||||
"DEAD": ("SEAD"),
|
||||
"ESCORT": ("CAP", "CAP HEAVY"),
|
||||
"BAI": ("CAS","CAS MAVERICK F"),
|
||||
"SWEEP": ("CAP", "CAP HEAVY"),
|
||||
"OCA_RUNWAY": ("STRIKE"),
|
||||
"OCA_AIRCRAFT": ("CAS","CAS MAVERICK F")
|
||||
}
|
||||
|
||||
PLANE_PAYLOAD_OVERRIDES: Dict[Type[PlaneType], Dict[Type[Task], str]] = {
|
||||
|
||||
@ -45,11 +45,16 @@ class QPylonEditor(QComboBox):
|
||||
|
||||
def default_loadout(self, pylon: Pylon) -> None:
|
||||
self.flight.unit_type.load_payloads()
|
||||
loadout = self.flight.unit_type.loadout_by_name(db.EXPANDED_TASK_PAYLOAD_OVERRIDE.get(self.flight.flight_type.name))
|
||||
pylon_default_weapon = None
|
||||
for i in loadout:
|
||||
if i[0] == self.pylon.number:
|
||||
pylon_default_weapon = i[1]["clsid"]
|
||||
# Iterate through each possible payload type for a given aircraft.
|
||||
# Some aircraft have custom loadouts that in aren't the standard set.
|
||||
for payload_override in db.EXPANDED_TASK_PAYLOAD_OVERRIDE.get(self.flight.flight_type.name):
|
||||
if loadout is None:
|
||||
loadout = self.flight.unit_type.loadout_by_name(payload_override)
|
||||
if loadout is not None:
|
||||
for i in loadout:
|
||||
if i[0] == self.pylon.number:
|
||||
pylon_default_weapon = i[1]["clsid"]
|
||||
if pylon_default_weapon is not None:
|
||||
self.setCurrentText(weapons_data.weapon_ids.get(pylon_default_weapon).get("name"))
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user