evido / wotreplay-parser

This project aims to create a parser of the World of Tanks replay files. The result is a list of decoded packets, which can be transformed into an image, a heatmap or json file.
BSD 3-Clause "New" or "Revised" License
107 stars 25 forks source link
world-of-tanks wot

World of Tanks Replay Parser

What?

This program aims to decode replay files and convert them into more accessible formats such as an image or json files. Which may be uses in other programs. The alternative project wotreplay-viewer implements a small HTML5 viewer for the JSON data.

When using the json output option, the replay is decoded into a list of packets, in the same way it is described in the replay file. The following information can be extracted from from the replay.

Examples

Output type PNG

Displays a summary of the battle on a map, green lines are your own team, red lines the enemy team, and blue is the recording player.

Output example of type 'png'

Output type GIF

Displays an animation of the battle on the map.

Output example of type 'gif'

Output type HEATMAP

Displays a heatmap of the positions of the tanks in the battle (for both teams combined)

Output example of type 'heatmap'

Output type Team Heatmap

Displays a heatmap of the positions of the tanks in the battle (colored by team)

Output example of type 'team-heatmap'

Output type Team Heatmap (Soft)

Displays a heatmap of the positions of the tanks in the battle (colored by team), with some smoothing applied.

Output example of type 'team-heatmap-soft'

Output type Class Heatmap

Output example of type 'class-heatmap'

Displays a heatmap of the positions following user defined classes.

Download

Build

Dependencies

Compiler Support

Compile

Unix

git clone https://github.com/evido/wotreplay-parser.git
cd wotreplay-parser
cmake .
make

You may need to specify the include directory for LibXML2 using the CMAKE variable INCLUDE_DIRECTORIES. This can be done as following.

cmake -DINCLUDE_DIRECTORIES="/usr/include/libxml2" .

Debian like Linux

You may need to install the following packages in order to compile successfully (tested ok on an Ubuntu 20.04 install):

sudo apt-get install build-essential libboost-all-dev git cmake libpng-dev libcrypt-dev libssl-dev libgd-dev libtbb-dev

Win32

Binaries can be built using VS2019 (using MSVC 2015 build tools).

Data

To use this software you need some data extracted from World of Tanks, this data contains some elements to draw the mini map, the actual minimaps and the arena definitions. I have prepared an archive which is available here. This should be available in the root folder (see next paragraph).

Run

Decode Replays

The program can be used to convert wotreplay files to images or json files.

wotreplay-parser --parse --root <working directory> --type <output type> --input <input file> --output <output file>

Create Heatmaps

The program can be used to create heatmaps for a directory of replays

wotreplay-parser --parse --root <working directory> --type heatmap --input <input directory> --output <output directory>

Create Minimaps

The program can also be used to create all the minimaps for usage in wotreplay-viewer.

wotreplay-parser --create-minimaps --root <working directory> --output <output directory>

Rules

The syntax of drawing rules is as follows (EBNF syntax)

rules = rule *(';' rule)
rule = color ':=' expression
expression = operation *(logical_operator operation)
operation = operand comparison operand
operand = symbol | value
logical_operator = 'and' | 'or'
comparison = '=' | '!=' | '>' | '<' | '>=' | '<='
color = '#' hex{6}
symbol = 'player' | 'clock' | 'team' | 'tank_name' | 'tank_country' | 'tank_tier' | 'tank_icon' | 'tank_class'
value = ''' +(digit | alpha | '_' | '-' ) '''

Each packet is evaluated using the defined rules and assigned a class (first match), which will be used in the resulting heatmap.

Packet Overview

Type 0x03

This packet is related to the spotting of tanks, it will occurr together with packet type 0x05 when the tank appears for the user (each time).

Type 0x05

See packet type 0x03

Type 0x07

Sub Type 0x05

This packet seems to be a health update which is sent relatively frequently, it only contains the following properties.

Sub Type 0x07

This packet seems to be sent when a player's tracks are repaired, it also indicates which track is still destroyed.

Type 0x08

Sub Type 0x01

This packet indicates a player doing damage to another player and will most likely be accompanied by another packet indicating the type of damage such as Sub Type 0x05

Sub Type 0x05

This packet indicates that a player was shot by another player. When this is not accompanied by a damage packet, the player bounced the shell.

Sub Type 0x0B

Most likely the indicator of a module being damaged.

Sub Type 0x11

Indicator that a shot was fired by a player.

Sub Type 0x17

Unclear.

Type 0x0A

This is the most frequent type of packet, it tells the player about the positions of any other player.

Type 0x23

This packet contains a message sent to the battlelog during the game. The owner information is encoded inside the message.

<font color='#DA0400'>SmurfingBird[RDDTX] (VK 36.01 H)&nbsp;:&nbsp;</font><font color='#FFFFFF'>so far so good</font>

Type 0x20

This packet indicates that a player's tank was tracked.

License

All code is licensed under the permissive BSD license.