skadistats / clarity

Comically fast Dota 2, CSGO, CS2 and Deadlock replay parser written in Java.
BSD 3-Clause "New" or "Revised" License
663 stars 122 forks source link

Item Drop Events #308

Closed VirenDias closed 1 year ago

VirenDias commented 1 year ago

Hi, I'm looking to get the data for item drop events, more specifically:

I've been trying to figure it out for a while, but I've been unsuccessful. Can anyone help me out?

reacheight commented 1 year ago

Each neutral token creates an entity (e. g. CDOTA_Item_Tier1Token for tier 1 token) when dropped and deletes the entity when activated. The entity contains player Id in the m_iPlayerOwnerID property (it doesn't change when another hero takes the token).

And there is DOTA_COMBATLOG_NEUTRAL_ITEM_EARNED combatlog type, but apparently it's not working now.

reacheight commented 1 year ago

For Rapiers I'd probably go like this:

  1. Track "creation" of every Rapier with @OnEntityCreated. I think you need to use StringTable here to check if an entity is actually a Rapier, because entity for Rapier is called like generic CDOTA_Item. Save entity handle of every Rapier.
  2. Track the m_iPlayerOwnerID property of the saved entities with @OnEntityPropertyChanged (get the first owner when entity created, other owners when this property changes).

Feel free to ask any questions.

VirenDias commented 1 year ago

Each neutral token creates an entity (e. g. CDOTA_Item_Tier1Token for tier 1 token) when dropped and deletes the entity when activated. The entity contains player Id in the m_iPlayerOwnerID property (it doesn't change when another hero takes the token).

And there is DOTA_COMBATLOG_NEUTRAL_ITEM_EARNED combatlog type, but apparently it's not working now.

Thank you so much! How do I map m_iPlayerOwnerID to a hero or steam ID?

reacheight commented 1 year ago

So PlayerId is a relative Id of a player in the given replay. It can only be an even number and goes from 0 to 18. 0 2 4 6 8 for radiant, 10-18 for dire, in the same order as you can see in Dota HUD at the top.

I know 2 ways to map PlayerId to a hero:

  1. Find a hero entity (name starts with CDOTA_UnitHero) with the given PlayerId in the m_iPlayerID property.
  2. Clarity.infoForFile(file).getGameInfo().getDota() gives you an object that has basic info about the game without running the replay. This object has getPlayerInfo(id) method, but id here is twice smaller than in entities' properties (valve 🤡), so e. g. getPlayerInfo(4) will get you info about the player with PlayerId = 8. Then this player info object has getHeroName() method that returns the name in "npc_dota_hero_antimage" format. This way is better if you wanna get the hero Id, because it returns names in the same format as the /IEconDOTA2_570/GetHeroes/v0001 Steam API method. UPD: player info object also has getSteamid() method.
VirenDias commented 1 year ago

Thank you, you've been very helpful! I've managed to get the data I need :).

spheenik commented 1 year ago

Thank you @reacheight for helping him out! Much appreciated!