• Stars
    star
    608
  • Rank 72,124 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created about 11 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python library to decode StarCraft II replay protocols

S2 Protocol

Documentation Status

Build Status

s2protocol is a reference Python library and standalone tool to decode StarCraft II replay files into Python data structures.

Currently s2protocol can decode these structures and events:

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

s2protocol 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 s2protocol 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

s2protocol supports all StarCraft II 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.

Tracker Events

Some notes on tracker events:

  • Tracker events are new in version 2.0.8, they do not exist in replays recorded with older versions of the game.
  • 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 range(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) 2013 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.

Ports and Related Projects

There are unofficial ports of s2protocol (and the required MPQ parser) available in other languages:

Go

This Go implementation is a standalone project for both the MPQ parser and the s2protocol implementation (also provide some higher level API):

Go MPQ parser: https://github.com/icza/mpq

Go s2protocol: https://github.com/icza/s2prot

Java

This Java implementation is part of the open source Scelight project (which is much more than just a replay parser, it also gives a high-level API):

Java MPQ parser: https://github.com/icza/scelight/tree/master/src-app-libs/hu/belicza/andras/mpq

Java s2protocol: https://github.com/icza/scelight/tree/master/src-app/hu/scelight/sc2/rep/s2prot

More Repositories

1

s2client-proto

StarCraft II Client - protocol definitions used to communicate with StarCraft II.
Python
3,754
star
2

node-rdkafka

Node.js bindings for librdkafka
JavaScript
2,065
star
3

s2client-api

StarCraft II Client - C++ library supported on Windows, Linux and Mac designed for building scripted bots and research using the SC2API.
C++
1,646
star
4

api-wow-docs

Documentation for the World of Warcraft web APIs.
519
star
5

heroprotocol

Python library to decode Heroes of the Storm replays
Python
398
star
6

d3-api-docs

API Documentation for the D3 Web API.
HTML
341
star
7

passport-bnet

Passport Strategy for Battle.net Login
JavaScript
196
star
8

FailoverQueue

A thread-safe queue wrapper that can spill over to on-disk files for later processing.
C++
71
star
9

api-sc2-docs

API Documentation for the Sc2 Web API.
64
star
10

omniauth-bnet

Omniauth Strategy for Battle.net Login
Ruby
60
star
11

s2client-docker

Supporting files for building the API and running the Linux build of StarCraft II
Shell
52
star
12

node-signature-generator

A sample OAuth2 Client Credentials flow application using Blizzard Battle.net APIs in Node.js.
JavaScript
28
star
13

premake-blizzard

The blizzard module for premake
Lua
24
star
14

qt

Blizzard's additions/modifications to Qt5
22
star
15

qtbase

Qt5 qtbase submodule with Blizzard's changes
C++
15
star
16

premake-consoles

Lua
14
star
17

java-signature-generator

A sample OAuth2 Client Credentials flow application using Blizzard Battle.net APIs in Java.
12
star
18

katana-assets

Documentation and information on creating Asset API plugins for Foundry's Katana
9
star
19

clang

Fork of official clang git repository located at http://llvm.org/git/clang
C++
8
star
20

premake-autoconf

AutoConf tools for Premake
Lua
6
star
21

ruby-signature-generator

A sample OAuth2 Client Credentials flow application using Blizzard Battle.net APIs in Ruby.
Ruby
5
star
22

oauth-client-sample

Java
5
star
23

qtdeclarative

Qt5 qtdeclarative submodule with Blizzard's changes
C++
4
star
24

premake-packagemanager

Lua
3
star
25

qtmultimedia

Qt5 qtmultimedia submodule with Blizzard's changes
C++
2
star