The StreamBinding class is Tarrasque’s metaphor for the replay. Every Tarrasque entity class has a reference to an instance of this class, and when the tick of the instance changes, the data returned by those classes changes. This makes it easy to handle complex object graphs without explicitly needing to pass the Skadi demo object around.
Note
Where methods on this class take absolute tick values (i.e. the start and end arguments to iter_ticks()), special string arguments may be passed. These are:
These values will not be 100% accurate, but should be good +-50 ticks
Loads the demo from the filename, and then initialises the StreamBinding with it, along with any other passed arguments.
Moves to the time when the GameInfo.game_state changed to the given state. Valid values are equal to the possible values of :att:`~GameInfo.game_state`, along with "start" and "end" which signify the first and last tick in the replay, respectively.
Returns the tick moved to.
Moves to the given tick, or the nearest tick after it. Returns the tick moved to.
Moves to the tick with the given game time. Could potentially overshoot, but not by too much. Will not undershoot.
Returns the tick it has moved to.
A generator that iterates through the demo’s ‘full ticks’; sync points that occur once a minute. Should be _much_ faster than :method:`iter_ticks`.
The start argument may take the same range of values as the start argument of :method:`iter_ticks`. The first full tick yielded will be the next full tick after the position obtained via self.go_to_tick(start).
The end tick may either be a tick value or a game state. The last full
tick yielded will be the first full tick after the tick value/game state change.
A generator that iterates through the demo’s ticks and updates the StreamBinding to that tick. Yields the current tick.
The start parameter defines the tick to iterate from, and if not set, the current tick will be used instead.
The end parameter defines the point to stop iterating; if not set, the iteration will continue until the end of the replay.
The step parameter is the number of ticks to consume before yielding the tick; the default of one means that every tick will be yielded. Do not assume that the step is precise; the gap between two ticks will always be larger than the step, but usually not equal to it.
A base class for all Tarrasque entity classes.
If you plan to manually initialise this class or any class inheriting from it (and I strongly recommend against it), pass initialisation arguments by name.
True if the ehandle exists in the current tick’s world. Examples of this not being true are when a Hero entity that represents an illusion is killed, or at the start of a game when not all heroes have been chosen.
This method uses the class’s dt_key attribute to find all instances of the class in the stream binding’s current tick, and then initialise them and return them as a list.
While this method seems easy enough to use, prefer other methods where possible. For example, using this function to find all Player instances will return 11 or more players, instead of the usual 10, where as StreamBinding.players returns the standard (and correct) 10.
A list of the entitiy’s modifiers. While this does not make sense on some entities, as modifiers can be associated with any entity, this is implemented here.
The name of an entity. This will either be equal to the DotaEntity.raw_name or be overridden to be a name an end user might be more familiar with. For example, if raw_name is "dt_dota_nevermore", this value might be set to "Nevermore" or "Shadow Field".
The “owner” of the entity. For example, a :class:BaseAbility the hero that has that ability as its owner.
The raw name of the entity. Not very useful on its own.
The StreamBinding object that the entity is bound to. The source of all information in a Tarrasque entity class.
The team that the entity is on. Options are
Finds the correct class for the ehandle and initialises it.
Returns the class that should be used to represent the ehandle with the given dt name.
Register a class that Tarrasque will use to represent dota entities with the given DT key. This class decorator automatically sets the :attr:~DotaEntity.dt_key attribute.
Similar to register_entity, will register a class, but instead of specifying a specific DT, use a regular expression to specify a range of DTs. For example, Hero uses this to supply a model for all heroes, i.e.:
from tarrasque.entity import *
@register_entity_wildcard("DT_DOTA_Unit_Hero_(.*)")
class Hero(DotaEntity):
def __new__(cls, *args, **kwargs):
# Use __new__ to dynamically generate individual hero classes
# See tarrasque/hero.py for actual implementation
return cls(*args, **kwargs)
A wildcard registration will not override a specific DT registration via register_entity.
Inherits from DotaEntity.
Represents a player in the game. This can be a player who is controlling a hero, or a “player” that is spectating.
The number of assists the player has.
The game time that the buyback will come off cooldown. If this is 0, the player has not bought back.
The number of times the player has died.
The number of denies on creeps that the player has.
The total earned gold by the user. This is not net worth; it should be used to calculate gpm and stuff.
The Hero that the player is playing in the tick. May be None if the player has yet to choose a hero. May change when the game_state is "pre_game", due to players swapping their heroes.
The index of the player in the game. i.e. 0 is the first player on the radiant team, 9 is the last on the dire
This is None for the undefined player, which should be ignored.
The number of times the player has killed an enemy hero.
The game_time that the player bought back.
The number of last hits on creeps that the player has.
The Steam name of the player, at the time of the game being played.
The Steam ID of the player.
The current kill-streak the player is on
The player’s team. Possible values are
Inherits from DotaEntity
The GameInfo contains the macro state of the game; the stage of the game that the tick is in, whether the tick is in day or night, the length of the game, etc etc.
The team that is currently banning/picking.
List of currently banned heroes. 0-4 are radiant picks, 5-9 dire. Bans that have not yet been done have value None.
IDs of the picking players (captains)
The time that the game_state changed to draft.
Extra time left for both teams. Index 0 is radiant, index 1 is dire
The time that the game_state changed to postgame.
The mode of the dota game. Possible values are:
The time that the game_state changed to game.
The state of the game. Potential values are:
The time in seconds of the current tick.
The winner of the game.
The time that the game_state changed to loading.
The unique match id, used by the Steam API and stuff (i.e. DotaBUff and friends).
The team that is currently pausing. Will be None if the game is not paused, otherwise either "radiant" or "dire".
The current pick/ban that is happening. None if no pick or ban is happening. If the game_mode is not "captain's mode", the possible values are:
Otherwise, the current pick and ban is returned in a tuple of the type of draft action and the index. For example, if the current tick was during the 5th ban of a captains mode game, the value of pick_state would be ("ban", 5). active_team could then be used to work out who is banning. Alternatively, if it was the 2nd pick of the game, it would be ("pick", 2).
The time that the game_state changed to pregame.
List of currently picked heroes. 0-4 are radiant picks, 5-9 dire. Picks that have not yet been done have value None.
The team that begins the draft.
Base class for all abilities. Currently does not delegate to other classes, but can do so.
The distance from the hero’s position that this spell can be cast/targeted at.
How long the goes on cooldown for every time it is cast.
Uses off_cooldown_time and GameInfo.game_time to calculate if the ability is on cooldown or not.
Use’s the abilities position in Hero.abilities to figure out if this is the ultimate ability.
TODO: Check this is reliable
The number of times the ability has been leveled up.
The mana cost of the spell
The time the ability comes off cooldown. Note that this does not reset once that time has been passed.
A base class for all NPCs, even ones controllable by players.
A list of the NPC’s abilities.
The NPC’s current HP.
The NPC’s health regen per second.
A list of the NPC’s items.
The NPC’s level. See Hero.ability_points for unspent level up ability points.
The state of the NPC’s life (unsurprisingly). Possible values are:
"respawnable" and "discardbody" shouldn’t occur in a Dota2 replay
The NPC’s current mana.
The NPC’s mana regen per second.
The NPC’s maximum HP.
The NPC’s maximum mana.
The (x, y) position of the NPC in Dota2 map coordinates
While each hero has a distinct class, not all have classes that are defined in source code. This is because the Hero class registers itself as a wildcard on the DT regexp "DT_DOTA_Unit_Hero_*", and then dynamically generates hero classes from the ehandle. The generated classes simply inherit from the Hero and have different values for dt_key and name.
While all hero classes inherit from this class, it is unlikely that this class will ever need to be instantiated.
Seems to be the number of ability points the player can assign.
The hero’s agility (from levels, items, and the attribute bonus).
`"DT_DOTA_BaseNPC_Hero"`, and it also wouldn’t be of any use to devs.
The hero’s intelligence (from levels, items, and the attribute bonus).
The name of the hero. For the base Hero class, this is None, but it is set when a subclass is created in the __new__ method.
The hero’s agility from levels.
The hero’s intelligence from levels.
The hero’s strength from levels.
The damage taken by the hero recently. The exact time period that classifies as “recently” is around 2/3 seconds.
TODO: Find exact value
The Hero the current hero is “replicating” [#f1]_. If the instance is not an illusion (which use the Hero class also), this will be None. There is no guarantee that that this hero will exist (see DotaEntity.exists) if the hero is someone like Phantom Lancer, who may have an illusion which creates other illusions, and then dies. However, this is still a useful property for tracking illusion creation chains
Appears to be the absolute time that the hero respawns. See game_time for the current time of the tick to compare.
TODO: Check this on IRC
The time (in game_time units) the hero spawned at.
TODO: Check this in game.
The hero’s strength (from levels, items, and the attribute bonus).
The hero’s experience.
Base class for all game events. Handles humanise and related things.
The name of the GameEvent. i.e. "dota_combatlog", "dota_chase_hero".
Creates a new GameEvent object from a stream binding and the un-humanized game event data.
Given the name of an event, finds the class that should be used to represent it.
Same as register_event() but uses a regex pattern to match, instead of a static game event name.
A message in the combat log.
The name of the attacker in the event.
The health of the unit being attacked, for ‘heal’ and ‘damage’ events.
The name of the “inflictor” (wtf is that?). Used to id modifiers.
The name of the source of the event.
The name of the entity that was targeted in the event. Note that this is not the dt name or “pretty” name, this is the DotaEntity.raw_name. So for a message where Shadow Field is being attacked, this would be "dt_dota_nevermore".
The timestamp this combat log message corresponds to.
The type of event this message signifies. Options are:
Item class
Presumably whether you can right-click ‘Alert allies’ with it (ex: Smoke, Arcane Boots, ‘Gather for Arcane Boots here!’)
These are all the same as the functions in the ability class, I’m lazy, go read them, they are fairly self-explanatory :D
Presumably the item’s current charges (ex: 7 for Diffusal if used once)
Presumably whether you can disassemble the item (ex: Arcane Boots)
Presumably if the item is droppable (ex: not Aegis)
Presumably charges when item is bought (ex: 8 for diffusal)
Presumably whether the item can be denied (ex: not Gem)
The time when the item will come off cooldown
Seems to be if the item will disappear when it runs out of stacks (i.e consumable. Ex: Tango, not Diffusal)
Presumably whether you can buy the item or not (ex: not Aegis)
The time when the item was purchased
The hero object of the purchaser of the item
Presumably whether the item is a recipe or not (ex: any Recipe)
Presumably whether the item needs charges to work (ex: Diffusal)
Presumably whether the item can be sold or not (ex: Not BKB)
Presumably whether the item can be shared (ex: Tango, RoH)
Presumably whether the item can be stacked (ex: Wards)