[d9e472]: infinity / formats / pro.py Maximize Restore History

Download this file

pro.py    343 lines (274 with data), 10.8 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
 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# -*-python-*-
# ie_shell.py - Simple shell for Infinity Engine-based game files
# Copyright (C) 2004-2008 by Jaroslav Benkovsky, <edheldil@users.sf.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from infinity import core
from infinity.format import Format, register_format
class PRO_Format (Format):
header_desc = (
{ 'key': 'signature',
'type': 'STR4',
'off': 0x0000,
'label': 'Signature' },
{ 'key': 'version',
'type': 'STR4',
'off':0x0004,
'label': 'Version'},
{ 'key': 'projectile_type',
'type': 'WORD',
'off': 0x0008,
'enum': { 2: 'single target', 3: 'area target' },
'label': 'Projectile type' },
{ 'key': 'speed',
'type': 'WORD',
'off': 0x000A,
'label': 'Speed' },
{ 'key': 'sparking_flag',
'type': 'WORD',
'off': 0x000C,
'mask': { 0x01: 'sparks', 0x02: 'flying projectile', 0x04: 'looping sound', 0x08: 'unknown', 0x10: 'ignore centre' },
'label': 'Sparking flag'},
{ 'key': 'unknown',
'type': 'WORD',
'off': 0x000E,
'label': 'Unknown'},
{ 'key': 'wavc',
'type': 'RESREF',
'off': 0x0010,
'label': 'WAVC resref'},
{ 'key': 'explosion_wavc',
'type': 'RESREF',
'off': 0x0018,
'label': 'Explosion WAVC resref'},
{ 'key': 'unknown_wavc',
'type': 'RESREF',
'off': 0x0020,
'label': 'Unknown/Unused? WAVC resref'},
{ 'key': 'spark_color',
'type': 'DWORD',
'off': 0x0028,
'label': 'Spark color'},
{ 'key': 'unknown2C',
'type': 'BYTES',
'off': 0x002C,
'size': 212,
'label': 'Unknown 2C'},
{ 'key': 'flags',
'type': 'DWORD',
'off': 0x0100,
'mask': { 0x01: 'enable BAM coloring', 0x02: 'enable smoke', 0x04: 'unknown', 0x08: 'darken projectile', 0x10: 'unknown2', 0x20: 'enable shadow', 0x40: 'enable light spot', 0x80: 'colored shadow' },
'label': 'Flags'},
{ 'key': 'projectile_bam',
'type': 'RESREF',
'off': 0x0104,
'label': 'BAM for travelling projectile'},
{ 'key': 'shadow_bam',
'type': 'RESREF',
'off': 0x010C,
'label': 'BAM for projectile shadow'},
{ 'key': 'projectile_bam_cycle',
'type': 'BYTE',
'off': 0x0114,
'label': 'BAM cycle for main projectile'},
{ 'key': 'shadow_bam_cycle',
'type': 'BYTE',
'off': 0x0115,
'label': 'BAM cycle for projectile shadow'},
{ 'key': 'light_spot_intensity',
'type': 'WORD',
'off': 0x0116,
'label': 'Light spot intensity'},
{ 'key': 'light_spot_x_size',
'type': 'BYTE',
'off': 0x0118,
'label': 'Light spot X-size'},
{ 'key': 'invisible',
'type': 'BYTE',
'off': 0x0119,
'label': 'Invisible'},
{ 'key': 'light_spot_y_size',
'type': 'WORD',
'off': 0x011A,
'label': 'Light spot Y-size'},
{ 'key': 'travel_type_color_bmp',
'type': 'RESREF',
'off': 0x011C,
'label': 'Travel-type projectile color BMP'},
{ 'key': 'projectile_color',
'type': 'BYTE',
'off': 0x0124,
'label': 'Projectile color'},
{ 'key': 'projectile_color_gradients',
'type': 'BYTES',
'off': 0x0125,
'size': 6,
'label': 'Projectile color gradients'},
{ 'key': 'smoke_puff_timing',
'type': 'BYTE',
'off': 0x012B,
'label': 'Smoke puff timing'},
{ 'key': 'smoke_color',
'type': 'BYTE',
'off': 0x012C,
'label': 'Smoke color'},
{ 'key': 'smoke_color_gradients',
'type': 'BYTES',
'off': 0x012D,
'size': 6,
'label': 'Smoke color gradients'},
{ 'key': 'face_target',
'type': 'BYTE',
'off': 0x0133,
'enum': { 1: 'dont face', 5: 'face' },
'label': 'Face target'},
{ 'key': 'smoke_reference',
'type': 'WORD', # FIXME: should be signed??
'off': 0x0134,
'enum': 'ANIMATE',
'label': 'Smoke reference to ANIMATE.IDS'},
{ 'key': 'secondary_missile_bam',
'type': 'RESREF',
'off': 0x0136,
'label': 'BAM for secondary missiles'},
{ 'key': 'tertiary_missile_bam',
'type': 'RESREF',
'off': 0x013E,
'label': 'BAM for tertiary missiles'},
{ 'key': 'quarternary_missile_bam',
'type': 'RESREF',
'off': 0x0146,
'label': 'BAM for quarternary missiles'},
{ 'key': 'secondary_missile_frequency',
'type': 'WORD',
'off': 0x014E,
'label': 'Frequency of secondary missiles'},
{ 'key': 'tertiary_missile_frequency',
'type': 'WORD',
'off': 0x0150,
'label': 'Frequency of tertiary missiles'},
{ 'key': 'quarternary_missile_frequency',
'type': 'WORD',
'off': 0x0152,
'label': 'Frequency of quarternary missiles'},
{ 'key': 'unknown154',
'type': 'BYTES',
'off': 0x0154,
'size': 176,
'label': 'Unknown 154'},
)
area_header_desc = (
{ 'key': 'aoe_target',
'type': 'WORD',
'off': 0x0200,
'mask': {0x0001: 'trap object visible',
0x0002: 'triggered by inanimate objects',
0x0004: 'triggered on condition',
0x0008: 'single explosion',
0x0010: 'no allies',
0x0020: 'draw fragments',
0x0040: 'no self',
0x0080: 'no enemies',
0x0100: 'unknown 8',
0x0200: 'multiple set off',
0x0400: 'use VVC',
0x0800: 'cone shape',
0x1000: 'unknown 12',
0x2000: 'no explosion?',
0x4000: 'delayed explosion?',
0x8000: 'affect only one' },
'label': 'AOE target (enemies/allies)'},
{ 'key': 'unknown202',
'type': 'WORD',
'off': 0x0202,
'label': 'Unknown 202'},
{ 'key': 'trigger_radius',
'type': 'WORD',
'off': 0x0204,
'label': 'Trigger radius'},
{ 'key': 'area_of_effect',
'type': 'WORD',
'off': 0x0206,
'label': 'Area of Effect'},
{ 'key': 'trigger_sound',
'type': 'RESREF',
'off': 0x0208,
'label': 'Trigger sound'},
{ 'key': 'delay_between_explosions',
'type': 'WORD',
'off': 0x0210,
'label': 'Delay between explosions'},
{ 'key': 'explosion_fragments',
'type': 'WORD',
'off': 0x0212,
'enum': 'ANIMATE',
'label': 'Explosion fragments to ANIMATE.IDS'},
{ 'key': 'unknown214',
'type': 'WORD',
'off': 0x0214,
'label': 'Unknown 214'},
{ 'key': 'duration_count',
'type': 'BYTE',
'off': 0x0216,
'label': 'Duration/Trigger count'},
{ 'key': '1st_explosion_projectile',
'type': 'BYTE',
'off': 0x0217,
'enum': 'FIREBALL',
'label': '1st explosion projectile ref to FIREBALL.IDS'},
{ 'key': '1st_explosion_color',
'type': 'BYTE',
'off': 0x0218,
'label': '1st explosion color'},
{ 'key': 'unknown219',
'type': 'BYTE',
'off': 0x0219,
'label': 'Unknown 219'},
{ 'key': 'explosion_projectile',
'type': 'WORD',
'off': 0x021A,
'enum': 'PROJECTL',
'label': 'Explosion projectile ref to PROJECTL.IDS'},
{ 'key': 'vvc',
'type': 'RESREF',
'off': 0x021C,
'label': 'VVC'},
{ 'key': 'cone_width',
'type': 'WORD',
'off': 0x0224,
'label': 'Cone width'},
{ 'key': 'unknown226',
'type': 'BYTES',
'off': 0x0226,
'size': 218,
'label': 'Unknown 218'},
)
def __init__ (self):
Format.__init__ (self)
self.expect_signature = 'PRO'
def read (self, stream):
self.read_header (stream)
if self.header['projectile_type'] == 3:
self.read_area_header (stream)
def printme (self):
self.print_header ()
if self.header['projectile_type'] == 3:
self.print_area_header ()
def read_area_header (self, stream):
self.area_header = {}
self.read_struc (stream, 0x0000, self.area_header_desc, self.area_header)
def print_area_header (self):
self.print_struc (self.area_header, self.area_header_desc)
register_format ('PRO', 'V1.0', PRO_Format)