Fixed errors in loadouts scripts

This commit is contained in:
Pax1601
2023-11-12 18:43:49 +01:00
parent a15b7620eb
commit a28584b08b
7 changed files with 36883 additions and 36401 deletions

View File

@@ -11,7 +11,7 @@
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"args": ["groundunit"]
"args": ["aircraft"]
}
]
}

View File

@@ -12,6 +12,40 @@ from dcs.weapons_data import Weapons
from dcs.planes import *
from dcs.helicopters import *
clsid_conversion = {
'ExtFuelTankID' : "{EFT_230GAL}" ,
'InternalFuelTank100' : "{IAFS_ComboPak_100}" ,
'NURSLauncherID_MK151' : "M261_MK151" ,
'NURSLauncherID_M229' : "{M261_M229}" ,
'NURSLauncherID_M257' : "{M261_M257}" ,
'NURSLauncherID_M274' : "{M261_M274}" ,
'NURSLauncherID_M282' : "{M261_M282}" ,
'NURSLauncherID_M433' : "{M261_M151_M433}" ,
'NURSLauncherID_M151_M274_OUTBOARD' : "{M261_OUTBOARD_AB_M151_E_M274}" ,
'NURSLauncherID_M151_M257_OUTBOARD' : "{M261_OUTBOARD_AB_M151_E_M257}" ,
'NURSLauncherID_M274_M151_INBOARD' : "{M261_INBOARD_DE_M151_C_M274}" ,
'NURSLauncherID_M257_M151_INBOARD' : "{M261_INBOARD_DE_M151_C_M257}" ,
'HellfireLauncherID_AGM114K_0' : "{M299_EMPTY}" ,
'HellfireLauncherID_AGM114K_4' : "{88D18A5E-99C8-4B04-B40B-1C02F2018B6E}" ,
'HellfireLauncherID_AGM114K_3_L' : "{M299_3xAGM_114K_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114K_3_R' : "{M299_3xAGM_114K_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114K_2' : "{M299_2xAGM_114K}" ,
'HellfireLauncherID_AGM114K_1_L' : "{M299_1xAGM_114K_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114K_1_R' : "{M299_1xAGM_114K_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114L_4' : "{M299_4xAGM_114L}" ,
'HellfireLauncherID_AGM114L_3_L' : "{M299_3xAGM_114L_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114L_3_R' : "{M299_3xAGM_114L_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114L_2' : "{M299_2xAGM_114L}" ,
'HellfireLauncherID_AGM114L_1_L' : "{M299_1xAGM_114L_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114L_1_R' : "{M299_1xAGM_114L_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114_1K3L_L' : "{M299_1xAGM_114K_3xAGM_114L_PRT}" ,
'HellfireLauncherID_AGM114_1K3L_R' : "{M299_1xAGM_114K_3xAGM_114L_STRBRD}" ,
'HellfireLauncherID_AGM114_2K2L' : "{M299_2xAGM_114K_2xAGM_114L}" ,
'HellfireLauncherID_AGM114_3K1L_R' : "{M299_3xAGM_114K_1xAGM_114L_STRBRD}" ,
'HellfireLauncherID_AGM114_3K1L_L' : "{M299_3xAGM_114K_1xAGM_114L_PRT}" ,
}
def rename_task(task_name):
task_map = {
"AFAC": "FAC-A",
@@ -20,13 +54,35 @@ def rename_task(task_name):
"Intercept": "CAP",
"Pinpoint Strike": "Strike",
"Refueling": "Tanker",
"Nothing": "No task"
"Nothing": "No task",
}
if task_name in task_map:
return task_map[task_name]
else:
return task_name
def convert_role(role):
other_roles = {
"tAntiShip": "AntishipStrike",
"tGndAttack": "GroundAttack",
"tAFAC": "AFAC",
"tRecon": "Reconnaissance",
"tRwyAttack": "RunwayAttack",
"tCAP": "CAP",
"tCAS": "CAS",
"tSEAD": "SEAD",
"tPinpntStrike": "PinpointStike",
"tIntercept": "Intercept",
"tCAP": "CAP",
"tFighterSweep": "FighterSweep",
"tEscort": "CAP"
}
if role in other_roles:
return other_roles[role]
else:
return role
# Known id mismatches (because reasons, ask ED)
mismatched_ids = {
@@ -42,6 +98,9 @@ def find_weapon_name(clsid):
if getattr(Weapons, weapon_id)["clsid"] == clsid:
return getattr(Weapons, weapon_id)["name"]
if clsid in clsid_conversion:
return clsid_conversion[clsid]
# The database file on which to operate is the first standard argument of the call
if len(sys.argv) > 1:
if (sys.argv[1] == "aircraft"):
@@ -105,6 +164,8 @@ if len(sys.argv) > 1:
for payload_idx in unit_payloads[unit_name][payload_name]:
payload_clsid = unit_payloads[unit_name][payload_name][payload_idx]["CLSID"]
weapon_name = find_weapon_name(payload_clsid)
if weapon_name is None:
weapon_name = payload_clsid
if weapon_name in payload_weapons:
payload_weapons[weapon_name] += 1
else:
@@ -121,7 +182,7 @@ if len(sys.argv) > 1:
else:
for name, obj in inspect.getmembers(task):
if inspect.isclass(obj) and issubclass(obj, task.MainTask):
if (name == role):
if (name == convert_role(role)):
payload_roles.append(rename_task(obj.name))
# Create the loadout structure and append it to the table

View File

@@ -8,6 +8,45 @@ sys.path.append("..\..\..\dcs-master\dcs-master")
SEARCH_FOLDER = "D:\\Eagle Dynamics\\DCS World OpenBeta"
clsid_conversion = {
'ExtFuelTankID' : "{EFT_230GAL}" ,
'InternalFuelTank100' : "{IAFS_ComboPak_100}" ,
'NURSLauncherID_MK151' : "M261_MK151" ,
'NURSLauncherID_M229' : "{M261_M229}" ,
'NURSLauncherID_M257' : "{M261_M257}" ,
'NURSLauncherID_M274' : "{M261_M274}" ,
'NURSLauncherID_M282' : "{M261_M282}" ,
'NURSLauncherID_M433' : "{M261_M151_M433}" ,
'NURSLauncherID_M151_M274_OUTBOARD' : "{M261_OUTBOARD_AB_M151_E_M274}" ,
'NURSLauncherID_M151_M257_OUTBOARD' : "{M261_OUTBOARD_AB_M151_E_M257}" ,
'NURSLauncherID_M274_M151_INBOARD' : "{M261_INBOARD_DE_M151_C_M274}" ,
'NURSLauncherID_M257_M151_INBOARD' : "{M261_INBOARD_DE_M151_C_M257}" ,
'HellfireLauncherID_AGM114K_0' : "{M299_EMPTY}" ,
'HellfireLauncherID_AGM114K_4' : "{88D18A5E-99C8-4B04-B40B-1C02F2018B6E}" ,
'HellfireLauncherID_AGM114K_3_L' : "{M299_3xAGM_114K_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114K_3_R' : "{M299_3xAGM_114K_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114K_2' : "{M299_2xAGM_114K}" ,
'HellfireLauncherID_AGM114K_1_L' : "{M299_1xAGM_114K_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114K_1_R' : "{M299_1xAGM_114K_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114L_4' : "{M299_4xAGM_114L}" ,
'HellfireLauncherID_AGM114L_3_L' : "{M299_3xAGM_114L_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114L_3_R' : "{M299_3xAGM_114L_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114L_2' : "{M299_2xAGM_114L}" ,
'HellfireLauncherID_AGM114L_1_L' : "{M299_1xAGM_114L_OUTBOARD_PORT}" ,
'HellfireLauncherID_AGM114L_1_R' : "{M299_1xAGM_114L_OUTBOARD_STARBOARD}" ,
'HellfireLauncherID_AGM114_1K3L_L' : "{M299_1xAGM_114K_3xAGM_114L_PRT}" ,
'HellfireLauncherID_AGM114_1K3L_R' : "{M299_1xAGM_114K_3xAGM_114L_STRBRD}" ,
'HellfireLauncherID_AGM114_2K2L' : "{M299_2xAGM_114K_2xAGM_114L}" ,
'HellfireLauncherID_AGM114_3K1L_R' : "{M299_3xAGM_114K_1xAGM_114L_STRBRD}" ,
'HellfireLauncherID_AGM114_3K1L_L' : "{M299_3xAGM_114K_1xAGM_114L_PRT}" ,
}
def convert_clsid(clsid):
if clsid in clsid_conversion:
return clsid_conversion[clsid]
else:
return clsid
def dump_lua(data):
if type(data) is str:
return f'"{data}"'
@@ -78,14 +117,14 @@ for filename in filenames:
"pylon_8A": 10
}
if type(payload['pylons']) == dict:
payloads[tmp['unitType']][payload['name']] = {pylonConversion[payload['pylons'][key]['num']]: {"CLSID" : payload['pylons'][key]['CLSID']} for key in payload['pylons']}
payloads[tmp['unitType']][payload['name']] = {pylonConversion[payload['pylons'][key]['num']]: {"CLSID" : convert_clsid(payload['pylons'][key]['CLSID'])} for key in payload['pylons']}
else:
payloads[tmp['unitType']][payload['name']] = {pylonConversion[payload['pylons'][key]['num']]: {"CLSID" : payload['pylons'][key]['CLSID']} for key in range(len(payload['pylons']))}
payloads[tmp['unitType']][payload['name']] = {pylonConversion[payload['pylons'][key]['num']]: {"CLSID" : convert_clsid(payload['pylons'][key]['CLSID'])} for key in range(len(payload['pylons']))}
else:
if type(payload['pylons']) == dict:
payloads[tmp['unitType']][payload['name']] = {payload['pylons'][key]['num']: {"CLSID" : payload['pylons'][key]['CLSID']} for key in payload['pylons']}
payloads[tmp['unitType']][payload['name']] = {payload['pylons'][key]['num']: {"CLSID" : convert_clsid(payload['pylons'][key]['CLSID'])} for key in payload['pylons']}
else:
payloads[tmp['unitType']][payload['name']] = {payload['pylons'][key]['num']: {"CLSID" : payload['pylons'][key]['CLSID']} for key in range(len(payload['pylons']))}
payloads[tmp['unitType']][payload['name']] = {payload['pylons'][key]['num']: {"CLSID" : convert_clsid(payload['pylons'][key]['CLSID'])} for key in range(len(payload['pylons']))}
except:
pass