-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml_for_missiles.py
More file actions
30 lines (27 loc) · 2.82 KB
/
xml_for_missiles.py
File metadata and controls
30 lines (27 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import csv
from datetime import datetime
csv_file = 'VROMISSILES.csv'
# xml_file = ''
time = str(datetime.now())
csv_data = csv.DictReader(open(csv_file), fieldnames=['name', 'macro', 'tags', 'info', 'race', 'damage', 'reload', 'amount', 'barrel', 'dps', 'alpha', 'lifetime', 'thrust', 'speed', 'travel', 'firerange', 'guided', 'retarget', 'swarm', 'locktime', 'lockrange', 'hull', 'weapon', 'resiliense', 'mass', 'inertia', 'dforward', 'dhv', 'dman', 'explosioneffect', 'launcheffect', 'engine', 'component', 'price', 'cells', 'mcs', 'sc', 'prodtime', 'tname', 'tbasename', 'tdescription'])
row_n = 0
for row in csv_data:
if row_n == 0:
print(str(row_n) + 'not printing')
row_n += 1
else:
xml_file = row['macro']+'.xml'
tname = '{6699, ' + row['tname'] + '}'
tbasename = '{6699, ' + row['tbasename'] + '}'
tdescription = '{6699, ' + row['tdescription'] + '}'
xml_data = '<?xml version="1.0" encoding="utf-8"?>\n<macros>\n<macro name="%s" class="missile">\n<component ref="%s" />\n<properties>\n<identification name="%s" basename="%s" description="%s" />\n<ammunition value="1" />\n<missile amount="%s" barrelamount="%s" lifetime="%s" range="%s" swarm="%s" guided="%s" retarget="%s" icon="missile_dumbfire_mk1" tags="%s"/>\n<explosiondamage value="%s" />\n<reload time="%s" />\n<hull max="%s" />\n<effects>\n<explosion ref="%s" />\n<launch ref="%s" />\n</effects>\n<weapon system="%s" />\n<countermeasure resilience="%s" />\n<physics mass="%s">\n<inertia pitch="%s" yaw="%s" roll="%s" />\n<drag forward="%s" reverse="%s" horizontal="%s" vertical="%s" pitch="%s" yaw="%s" roll="%s" />\n</physics>' % (row['macro'], row['component'], tname, tbasename, tdescription, row['amount'], row['barrel'], row['lifetime'], row['firerange'], row['swarm'], row['guided'], row['retarget'], row['tags'], row['damage'], row['reload'], row['hull'], row['explosioneffect'], row['launcheffect'], row['weapon'], row['resiliense'], row['mass'], row['inertia'], row['inertia'], row['inertia'], row['dforward'], row['dhv'], row['dhv'], row['dhv'], row['dman'], row['dman'], row['dman'])
if row['locktime'] == '0':
xml_data = xml_data + '\n</properties>\n<connections>\n<connection ref = "con_engine01">\n<macro ref = "%s" connection = "ship"/>\n</connection>\n</connections>\n</macro>\n</macros>' % (row['engine'])
else:
xml_data = xml_data + '\n<lock time="%s" range="%s"/>\n</properties>\n<connections>\n<connection ref = "con_engine01">\n<macro ref = "%s" connection = "ship"/>\n</connection>\n </connections>\n</macro>\n</macros>' % (row['locktime'], row['lockrange'],row['engine'])
xml_data = xml_data + '\n<!--generated by SHUUL on ' + time + '-->'
# print(x)
F = open(xml_file, 'w')
F.write(xml_data)
F.close
row_n += 1