Blizzard / heroprotocol

Python library to decode Heroes of the Storm replays
MIT License
397 stars 71 forks source link

How to get Last Hit Player Kill? #81

Closed KjellConnelly closed 5 years ago

KjellConnelly commented 5 years ago

It seems like when I look under Player Deaths, I can an array of killers, and I can map them to my list of players. But I don't get any info on who got the last hit (ie if a morales hits hanzo once, and greymane takes the hanzo from 95%-0% in 1 combo, then morales is equally added to the array). In this case, I would like to know who got the last hit on hanzo, especially since the game shows who did, and this is counted as a kill, instead of an assist.

barrett777 commented 5 years ago

In the tracker events, the UnitDiedEvent contains the player who killed the unit. I'm pretty sure this applies to normal units as well as player units:

https://github.com/Blizzard/heroprotocol/blob/master/protocol76437.py#L335 https://github.com/Blizzard/heroprotocol/blob/master/protocol76437.py#L213

I'm used to the C# replay parser so I'm not too familiar with usage here. The README shows command line arguments for printing tracker events, and an explanation on the unit tag indexes, which are a bit tricky. Unit Ids are recycled throughout a game. You'll know if you mapped them correctly when the player hero kills you calculate line up with score screen kills.

KjellConnelly commented 5 years ago

Figured it out: check born event IDs for heros and use those some IDs in the Unit death. Doesn't work perfectly (for instance with Uther who kills himself according to my algorithm), but does decently. Thank you!