Python library to decode Heroes of the Storm replay protocols
Python
Failed to load latest commit information.
mpyq Initial commit Dec 15, 2015
.gitattributes Initial commit Dec 15, 2015
.gitignore Initial commit Dec 15, 2015
LICENSE Initial commit Dec 15, 2015
README.md Merge pull request #7 from ReadmeCritic/master Jan 29, 2016
__init__.py Initial commit Dec 15, 2015
decoders.py Initial commit Dec 15, 2015
heroprotocol.py Merge branch 'json-dump' of git://github.com/bryanar/heroprotocol int… Jan 29, 2016
protocol29406.py Initial commit Dec 15, 2015
protocol30414.py Added additional protocols Feb 2, 2016
protocol30509.py Added additional protocols Feb 2, 2016
protocol30829.py Added additional protocols Feb 2, 2016
protocol30948.py Added additional protocols Feb 2, 2016
protocol31090.py Added additional protocols Feb 2, 2016
protocol31360.py Added additional protocols Feb 2, 2016
protocol31566.py Added additional protocols Feb 2, 2016
protocol31726.py Added additional protocols Feb 2, 2016
protocol31948.py Added additional protocols Feb 2, 2016
protocol32120.py Added additional protocols Feb 2, 2016
protocol32253.py Added additional protocols Feb 2, 2016
protocol32455.py Initial commit Dec 15, 2015
protocol32524.py Initial commit Dec 15, 2015
protocol33182.py Added missing protocols 33182, 33353, 33684, 37795 Feb 1, 2016
protocol33353.py Added missing protocols 33182, 33353, 33684, 37795 Feb 1, 2016
protocol33684.py Added missing protocols 33182, 33353, 33684, 37795 Feb 1, 2016
protocol34053.py Initial commit Dec 15, 2015
protocol34190.py Initial commit Dec 15, 2015
protocol34659.py Initial commit Dec 15, 2015
protocol34846.py Initial commit Dec 15, 2015
protocol35360.py Initial commit Dec 15, 2015
protocol35529.py Initial commit Dec 15, 2015
protocol35634.py Initial commit Dec 15, 2015
protocol35702.py Initial commit Dec 15, 2015
protocol36144.py Initial commit Dec 15, 2015
protocol36280.py Added additional protocols Feb 2, 2016
protocol36359.py Initial commit Dec 15, 2015
protocol36536.py Initial commit Dec 15, 2015
protocol36693.py Initial commit Dec 15, 2015
protocol37069.py Initial commit Dec 15, 2015
protocol37117.py Initial commit Dec 15, 2015
protocol37274.py Added protocol37274.py protocol39595.py Feb 1, 2016
protocol37351.py Initial commit Dec 15, 2015
protocol37569.py Initial commit Dec 15, 2015
protocol37795.py Added missing protocols 33182, 33353, 33684, 37795 Feb 1, 2016
protocol38236.py Initial commit Dec 15, 2015
protocol38500.py Initial commit Dec 15, 2015
protocol38593.py Initial commit Dec 15, 2015
protocol38793.py Initial commit Dec 15, 2015
protocol39015.py Added additional protocols Feb 2, 2016
protocol39153.py Initial commit Dec 15, 2015
protocol39271.py Initial commit Dec 15, 2015
protocol39445.py Initial commit Dec 15, 2015
protocol39595.py Added protocol37274.py protocol39595.py Feb 1, 2016
protocol39709.py Added protocol39709.py Jan 15, 2016
protocol39951.py Added protocol39951.py Jan 15, 2016
protocol40087.py Added protocol40087.py Jan 24, 2016
protocol40322.py Added protocol40322.py Jan 27, 2016
protocol40336.py Added protocol40336.py Jan 26, 2016
protocol40431.py Added protocol40431.py Feb 3, 2016
protocol40697.py Added protocol40697.py Feb 11, 2016
protocol40798.py Added protocol40798.py Feb 17, 2016
protocol41150.py Added protocol41150.py Mar 1, 2016
protocol41393.py Added protocol41393.py Mar 9, 2016
protocol41504.py Added protocol41504.py Mar 16, 2016
protocol41609.py Added protocol41609.py Mar 21, 2016
protocol41707.py Automated upload of generated Heroes Replay Protocol. (17.1.42178) Apr 13, 2016
protocol41764.py Automated upload of generated Heroes Replay Protocol. (17.1.42178) Apr 13, 2016
protocol41810.py Added protocol41810.py Mar 29, 2016
protocol42178.py Automated upload of generated Heroes Replay Protocol. (17.1.42178) Apr 13, 2016
protocol42273.py Automated upload of generated Heroes Replay Protocol. (17.2.42273) Apr 19, 2016
protocol42406.py Automated upload of generated Heroes Replay Protocol. (17.3.42406) Apr 21, 2016
protocol42506.py Automated upload of generated Heroes Replay Protocol. (17.4.42506) Apr 27, 2016
protocol42590.py Automated upload of generated Heroes Replay Protocol. (17.5.42590) May 4, 2016
protocol42742.py Automated upload of generated Heroes Replay Protocol. (18.3.42742) May 26, 2016
protocol42958.py Automated upload of generated Heroes Replay Protocol. (18.0.42958) May 18, 2016
protocol43051.py Automated upload of generated Heroes Replay Protocol. (18.1.43051) May 20, 2016
protocol43170.py Automated upload of generated Heroes Replay Protocol. (18.2.43170) May 25, 2016
protocol43259.py Automated upload of generated Heroes Replay Protocol. (18.3.43259) Jun 2, 2016
protocol43481.py Automated upload of generated Heroes Replay Protocol. (18.4.43481) Jun 7, 2016
protocol43527.py Automated upload of generated Heroes Replay Protocol. (18.4.43527) Jun 8, 2016
protocol43571.py Automated upload of generated Heroes Replay Protocol. (18.4.43571) Jun 14, 2016
protocol43905.py Automated upload of generated Heroes Replay Protocol. (18.5.43905) Jun 21, 2016
protocol44124.py Automated upload of generated Heroes Replay Protocol. (18.6.44124) Jun 29, 2016
protocol44256.py Automated upload of generated Heroes Replay Protocol. (19.0.44256) Jul 6, 2016
protocol44468.py Automated upload of generated Heroes Replay Protocol. (19.0.44468) Jul 12, 2016
protocol44737.py Automated upload of generated Heroes Replay Protocol. (19.1.44737) Jul 20, 2016
protocol44797.py Automated upload of generated Heroes Replay Protocol. (19.2.44797) Jul 21, 2016
protocol44941.py Automated upload of generated Heroes Replay Protocol. (19.3.44941) Jul 27, 2016
protocol45024.py Automated upload of generated Heroes Replay Protocol. (19.4.45024) Aug 1, 2016

README.md

Hero Protocol

heroprotocol is a reference Python library and standalone tool to decode Heroes of the Storm replay files into Python data structures.

Currently heroprotocol can decode these structures and events:

  • replay header
  • game details
  • replay init data
  • game events
  • message events
  • tracker events

heroprotocol can be used as a base-build-specific library to decode binary blobs, or it can be run as a standalone tool to pretty print information from supported replay files.

Note that heroprotocol does not expose game balance information or provide any kind of high level analysis of replays; it's meant to be just the first tool in the chain for your data mining application.

Supported Versions

heroprotocol supports all Hereos of the Storm replay files that were written with retail versions of the game. The current plan is to support all future publicly released versions, including public betas.

How to Use

A working installation of Python 2.x is required. From the folder where heroprotocol is located, type the following into the command line, assuming that the replay file was also copied into the same folder:

py heroprotocol.py --<option> "<replayFileName>" > output.txt

If you want the output shown directly in the terminal, leave out the > output.txt.

Example Usage

py heroprotocol.py --details "Blackheart's Bay.StormReplay" > output.txt

-- arguments

-h, --help Show the options that are available.

--gameevents print all game events including coordinates

--messageevents print message events such as ping events

--trackerevents print tracker events such as units killed, game stat events, score result event

--attributeevents print attribute events, a table of attrid, namespace, and attribute values

--header print protocol header including HotS build and elapsedGameLoops

--details print protocol details, e.g. teamId, player names and chosen heroes, player region, game result, observer status

--initdata print protocol initdata, e.g. interface settings for every player

--stats print game stats

Tracker Events

Some notes on tracker events:

  • Convert unit tag index, recycle pairs into unit tags (as seen in game events) with protocol.unit_tag(index, recycle)
  • Interpret the NNet.Replay.Tracker.SUnitPositionsEvent events like this:
    unitIndex = event['m_firstUnitIndex']
    for i in xrange(0, len(event['m_items']), 3):
        unitIndex += event['m_items'][i + 0]
        x = event['m_items'][i + 1] * 4
        y = event['m_items'][i + 2] * 4
        # unit identified by unitIndex at the current event['_gameloop'] time is at approximate position (x, y)
  • Only units that have inflicted or taken damage are mentioned in unit position events, and they occur periodically with a limit of 256 units mentioned per event.
  • NNet.Replay.Tracker.SUnitInitEvent events appear for units under construction. When complete you'll see a NNet.Replay.Tracker.SUnitDoneEvent with the same unit tag.
  • NNet.Replay.Tracker.SUnitBornEvent events appear for units that are created fully constructed.
  • You may receive a NNet.Replay.Tracker.SUnitDiedEvent after either a UnitInit or UnitBorn event for the corresponding unit tag.
  • In NNet.Replay.Tracker.SPlayerStatsEvent, m_scoreValueFoodUsed and m_scoreValueFoodMade are in fixed point (divide by 4096 for integer values). All other values are in integers.
  • There's a known issue where revived units are not tracked, and placeholder units track death but not birth.

License

Copyright (c) 2015 Blizzard Entertainment

Open sourced under the MIT license. See the included LICENSE file for more information.

Acknowledgements

The standalone tool uses mpyq to read mopaq files.

Thanks to David Joerg and Graylin Kim of GGTracker for design feedback and beta-testing of the s2protocol library that heroprotocol is based upon.

Thanks to Ben Barrett of HOTSLogs for feedback on and beta-testing of the heroprotocol library.