10
10
11
11
12
12
class TrackerEvent (Event ):
13
+ """
14
+ Parent class for all tracker events.
15
+ """
13
16
def __init__ (self , frames ):
14
17
#: The frame of the game this event was applied
15
18
self .frame = frames
19
+
20
+ #: The second of the game (game time not real time) this event was applied
16
21
self .second = frames >> 4
17
22
18
23
#: Short cut string for event class name
@@ -30,17 +35,15 @@ def __str__(self):
30
35
31
36
class PlayerStatsEvent (TrackerEvent ):
32
37
"""
33
- Player Stats events are generated for all players that were in the game
34
- even if they've since left every 10 seconds. An additional set of stats
35
- events are generated at the end of the game.
38
+ Player Stats events are generated for all players that were in the game even if they've since
39
+ left every 10 seconds. An additional set of stats events are generated at the end of the game.
36
40
37
- When a player leaves the game, a single PlayerStatsEvent is generated
38
- for that player and no one else. That player continues to generate
39
- PlayerStatsEvents at 10 second intervals until the end of the game.
41
+ When a player leaves the game, a single PlayerStatsEvent is generated for that player and no
42
+ one else. That player continues to generate PlayerStatsEvents at 10 second intervals until the
43
+ end of the game.
40
44
41
- In 1v1 games, the above behavior can cause the losing player to have 2
42
- events generated at the end of the game. One for leaving and one for
43
- the end of the game.
45
+ In 1v1 games, the above behavior can cause the losing player to have 2 events generated at the
46
+ end of the game. One for leaving and one for the end of the game.
44
47
"""
45
48
def __init__ (self , frames , data , build ):
46
49
super (PlayerStatsEvent , self ).__init__ (frames )
@@ -213,15 +216,14 @@ def __str__(self):
213
216
214
217
class UnitBornEvent (TrackerEvent ):
215
218
"""
216
- Generated when a unit is created in a finished state in the game. Examples
217
- include the Marine, Zergling, and Zealot (when trained from a gateway).
218
- Units that enter the game unfinished (all buildings, warped in units) generate
219
- a :class:`UnitInitEvent` instead.
220
-
221
- Unfortunately, units that are born do not have events marking their beginnings
222
- like :class:`UnitInitEvent` and :class:`UnitDoneEvent` do. The closest thing to
223
- it are the :class:`~sc2reader.event.game.AbilityEvent` game events where the ability
224
- is a train unit command.
219
+ Generated when a unit is created in a finished state in the game. Examples include the Marine,
220
+ Zergling, and Zealot (when trained from a gateway). Units that enter the game unfinished (all
221
+ buildings, warped in units) generate a :class:`UnitInitEvent` instead.
222
+
223
+ Unfortunately, units that are born do not have events marking their beginnings like
224
+ :class:`UnitInitEvent` and :class:`UnitDoneEvent` do. The closest thing to it are the
225
+ :class:`~sc2reader.event.game.AbilityEvent` game events where the ability is a train unit
226
+ command.
225
227
"""
226
228
def __init__ (self , frames , data , build ):
227
229
super (UnitBornEvent , self ).__init__ (frames )
@@ -253,10 +255,12 @@ def __init__(self, frames, data, build):
253
255
#: The player object that controls this unit. 0 means neutral unit
254
256
self .unit_controller = None
255
257
256
- #: The x coordinate of the location
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.
257
260
self .x = data [5 ] * 4
258
261
259
- #: The y coordinate of the location
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.
260
264
self .y = data [6 ] * 4
261
265
262
266
#: The map location of the unit birth
@@ -292,10 +296,12 @@ def __init__(self, frames, data, build):
292
296
#: The player object of the that killed the unit. Not always available.
293
297
self .killer = None
294
298
295
- #: The x coordinate of the location
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.
296
301
self .x = data [3 ] * 4
297
302
298
- #: The y coordinate of the location
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.
299
305
self .y = data [4 ] * 4
300
306
301
307
#: The map location the unit was killed at.
@@ -394,10 +400,9 @@ def __str__(self):
394
400
395
401
class UnitInitEvent (TrackerEvent ):
396
402
"""
397
- The counter part to :class:`UnitDoneEvent`, generated by the game engine
398
- when a unit is initiated. This applies only to units which are started
399
- in game before they are finished. Primary examples being buildings and
400
- warp-in units.
403
+ The counter part to :class:`UnitDoneEvent`, generated by the game engine when a unit is
404
+ initiated. This applies only to units which are started in game before they are finished.
405
+ Primary examples being buildings and warp-in units.
401
406
"""
402
407
def __init__ (self , frames , data , build ):
403
408
super (UnitInitEvent , self ).__init__ (frames )
@@ -429,10 +434,12 @@ def __init__(self, frames, data, build):
429
434
#: The player object that controls this unit. 0 means neutral unit
430
435
self .unit_controller = None
431
436
432
- #: The x coordinate of the location
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.
433
439
self .x = data [5 ] * 4
434
440
435
- #: The y coordinate of the location
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.
436
443
self .y = data [6 ] * 4
437
444
438
445
#: The map location the unit was started at
@@ -444,9 +451,8 @@ def __str__(self):
444
451
445
452
class UnitDoneEvent (TrackerEvent ):
446
453
"""
447
- The counter part to the :class:`UnitInitEvent`, generated by the game engine
448
- when an initiated unit is completed. E.g. warp-in finished, building finished,
449
- morph complete.
454
+ The counter part to the :class:`UnitInitEvent`, generated by the game engine when an initiated
455
+ unit is completed. E.g. warp-in finished, building finished, morph complete.
450
456
"""
451
457
def __init__ (self , frames , data , build ):
452
458
super (UnitDoneEvent , self ).__init__ (frames )
@@ -485,7 +491,9 @@ def __init__(self, frames, data, build):
485
491
#: A dict mapping of units that had their position updated to their positions
486
492
self .units = dict ()
487
493
488
- #: A list of (unit_index, (x,y)) derived from the first_unit_index and items
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.
489
497
self .positions = list ()
490
498
491
499
unit_index = self .first_unit_index
0 commit comments