demoinfocs-golang - A CS:GO Demo Parser
Is a Go library for super fast parsing and analysing of Counter Strike: Global Offensive (CS:GO) demos (aka replays). It is based on Valve's demoinfogo and SatsHelix's demoinfo.
Discussions / Chat
You can use gitter to ask questions and discuss ideas about this project.
Requirements
This library is intended to be used with go 1.11
or higher as it is built using Go modules.
It's recommended to use modules for consumers as well if possible.
If you are unfamiliar with Go modules there's a list of recommended resources in the wiki.
Go Get
go get -u github.com/markus-wa/demoinfocs-golang
Example
This is a simple example on how to handle game events using this library.
It prints all kills in a given demo (killer, weapon, victim, was it a wallbang/headshot?) by registering a handler for events.Kill
.
Check out the godoc of the events
package for some information about the other available events and their purpose.
package main
import (
"fmt"
"os"
dem "github.com/markus-wa/demoinfocs-golang"
events "github.com/markus-wa/demoinfocs-golang/events"
)
func main() {
f, err := os.Open("/path/to/demo.dem")
if err != nil {
panic(err)
}
defer f.Close()
p := dem.NewParser(f)
// Register handler on kill events
p.RegisterEventHandler(func(e events.Kill) {
var hs string
if e.IsHeadshot {
hs = " (HS)"
}
var wallBang string
if e.PenetratedObjects > 0 {
wallBang = " (WB)"
}
fmt.Printf("%s <%v%s%s> %s\n", e.Killer, e.Weapon, hs, wallBang, e.Victim)
})
// Parse to end
err = p.ParseToEnd()
if err != nil {
panic(err)
}
}
Sample output
Running the code above will print something like this:
xms <AK-47 (HS)> crisby
tiziaN <USP-S (HS)> Ex6TenZ
tiziaN <USP-S> mistou
tiziaN <USP-S (HS)> ALEX
xms <Glock-18 (HS)> tiziaN
...
keev <AWP (HS) (WB)> to1nou
...
More examples
Check out the examples folder for more examples, like how to generate heatmaps like this one:
Features
- Game events (kills, shots, round starts/ends, footsteps etc.) - docs / example
- Tracking of game-state (players, teams, grenades, ConVars etc.) - docs
- Grenade projectiles / trajectories - docs / example
- Access to entities, server-classes & data-tables - docs / example
- Access to all net-messages - docs / example
- Chat & console messages 1 - docs / example
- POV demo support 2
- Easy debugging via build-flags
- Built with performance & concurrency in mind
- Only for some demos; in MM demos the chat is encrypted for example.
- Only partially supported (as good as other parsers), some POV demos seem to be inherently broken
Performance / Benchmarks
Two of the top priorities of this parser are performance and concurrency.
Here are some benchmark results from a system with an Intel i7 6700k CPU and a SSD disk running Windows 10 and a demo with 85'000 frames.