-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_tlasers.py
140 lines (125 loc) · 3.46 KB
/
parse_tlasers.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
from x3lib import *
class BulletObj(BaseObj):
TEMPLATE = (
"Model file",
"Picture ID",
"Rotation X",
"Rotation Y",
"Rotation Z",
"Subtype",
"Description",
"Shield Damage",
"Energy Used",
"Impact Sound",
"Lifetime",
"Speed",
"Flags",
"Color R",
"Color G",
"Color B",
"width",
"height",
"length",
"Trail Effect",
"Impact Effect",
"Launch Effect",
"Hull Damage",
"Engine Trail",
"Ambiend Sound",
"Sound Volume (max)",
"Sound Volume (min)",
"Launch Delay",
"Speed Reduce (percent)",
"Speed Reduce (duration)",
"Target Weapon Drain",
"Damage over Time (energy)",
"Damage over Time (duration)",
"Fragment Bullet Index",
"Number of Fragments",
"Charged Energy Amplifier",
"Charged Size Amplifier",
"OOS Shield Damage",
"OOS Hull Damage",
"Ammo TWareT Index",
"Relative Value",
"Price modifier 1",
"Price modifier 2",
"Size",
"Relative value (player)",
"Minimum Notoriety",
"Video ID",
"Skin Index",
"ID",
)
class LaserObj(BaseObj):
TEMPLATE = (
"Model file",
"Picture ID",
"Rotation X",
"Rotation Y",
"Rotation Z",
"Subtype",
"Description",
"Rate of fire",
"Sound",
"Projectile",
"Energy",
"Charge rate",
"Icon",
"Volume",
"Relative Value",
"Price modifier 1",
"Price modifier 2",
"Size",
"Relative value (player)",
"Minimum Notoriety",
"Video ID",
"Skin Index",
"ID",
)
if __name__ == '__main__':
print "Getting bullets"
lines=open('ap/addon/types/tbullets.pck').readlines()[3:]
bullets = []
for line in lines:
data = line.strip().split(';')
if len(data) < 10:
continue
bullets.append(BulletObj(data))
print "Getting lasers"
lines=open('ap/addon/types/tlaser.pck').readlines()[2:]
lasers = []
for line in lines:
data = line.strip().split(';')
if len(data) < 10:
continue
lasers.append(LaserObj(data))
print "Getting pages"
pages = Pages()
import pymongo
mongo=pymongo.MongoClient()
db=mongo.x3
db.bullets.drop()
for id, o in enumerate(bullets):
o.data['_id']=o.data['line']=id
db.bullets.save(o.data)
page_id = 17
db.lasers.drop()
for id, o in enumerate(lasers):
o.data['_id']=o.data['line']=id
t_id=o.data['description']
o.data['laser_name'] = pages.get_page(page_id, t_id)
o.data['laser_desc'] = pages.get_page(page_id, t_id+1)
o.data['bullet']=bullet=bullets[o.data['projectile']].data
fire_rate = 1000.0/o.data['rate_of_fire']
speed = bullet['speed']/500.0
o.data['info'] = dict(
fire_rate=round(fire_rate, 1),
speed=round(speed, 0),
range=round(speed * bullet['lifetime'] / 1000.0, 0),
dps_hull=round(bullet['hull_damage']*fire_rate, 0),
dps_shields=round(bullet['shield_damage']*fire_rate, 0),
eps=round(bullet['energy_used']*fire_rate, 0),
flags=get_bullet_flags(bullet['flags'])
)
db.lasers.save(o.data)