Skip to content

DT_DOTA_PlayerResource

mfajer edited this page Sep 3, 2013 · 11 revisions

Arrays

  • These arrays index from 0000-0004 for Radiant, 0005-0009 for Dire, and 0010-#### for spectators, etc.

When a DT_DOTA_PlayerResource is found, such as players=world.find_all_by_dt('DT_DOTA_PlayerResource'), an collections.OrderedDict is returned. The only item in players is a tuple (ehandle,state) pair. ehandle is the ehandle for this DT, and the state is a regular dict. The keys in this dict are tuples of a data point, and a player. for example:

  • ('m_iReliableGold','0003'): contains the reliable gold of player 3
  • ('m_iPlayerTeams','0000'): contains the team of player 0
  • ('m_iPlayerSteamIDs','0006'): contains the steamID of player 6
  • ('m_iLastHitCount','0005'): contains the number of last hits player 5 has

Visual of players=world.find_all_by_dt('DT_DOTA_PlayerResource')

data structure

Example

This example shows how we can make a plot of each player's total earned gold as a function of time. This method uses the m_iszPlayerNames and m_iTotalEarnedGold to get this information.

import io
from skadi.replay import demo as rd
import matplotlib.pyplot as plt
    
demfile= 'YOURDEMPATH'
   
gold={} #Initialize a dict file that will store all the earned gold, by player name
    
infile=io.open(demfile,'r+b')
demo = rd.construct(infile)
stream=demo.stream(tick=5000)
    
player_dt='DT_DOTA_PlayerResource'
players = stream.world.find_all_by_dt(player_dt)
    
#This list will allow us to access all the correct properties by player
player_id_list=['0000','0001','0002','0003','0004','0005','0006','0007','0008','0009']
    
#Construct the dict with keys that are each players name.
#The values in the dict will be a list of int.
for ehandle,state in players.items():
    for i in range(len(player_id_list)):
        gold[state[('m_iszPlayerNames',player_id_list[i])]]=[]
        
ticks=[]

for tick, string_tables, world in demo.stream(tick=5000):
    players = world.find_all_by_dt(player_dt) #Find all the 'DT_DOTA_PlayerResource' ehandles
        
    for ehandle, state in players.items(): #Iterate through the ehandles (in this case, there is only one)
        ticks.append(tick)
        for i in range(len(player_id_list)): #For each tick, we want to get the player's earned gold. 
            name=state[('m_iszPlayerNames',player_id_list[i])]
            player_gold=state[('m_iTotalEarnedGold',player_id_list[i])]    
            gold[name].append(player_gold)
                  
for i in gold.keys():
    plt.plot(ticks,gold[i])
        
plt.show()

Player's earned gold vs. time (in ticks)

Full List of DT_DOTA_PlayerResource arrays names:

  • m_iszSelectedHero
  • m_iReliableGold : the player's reliable gold
  • m_bIsBroadcaster
  • m_nSelectedHeroID : hero ID for that player entry (http://wiki.teamfortress.com/wiki/WebAPI/GetHeroes)
  • m_UnitShareMasks
  • m_iNearbyCreepDeathCount
  • m_iszPlayerNames : the player's name
  • m_bHasRepicked
  • m_iTimedRewardCrates
  • m_iTimedRewardDrops
  • m_bFakeClient
  • m_iBroadcasterLanguage
  • m_iLastHitStreak
  • m_bBattleBonusActive
  • m_iMetaLevel
  • m_hSelectedHero : ehandle for the DT_DOTA_Unit_Hero entity
  • m_iMetaExperienceBonusRate
  • m_iLastHitMultikill
  • m_iLastHitCount
  • m_iLevel
  • m_iDenyCount
  • m_iConnectionState
  • m_iDeaths
  • m_bFullyJoinedServer
  • m_iBroadcasterChannelSlot
  • m_iMetaExperience
  • m_iTotalEarnedXP
  • m_iPlayerSteamIDs : steam ID for that player
  • m_nPossibleHeroSelection
  • m_bVoiceChatBanned
  • m_iUnreliableGold : the player's unreliable gold
  • m_iLastBuybackTime
  • m_iAssists
  • m_nSuggestedHeroes
  • m_iBattleBonusRate
  • m_iKills
  • m_iTotalEarnedGold : The player's total earned gold
  • m_iPlayerTeams : the player's side in game
    • 2: Radiant
    • 3: Dire
    • 5: Spectator
  • m_iRespawnSeconds
  • m_bHasRandomed
  • m_iStreak
  • m_iBroadcasterChannel
  • m_flBuybackCooldownTime : The game time that the player can buy back. Will be 0 until the player buys back for the first time.
  • m_bAFK
  • m_iMetaExperienceAwarded