Version 12 (modified by 9 years ago) (diff) | ,
---|
Sc2Replay
Table of Contents
WARP currently supports the extraction of the following information from .SC2Replay files:
- Player name
- Player race
- Player color
- Game duration
- Game version
- Chat log
- Map preview
The following is a documentation of SC2Replay files.
WARNING: The file structure of SC2Replay files as state below is neither complete, nor completely correct! Refer to http://code.google.com/p/starcraft2replay/ for a better documentation. This site will be updated soon.
File Structure
SC2Replay files contain an mpq archive with 8 files. The archive starts at an offset of 1024 bytes. The types used in this documentation are:
Type | Description |
int8 | A single byte. |
int16 | Two bytes. |
int32 | Four bytes. |
string | One byte that represents the length of the following string. The string has as many characters, as the byte's value |
bytesX | A number of bytes whose functions and grouping are unknown, where X represents the number of bytes. |
All types are Big-Endian.
There is another type that will be called time offset. It is of variable length and describes the amount of time that has passed since the last action has occured. Time seems to be measured in something I will call time frames or just frames. 25 frames give a real second. Say you read a byte. If this byte has the flag 0b00000001 set, the time offset is followed by another byte. If the flag 0b00000010 set, it followed by another two bytes (not tested yet). It is likely that the time offset consists of two byte, if any of the 8 bits are set, though. Let a be the first byte you read that contains the flags and b be the second byte, then the value of the time offset t is calculated:
t = b + (a >> 2) * 255
replay.info
This file contains information about the players and the game in general. All offsets are relative to the described block, unless specified otherwise.
Players
The first part of this file simply stores the player names.
Offset | Type | Description |
0x00 | int8 | Number of player names that are contained in this block. This value usually is 0x10 i.e. 16. |
Now, for each player, the entry looks the following:
Offset | Type | Description |
0x00 | string | Player name. |
string | bytes5 | Function unknown. Always seems to be 0x00. |
Game settings
The player block is followed by:
Offset | Type | Description |
0x00 | bytes5 | Unknown. |
0x05 | string | Probably an indicator for a compression algorithm used somewhere. Always seems to be "Dflt". |
0x05+string | byte | This byte contains some flags. If the alliances in the game are locked, the rightmost bit is set. |
0x05+string+1 | byte | Function unknown. Always seems to be 0x00. |
0x05+string+2 | byte | Byte indicating the game speed. 0x00 = Slowest, 0x01 = Slow, 0x02 = Normal, 0x03 = Fast, 0x04 = Fastest |
0x05+string+3 | bytes11 | Function unknown. |
0x05+string+14 | string | Some kind of checksum or hash. Usually 76 bytes long (75 without the length indicator of the string). |
replay.game.events
This file stores all actions the players have ordered.
An action looks like the following:
Offset | Type | Description |
0x00 | time information | Gives information about the time offset of an action to the preceding action. Equivalent to the time information in the chat log. |
time information | byte | Unknown. |
time information + 1 | byte | Action code. |
time information + 2 | bytesX | Bytes storing information on the respective action. The size seems to depend on the action code. |
Action codes
Action codes are unique identifiers that distinguish one action from another. They are 1 byte long.
Known action codes are:
Action code | In-game action |
0x00 | Unknown action. Randomly appears after other actions. |
0x0B | Usage of any kind of ability or assignment of orders. Includes constructing buildings, training units, moving, attacking, gathering resources, and so on. |
0x0D | Group 0 |
0x1D | Group 1 |
0x2D | Group 2 |
0x3D | Group 3 |
0x4D | Group 4 |
0x5D | Group 5 |
0x6D | Group 6 |
0x7D | Group 7 |
0x8D | Group 8 |
0x9D | Group 9 |
0x81 | Movement of the screen. |
0x89 | Unknown action. |
0xAC | Selection or deselection. |
Group actions
Offset | Type | Description |
0x00 | byte | If the group is assigned, this byte's value is 0x00. If the group is selected, this byte's value is 0x02. |
0x01 | byte | Function unknown. Always seems to be 0x00. |
Select action
This action is not reliably documented. The length of the action varies.
Offset | Type | Description |
0x00 | byte | The currently selected subgroup with 0x00 being the first. |
0x01 | byte | Not fully documented! Selection index of the unit that is affected by this action. A value of 0x00 means that the newly selected unit is appended to the current selection. If the player's old selection will be discarded (read further), this should be 0x01. |
0x02 | byte | Byte containing flags. |
0x03 | byte | Byte containing flags. If 0b00000001 is set, the player's current selection will be discarded and the units described in this action will be the only units remaining in the player's new selection. If not set, the units of this action will be added to the player's selection. |
0x04 | byte | If this byte and the previous byte are 0x00, the action ends here. This only occurs, if units are deselected. Deselection in this case means that only some of the units in the player's current selection are deselected. In other words, if A is the player's current selection and B is the player's new selection, B is a subset of A. If this byte is not 0x00, however, it has something to do with the unit IDs. |
0x05 | byte | Function unknown. |
0x06 | byte | Function unknown. Probably an indicator for the selection type that occurred (left-click, shift-click, rectangle or ctrl-click). |
0x07 | byte | Number of units that will be added to the player's current selection. |
0x08 | byte | Function unknown. |
This "header" which provides general information for the selection is followed by the block for the newly selected units. Each unit is described as follows:
Offset | Type | Description |
0x00 | byte | Unit ID. |
0x01 | byte | Function unknown. |
0x02 | byte | Function unknown. |
0x03 | byte | Function unknown. Only present, if the unit is not the last unit of the select action. The exception is that it is present at the last unit entry, if the old selection is dicarded. |
Ability codes
To distinguish abilities or orders, a 3 byte identifier for each order is used. These 3 bytes will be called the "ability code".
Known ability codes are:
Ability code | Ability |
0x020400 | Stop |
0x020501 | Hold Fire |
0x020600 | Move |
0x020601 | Patrol |
0x020602 | Hold position |
0x020900 | Attack |
0x030A00 | Point Defense Drone |
0x040700 | Seeker Missile |
0x050500 | Set rally point |
0x050D00 | Stimpack (Marauder) |
0x050F00 | 250mm Strike Cannon |
0x060400 | Gather |
0x060401 | Return cargo |
0x060800 | Cancel |
0x060D00 | Build Command Center |
0x060D01 | Build Supply Depot |
0x060D02 | Build Refinery |
0x060D03 | Build Barracks |
0x060D04 | Build Engineering Bay |
0x060D05 | Build Missile Turret |
0x060D06 | Build Bunker |
0x060D08 | Build Sensor Tower |
0x060D09 | Build Ghost Academy |
0x060D0A | Build Factory |
0x060D0B | Build Starport |
0x060D0D | Build Armory |
0x060D0F | Build Fusion Core |
0x060F00 | Stimpack (Marine) |
0x070000 | Cloack (Ghost) |
0x070001 | Decloack (Ghost) |
0x070100 | Sniper Round |
0x070200 | Heal (Medivac) |
0x070300 | Siege Mode (Siege Tank) |
0x070400 | Tank Mode (Siege Tank) |
0x070500 | Cloack (Banshee) |
0x070501 | Decloack (Banshee) |
0x070600 | Load (Medivac) |
0x070602 | Unload all (Medivac) |
0x070800 | Yamato Cannon |
0x070900 | Assault Mode (Viking) |
0x070A00 | Fighter Mode (Viking) |
0x070C01 | Unload all (Command Center) |
0x070C04 | Load (Command Center) |
0x070D00 | Lift off (Command Center) |
0x070E00 | Land (Command Center) |
0x070F00 | Build Tech Lab (Barracks) |
0x070F01 | Build Reactor (Barracks) |
0x080100 | Build Tech Lab (Factory) |
0x080300 | Build Tech Lab (Starport) |
0x080700 | Train SCV |
0x080900 | Lower (Supply Depot) |
0x080A00 | Raise (Supply Depot) |
0x080B00 | Train Marine |
0x080B01 | Train Reaper |
0x080B02 | Train Ghost |
0x080B03 | Train Marauder |
0x080C01 | Train Siege Tank |
0x080C04 | Train Thor |
0x080C05 | Train Hellion |
0x080D00 | Train Medivac |
0x080D01 | Train Banshee |
0x080D02 | Train Raven |
0x080D03 | Train Battlecruiser |
0x080D04 | Train Viking |
0x080E00 | Upgrade Hi-Sec Auto Tracking |
0x080E01 | Upgrade Building Armor |
0x080E02 | Upgrade Infantry Weapons 1 |
0x080E03 | Upgrade Infantry Weapons 2 |
0x080E04 | Upgrade Infantry Weapons 3 |
0x080E06 | Upgrade Infantry Armor 1 |
0x080E07 | Upgrade Infantry Armor 2 |
0x080E08 | Upgrade Infantry Armor 3 |
0x080E05 | Upgrade Neosteel Frame |
0x080F03 | Research Nitro Packs |
0x090000 | Arm Silo with Nuke |
0x090100 | Research Stimpack |
0x090101 | Research Combat Shield |
0x090200 | Research Siege Tech |
0x090201 | Research Infernal Pre-Igniter |
0x090300 | Research Cloacking Field |
0x090302 | Research Caduceus Reactor |
0x090303 | Research Corvid Reactor |
0x090306 | Research Seeker Missiles |
0x090307 | Research Durable Materials |
0x090400 | Research Personal Cloacking |
0x090401 | Research Moebius Reactor |
0x090502 | Upgrade Vehicle Plating 1 |
0x090503 | Upgrade Vehicle Plating 2 |
0x090504 | Upgrade Vehicle Plating 3 |
0x090505 | Upgrade Vehicle Weapons 1 |
0x090506 | Upgrade Vehicle Weapons 2 |
0x090507 | Upgrade Vehicle Weapons 3 |
0x09050B | Upgrade Ship Weapons 1 |
0x09050C | Upgrade Ship Weapons 2 |
0x09050D | Upgrade Ship Weapons 3 |
0x090508 | Upgrade Ship Plating 1 |
0x090509 | Upgrade Ship Plating 2 |
0x09050A | Upgrade Ship Plating 3 |
0x0C0700 | Upgrade to Planetary Fortress |
0x0D0600 | Research Weapon Refit |
0x0D0601 | Research Behemoth Reactor |
0x0D0900 | Tac Nuclear Strike |
0x0D0C00 | EMP Round |
0x0F0400 | Auto-Turret |
Simply right clicking on an object in order to attack, gather resources, or move, depending on what is the default action, occupies a special ability code:
Ability code | Ability |
0xFFFF0F | Right click action |