overwolf.games.events

General

overwolf.games.events allows you to be notified when something interesting happens while playing a certain game (e.g. a hero killed someone, someone killed the gamer’s hero, etc.). Overwolf supports events for multiple games, you can see the list of supported games on the side menu.

Each supported game has its own set of available features.

A feature is a collection of related game events (e.g events related to a “match” feature – ‘started’/’ended’/’outcome’, etc.). You can view the features of each supported game in the relevant game page on the side menu, for example, League of Legends page.

 

A feature is further broken down into two entity types:

  1. Info Updates – game information changes that define the game’s current state (e.g. the match is currently taking place)
  2. Events – volatile events that happen in the game (e.g. player just got killed)

So a feature is a collection of related info updates and events.

When an app wants to receive specific info updates and events, it registers itself to the relevant (containing) features via the overwolf.games.events.setRequiredFeatures() function.

How to register for features

The first step is to declare which game the app wants to register features for. The declaration is done by adding the game’s class id under data.game_events in the manifest.json. This property is an array of game class ids that the app wants to register for (it can register to multiple games).
This is how the value would look like if the app is interested in receiving events for League of Legends and CS:GO:

     "data":{     
      "game_events":[5426, 7764],
      ... 
   }

The next step is to add a listener to the relevant JavaScript Event object in your app’s code:

  1. overwolf.games.events.onInfoUpdates2 – to receive info update changes (notice the 2 at the end of the event name).
    overwolf.games.events.onInfoUpdates2.addListener(function(infoUpdateChange) { … })
  2. overwolf.games.events.onNewEvents – to receive new events.
    overwolf.games.events.onNewEvents.addListener(function(newEvents) { … })

The final step is to call overwolf.games.events.setRequiredFeatures once the app wants to start receiving info updates and events. You call this function with an array of feature names that you would like your app to consume.

Sample App

Here’s an example of using the overwolf.games.events to be notified whenever an interesting event has happened in League of Legends.

Methods

setRequiredFeatures(features, callback)

Version added: 0.93.1

Sets the required features from the provider.

Example for setting League of Legends required features:

var g_interestedInFeatures = [
  'summoner_info',
  'gameMode',
  'teams',
  'matchState',
  'spellsAndAbilities',
  'deathAndRespawn',
  'kill',
  'assist',
  'minions'
];

function setFeatures() {
  overwolf.games.events.setRequiredFeatures(g_interestedInFeatures, function(info) {
    if (info.status == "error")
    {
      //console.log("Could not set required features: " + info.reason);
      //console.log("Trying in 2 seconds");
      window.setTimeout(setFeatures, 2000);
      return;
    }

    console.log("Set required features:");
    console.log(JSON.stringify(info));
  });
}

 

  • Parameter: features <string[]>

    The required features.

  • Parameter: callback <function>

Callback argument:
{  
   "status":"success",
   "supportedFeatures":[  
      "summoner_info",
      "teams",
      "kill"
   ]
}

getInfo(callback)

Version added: 0.95

Gets the current game info.

  • Parameter: callback <function>

Callback argument:
{  
      "status":"status",
      "res":{  
         "summoner_info":{  
            "id":"79489298",
            "name":"itaygl",
            "region":"EUW",
            "champion":"Rengar"
         },
         "game_info":{  
            "match_started":"True",
            "matchStarted":"True",
            "teams":"%5B%7B%22team%22:%22100%22,%22champion%22:%22Rengar%22,%22skinId%22:%220%22,%22clientId%22:%220%22,%22summoner%22:%22itaygl%22%7D%5D",
            "gameMode":"custom",
            "game_mode":"custom",
            "minionKills":"5",
            "minions_kills":"5",
            "gold":"1002"
         },
         "features":{  
            "kill":"True",
            "assist":"True",
            "minions":"True",
            "deathAndRespawn":"True",
            "death":"True",
            "minion":"True",
            "gold":"True",
            "level":"True",
            "abilities":"True",
            "gameMode":"True",
            "game_mode":"True"
         },
         "level":{  
            "level":"3"
         }
      }
   }

Events How to use events

onError

Version added: 0.78

Fired when there was an error in the game events system.

onInfoUpdates2

Version added: 0.96

Fired when there are game info updates with a JSON object of the updates.

Event value:
{  
   "info":{  
      "game_info":{  
         "minionKills":"3"
      }
   },
   "feature":"minions"
}

onNewEvents

Version added: 0.96

Fired when there are new game events with a JSON object of the events information.

Event value:
{
  "events": [
    {
      "name": "death",
      "data": "{"count": "2"}"
    }
  ]
}