Tons Of Guns dependencies[message #358141]
|
Sun, 29 September 2019 13:28
|
|
DSmidgy |
|
Messages:22
Registered:July 2007 |
|
|
I wrote a Python script, that finds all Tons Of Guns attachments, linked to normal guns.
This way you can find all the scopes, that you can remove Tons Of Guns flag from.
I was trying to upload it, but I see that file attachments are disabled.
So here is the code (for version 2.7):
import xml.etree.ElementTree as ET
# Config
ja2path = "C:\\GOG Games\\Jagged Alliance 2\\Data-1.13\\TableData\\Items"
# Read all relevant data
itemsXml = ET.parse(ja2path + "\\Items.xml")
items = {}
for item in itemsXml.getroot():
itemId = -1
itemToG = False
itemName = ''
for node in item:
if node.tag == 'uiIndex':
itemId = int(node.text)
if node.tag == 'BigGunList': # TonsOfGuns
itemToG = bool(node.text)
if node.tag == 'szLongItemName':
itemName = node.text
items[itemId] = [itemToG, itemName]
weaponsXml = ET.parse(ja2path + "\\Weapons.xml")
weapons = {}
for weapon in weaponsXml.getroot():
itemId = -1
for node in weapon:
if node.tag == 'uiIndex':
itemId = int(node.text)
weapons[itemId] = None
attachmentsXml = ET.parse(ja2path + "\\Attachments.xml")
attachments = {}
for attachment in attachmentsXml.getroot():
itemId = -1
attachmentId = -1
for node in attachment:
if node.tag == 'itemIndex':
itemId = node.text
if node.tag == 'attachmentIndex':
attachmentId = node.text
attachments[itemId + ':' + attachmentId] = None
# Normal weapons
weaponsN = {}
for weaponId, weapondValue in weapons.items():
if items[weaponId][0] == False:
weaponsN[weaponId] = items[weaponId][1]
# Attachments with ToG flag on normal weapons
attachemntsToG = {}
for itemAttachmentId, attachmentValue in attachments.items():
splitIds = itemAttachmentId.split(':')
itemId = int(splitIds[0])
attachmentId = int(splitIds[1])
if itemId in weaponsN and items[attachmentId][0] == True:
attachemntsToG[attachmentId] = items[attachmentId][1]
# ToG attachments on normal weapons
for itemAttachmentId, attachmentName in sorted(attachemntsToG.items()):
print(itemAttachmentId, attachmentName)
[Updated on: Sun, 29 September 2019 13:29] Report message to a moderator
|
Private 1st Class
|
|
|