GithubHelp home page GithubHelp logo

flipkick / gogsi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pinkuburu/gogsi

0.0 1.0 0.0 19 KB

A game state integration (GSI) library for Dota 2, written in Go.

License: MIT License

Go 100.00%

gogsi's Introduction

gogsi Build Status GoDoc Go report

go get github.com/mammothbane/gogsi

The Dota 2 client is capable of streaming JSON-formatted updates about the game to an arbitrary HTTP endpoint. This library listens to those updates and converts them to a Go representation that you can manipulate as convenient.

Usage

A barebones example might look like this:

package main

import "github.com/mammothbane/gogsi"

func main() {
	gogsi.Listen("localhost:3000", func(s *gogsi.State) error {
		if s.Added.Map.NightstalkerNight {
			/* adjust your phillips hue light, play a scary noise, update statistics, log something, etc. */
		}
		return nil
	})
}

The notion of change in the Dota 2 GSI is represented by the State.Added and State.Previous fields, so, as might be expected, this snippet responds to the value of Map.NightstalkerNight changing to true. Further detail about Added and Previous can be found in the docs.

Config

A sample configuration is provided below, set up to send all game updates to localhost:3000. Save it (along with any desired changes) to game/dota/cfg/gamestate_integration/gamestate_integration_[integration_name].cfg in order to register your integration with the Dota 2 client.

"Dota 2 Sample Integration"
{
	"uri"		"http://localhost:3000"
	"timeout"	"5.0"
	"buffer"  	"0.1"
	"throttle"	"0.1"
	"heartbeat"	"30.0"
	"data"
	{
		"provider"		"1"
		"map"			"1"
		"player"		"1"
		"hero"			"1"
		"abilities"		"1"
		"items"			"1"
		"allplayers"	"1"
	}	
}

The first line (the name of the integration) should be unique.

uri is the URI of your server (usually on localhost).

buffer is the amount of time (in seconds) for which the client should wait once it has a delta to send, collecting together all deltas in the meantime in order to reduce traffic. A value of "0" causes every delta to be sent as soon as it is available.

throttle is the minimum amount of time (in seconds) the client waits before sending a new delta after receiving a 2XX response from the server.

heartbeat specifies the maximum amount of time the client waits before sending an update, even if no events have occurred.

data options are more or less self-explanatory ("1" indicates that the game client should send updates about the given item, "0" indicates that it shouldn't).

Additionally, an auth block can be specified as follows:

"Dota 2 Sample Integration"
{
	// ...
	"auth"
	{
		"token" "an_auth_token"
	}
}

This token will be transmitted with every request as state.Auth.Token, so it's easiest to use as a shared key and/or unique ID per client for a remote gogsi instance.

These options are also covered in more detail at the CS: GO GSI page.

Notes and caveats

GSI does not begin sending updates until the first time the player loads into a game. Normally (and according to Valve's spec and various observations), the heartbeat is intended to be respected while in the client UI (i.e. not loaded into a game). This does not occur until after a game is loaded for the first time. I have also come across instances in testing where the client did not send GSI updates until the 0:00 horn in the first game.

On another note, this is not a scripting or hacking tool. Anyone looking for an easy way to break into the game should look somewhere else. The GSI is provided by Valve, and it does not allow any input. No information about other heroes or creeps is available, and position data is similarly not accessible.

Credits

This package was inspired by antonpup's C# implementation.

gogsi's People

Contributors

flipkick avatar mammothbane avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.