@@ -27,12 +27,30 @@ def load_context(self, replay):
27
27
pass
28
28
29
29
def _str_prefix (self ):
30
- return "{0}\t " .format (Length (seconds = int (self .frame / 16 )))
30
+ return "{0}\t " .format (Length (seconds = int (self .frame / 16 )))
31
31
32
32
def __str__ (self ):
33
33
return self ._str_prefix () + self .name
34
34
35
35
36
+ class PlayerSetupEvent (TrackerEvent ):
37
+ """ Sent during game setup to help us organize players better """
38
+ def __init__ (self , frames , data , build ):
39
+ super (PlayerSetupEvent , self ).__init__ (frames )
40
+
41
+ #: The player id of the player we are setting up
42
+ self .pid = data [0 ]
43
+
44
+ #: The type of this player. One of 1=human, 2=cpu, 3=neutral, 4=hostile
45
+ self .type = data [1 ]
46
+
47
+ #: The user id of the player we are setting up. None of not human
48
+ self .uid = data [2 ]
49
+
50
+ #: The slot id of the player we are setting up. None if not playing
51
+ self .sid = data [3 ]
52
+
53
+
36
54
class PlayerStatsEvent (TrackerEvent ):
37
55
"""
38
56
Player Stats events are generated for all players that were in the game even if they've since
@@ -181,10 +199,10 @@ def __init__(self, frames, data, build):
181
199
self .resources_killed = self .minerals_killed + self .vespene_killed
182
200
183
201
#: The food supply currently used
184
- self .food_used = clamp (self .stats [29 ])/ 4096.0
202
+ self .food_used = clamp (self .stats [29 ]) / 4096.0
185
203
186
204
#: The food supply currently available
187
- self .food_made = clamp (self .stats [30 ])/ 4096.0
205
+ self .food_made = clamp (self .stats [30 ]) / 4096.0
188
206
189
207
#: The total mineral value of all active forces
190
208
self .minerals_used_active_forces = clamp (self .stats [31 ])
@@ -211,7 +229,7 @@ def __init__(self, frames, data, build):
211
229
self .ff_vespene_lost_technology = clamp (self .stats [38 ]) if build >= 26490 else None
212
230
213
231
def __str__ (self ):
214
- return self ._str_prefix ()+ "{0: >15} - Stats Update" .format (self .player )
232
+ return self ._str_prefix () + "{0: >15} - Stats Update" .format (self .player )
215
233
216
234
217
235
class UnitBornEvent (TrackerEvent ):
@@ -255,19 +273,24 @@ def __init__(self, frames, data, build):
255
273
#: The player object that controls this unit. 0 means neutral unit
256
274
self .unit_controller = None
257
275
258
- #: The x coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
259
- #: Location prior to rounding marks the center of the unit footprint .
260
- self .x = data [5 ] * 4
276
+ #: The x coordinate of the center of the born unit's footprint. Only 4 point resolution
277
+ #: prior to Starcraft Patch 2.1 .
278
+ self .x = data [5 ]
261
279
262
- #: The y coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
263
- #: Location prior to rounding marks the center of the unit footprint .
264
- self .y = data [6 ] * 4
280
+ #: The y coordinate of the center of the born unit's footprint. Only 4 point resolution
281
+ #: prior to Starcraft Patch 2.1 .
282
+ self .y = data [6 ]
265
283
266
284
#: The map location of the unit birth
267
285
self .location = (self .x , self .y )
268
286
287
+ if build < 27950 :
288
+ self .x = self .x * 4
289
+ self .y = self .y * 4
290
+ self .location = (self .x , self .y )
291
+
269
292
def __str__ (self ):
270
- return self ._str_prefix ()+ "{0: >15} - Unit born {1}" .format (self .unit_upkeeper , self .unit )
293
+ return self ._str_prefix () + "{0: >15} - Unit born {1}" .format (self .unit_upkeeper , self .unit )
271
294
272
295
273
296
class UnitDiedEvent (TrackerEvent ):
@@ -296,19 +319,39 @@ def __init__(self, frames, data, build):
296
319
#: The player object of the that killed the unit. Not always available.
297
320
self .killer = None
298
321
299
- #: The x coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
300
- #: Location prior to rounding marks the center of the unit footprint .
301
- self .x = data [3 ] * 4
322
+ #: The x coordinate of the center of the dying unit's footprint. Only 4 point resolution
323
+ #: prior to Starcraft Patch 2.1 .
324
+ self .x = data [3 ]
302
325
303
- #: The y coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
304
- #: Location prior to rounding marks the center of the unit footprint .
305
- self .y = data [4 ] * 4
326
+ #: The y coordinate of the center of the dying unit's footprint. Only 4 point resolution
327
+ #: prior to Starcraft Patch 2.1 .
328
+ self .y = data [4 ]
306
329
307
330
#: The map location the unit was killed at.
308
331
self .location = (self .x , self .y )
309
332
333
+ #: The index portion of the killing unit's id. Available for build 27950+
334
+ self .killer_unit_index = None
335
+
336
+ #: The recycle portion of the killing unit's id. Available for build 27950+
337
+ self .killer_unit_recycle = None
338
+
339
+ #: The unique id of the unit doing the killing. Available for build 27950+
340
+ self .killer_unit_id = None
341
+
342
+ if build < 27950 :
343
+ self .x = self .x * 4
344
+ self .y = self .y * 4
345
+ self .location = (self .x , self .y )
346
+ else :
347
+ # Starcraft patch 2.1 introduced killer unit indexes
348
+ self .killer_unit_index = data [5 ]
349
+ self .killer_unit_recycle = data [6 ]
350
+ if self .killer_unit_index :
351
+ self .killer_unit_id = self .killer_unit_index << 18 | self .killer_unit_recycle
352
+
310
353
def __str__ (self ):
311
- return self ._str_prefix ()+ "{0: >15} - Unit died {1}." .format (self .unit .owner , self .unit )
354
+ return self ._str_prefix () + "{0: >15} - Unit died {1}." .format (self .unit .owner , self .unit )
312
355
313
356
314
357
class UnitOwnerChangeEvent (TrackerEvent ):
@@ -344,7 +387,7 @@ def __init__(self, frames, data, build):
344
387
self .unit_controller = None
345
388
346
389
def __str__ (self ):
347
- return self ._str_prefix ()+ "{0: >15} took {1}" .format (self .unit_upkeeper , self .unit )
390
+ return self ._str_prefix () + "{0: >15} took {1}" .format (self .unit_upkeeper , self .unit )
348
391
349
392
350
393
class UnitTypeChangeEvent (TrackerEvent ):
@@ -372,7 +415,7 @@ def __init__(self, frames, data, build):
372
415
self .unit_type_name = data [2 ].decode ('utf8' )
373
416
374
417
def __str__ (self ):
375
- return self ._str_prefix ()+ "{0: >15} - Unit {0} type changed to {1}" .format (self .unit .owner , self .unit , self .unit_type_name )
418
+ return self ._str_prefix () + "{0: >15} - Unit {0} type changed to {1}" .format (self .unit .owner , self .unit , self .unit_type_name )
376
419
377
420
378
421
class UpgradeCompleteEvent (TrackerEvent ):
@@ -395,7 +438,7 @@ def __init__(self, frames, data, build):
395
438
self .count = data [2 ]
396
439
397
440
def __str__ (self ):
398
- return self ._str_prefix ()+ "{0: >15} - {1}upgrade completed" .format (self .player , self .upgrade_type_name )
441
+ return self ._str_prefix () + "{0: >15} - {1}upgrade completed" .format (self .player , self .upgrade_type_name )
399
442
400
443
401
444
class UnitInitEvent (TrackerEvent ):
@@ -434,19 +477,24 @@ def __init__(self, frames, data, build):
434
477
#: The player object that controls this unit. 0 means neutral unit
435
478
self .unit_controller = None
436
479
437
- #: The x coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
438
- #: Location prior to rounding marks the center of the unit footprint .
439
- self .x = data [5 ] * 4
480
+ #: The x coordinate of the center of the init unit's footprint. Only 4 point resolution
481
+ #: prior to Starcraft Patch 2.1 .
482
+ self .x = data [5 ]
440
483
441
- #: The y coordinate of the location with 4 point resolution. E.g. 13.75 recorded as 12.
442
- #: Location prior to rounding marks the center of the unit footprint .
443
- self .y = data [6 ] * 4
484
+ #: The y coordinate of the center of the init unit's footprint. Only 4 point resolution
485
+ #: prior to Starcraft Patch 2.1 .
486
+ self .y = data [6 ]
444
487
445
488
#: The map location the unit was started at
446
489
self .location = (self .x , self .y )
447
490
491
+ if build < 27950 :
492
+ self .x = self .x * 4
493
+ self .y = self .y * 4
494
+ self .location = (self .x , self .y )
495
+
448
496
def __str__ (self ):
449
- return self ._str_prefix ()+ "{0: >15} - Unit initiated {1}" .format (self .unit_upkeeper , self .unit )
497
+ return self ._str_prefix () + "{0: >15} - Unit initiated {1}" .format (self .unit_upkeeper , self .unit )
450
498
451
499
452
500
class UnitDoneEvent (TrackerEvent ):
@@ -470,7 +518,7 @@ def __init__(self, frames, data, build):
470
518
self .unit = None
471
519
472
520
def __str__ (self ):
473
- return self ._str_prefix ()+ "{0: >15} - Unit {1} done" .format (self .unit .owner , self .unit )
521
+ return self ._str_prefix () + "{0: >15} - Unit {1} done" .format (self .unit .owner , self .unit )
474
522
475
523
476
524
class UnitPositionsEvent (TrackerEvent ):
@@ -491,17 +539,20 @@ def __init__(self, frames, data, build):
491
539
#: A dict mapping of units that had their position updated to their positions
492
540
self .units = dict ()
493
541
494
- #: A list of (unit_index, (x,y)) derived from the first_unit_index and items. Like the other
495
- #: tracker events, these coordinates have 4 point resolution. (15,25) recorded as (12,24).
496
- #: Location prior to rounding marks the center of the unit footprint.
542
+ #: A list of (unit_index, (x,y)) derived from the first_unit_index and items. Prior to
543
+ #: Starcraft Patch 2.1 the coordinates have 4 point resolution. (15,25) recorded as (12,24).
544
+ #: Location prior to any rounding marks the center of the unit footprint.
497
545
self .positions = list ()
498
546
499
547
unit_index = self .first_unit_index
500
548
for i in range (0 , len (self .items ), 3 ):
501
549
unit_index += self .items [i ]
502
- x = self .items [i + 1 ]* 4
503
- y = self .items [i + 2 ]* 4
550
+ x = self .items [i + 1 ]
551
+ y = self .items [i + 2 ]
552
+ if build < 27950 :
553
+ x = x * 4
554
+ y = y * 4
504
555
self .positions .append ((unit_index , (x , y )))
505
556
506
557
def __str__ (self ):
507
- return self ._str_prefix ()+ "Unit positions update"
558
+ return self ._str_prefix () + "Unit positions update"
0 commit comments