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