Game State Integration Intro
Game State Integration (GSI) is a powerful feature integrated into Counter-Strike: Global Offensive and Dota 2. It enables the sending of real-time updates of the game state to services, which can be harnessed to create applications that integrate deeply with the current state of the game.
Although GSI is officially launched for Counter-Strike: Global Offensive, there is no official information or release for its use in Dota 2. Despite this, people have still found ways to use GSI in Dota 2.
How does it work?
When GSI is enabled, the game client sends HTTP POST requests to all registered services. These requests contain information specified by the service’s configuration and the content-type of the body is JSON. During gameplay, the information is limited to the player’s or observer’s role to prevent cheating. Observers can access more information than players.
This setup is convenient because it utilizes commonly used components, such as a web server and JSON, which are compatible with most programming languages.
GSI supports both local and remote URIs, making it suitable for debugging purposes before launching a production system.
How do you enable it?
Enabling GSI is a two-step process. First, you need to instruct the game client to enable GSI by following these steps:
- Open Steam and navigate to your library.
- Right-click on Dota 2 and select
Properties
. - Click on the
General
tab. - In the
Launch Options
field, enter-gamestateintegration
.
Next, you need to create a configuration file that the game client can parse. Here’s how to do it:
- Navigate to your Dota 2 directory for example:
YOUR_STEAM_DIRECTORY\steamapps\common\dota 2 beta\game\dota\cfg\gamestate_integration\
. - Create a file with a name starting with
gamestate_integration_
and ending with.cfg
. For example,gamestate_integration_my_service.cfg
.
Here is an example configuration file:
|
|
This file specifies the following:
uri
: Where the data will be sent.timeout
: After how long time the game will consider it a timeout if no HTTP 2XX response has been received.buffer
: Combine game events during this duration, to reduce the number of requests.throttle
: Limit how often the game will send a request.heartbeat
: Even if there is no game data update, the service will be pinged after this duration. A good way to detect disconnects.data
: The data that the service signs up for.auth
: A token that can be used for authentication.
Additional and more in-depth information can be found at CS:GO GSI.
Dota 2 appears to search for new configuration files each time a match starts.
However, it does not allow updates to the configuration for an already configured uri
unless you restart the game client.
To add comments, use //
and anything following it will be ignored until a line break occurs.
In order to enable data sharing, you’ll need to set the value of the specific data to 1
.
The auth section is included in every request, both for local and remote uri’s. When dealing with remote uri’s, this is a great way to ensure that only authorized clients can send data to the specified service. As with the submission of any credentials, it is essential that this information is sent over HTTPS to prevent any possibility of a MITM (man-in-the-middle) attack.
Where is GSI used?
- Steelseries GG application use it to control LEDs as well as present info on displays.
- The Twitch overlay Dota 2 Tooltips for streamers which allows viewers to see tooltips of abilities and items.
- Pyrotechnics and stage integrations at offline events for Counter-Strike:Global Offensive and Dota 2.
- Changing player camera during events when the observer changes player view.
Performance impact?
Currently, GSI requires an active opt-in to be used. However, prior to March 2022, it was not necessary to specify the launch option. It makes me wonder if this change is related to peripheral companies, such as Steelseries and Logitech, requesting excessive data too frequently, simply to update some LEDs since it will impact performance.
All additional work will require extra computation, as noted by JJLiebig in this tweet.
Additional reading and sources
The majority of information regarding GSI in Dota 2 has been extracted based on the documentation for Counter-Strike: Global Offensive and via debugging. For more in-depth information, I recommend scanning through the following links.
- Official GSI documentation for CS:GO Can help you understand general GSI concepts, very in-depth.
- JavaScript GSI server for Dota 2
- C# GSI server for Dota 2
- Kotlin GSI server for Dota 2
- Rust GSI server for Dota 2
- Valve .cfg info