Blizzard / heroprotocol

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

How to get party information? #83

Closed narfdotpl closed 4 years ago

narfdotpl commented 4 years ago

Hey,

I'm using heroprotocol as a black box (running python heroprotocol.py ... and reading JSON) in my Python tool for analysing win rates. I've noticed on a few websites that they show information about who was in a party with who. I was surprised to see this because HotS itself doesn't show it when watching a replay and I didn't see it it the heroprotocol README either.

Party information is something I would like to use. Right now I work around this by manually entering names of my party members into the script.

I searched on GitHub and what I understand is that I should be interested in the battlelobby "file":

battlelobby = archive.read_file('replay.server.battlelobby')

Unfortunately this returns binary. Could you help me with getting party info out of it? Is this structure documented anywhere? Are party values always at specific points by any chance? (The perfect scenario for me would be "party value is always n bytes after player's name"... 🤞)

yretenai commented 4 years ago

I'd much rather want Blizzard to either document or create generated protocol schemas for battlelobby and other (temporary) partial replay files so we can parse those files properly since I believe it's using the same bitpacked decoder as the normal replay data blobs.

The party data is always infront of the battletags, but only if they are actually in a party.

https://github.com/barrett777/Heroes.ReplayParser/blob/master/Heroes.ReplayParser/MPQFiles/ReplayServerBattlelobby.cs#L233-L243

MGatner commented 4 years ago

I’d also love a BattleLobby parser but Blizz has been unusual silent on the issue despite many requests so I can only guess that it includes information they don’t want public (or at least easily accessible). E.g. you can get full BattleTags from there so could friend request anyone from any replay file you had.

@narfdotpl You're on the right track! Check out line 233-ish here: https://github.com/barrett777/Heroes.ReplayParser/blob/master/Heroes.ReplayParser/MPQFiles/ReplayServerBattlelobby.cs - Heroes.ReplayParser is almost always up-to-date and was helpful in making this repo so is a trustworthy resource. You could also join us on the HotsApi Discord for more hands-on help.

narfdotpl commented 4 years ago

Thanks @healingbrew, @MGatner! It works: https://github.com/narfdotpl/hots-winrate/commit/e13720b0792730f374a0ac7b21b669344eff7b89 ✨

I even got a cool stat about my SL games that semi-confirms my suspicion that it's not worth to play as 5 unless you play really well together:

solo:        58% ( 62/107) (+17)
party of 3:  57% ( 27/ 47) (+ 7)
average:     56% (175/315) (+35)
party of 4:  56% ( 15/ 27) (+ 3)
party of 2:  54% ( 52/ 97) (+ 7)
party of 5:  51% ( 19/ 37) (+ 1)

Thanks again and happy holidays!