Using game events in your app
Overwolf supports events for multiple games, and for each supported game, there are many game events: kills, deaths, victories, damage caused, gold spent, and many others.
The full list of supported games with their Game ID’s is always up to date and can be found here.
In this guide, we'll discuss the different types of Overwolf game events features, how to register to these game events, and how to consume them from your OW app, using the overwolf.games.events API.
If you like to get general info updates about the currently running game, like process name, focus, command line info, you can use the overwolf.games API. You don't even have to register for features and real-time game events.
Features Overview
Each supported game has its own set of available features. A feature is a category of related game events, for example 'Match Start', 'Match End', 'Match Outcome' are all events belonging to the Match feature.
You can review the supported features for each game in the relevant game page found on the sidebar menu, for example, the League of Legends page.
Feature types
Each feature is broken down into two entity types: info updates and events.
Info Updates
– game information changes that define the game’s current status.
For example - a match is currently taking place.Events
– specific events that happen in the game.
For example - You just got killed.
A single feature can contain multiple info updates and events.
On the next clause, you are going to learn how to register to features and listen to events or info updates.
feature example: "Death" feature in LoL
The "Death" feature in League of Legends has a:
"death" event, which fires when the player's champion died.
"deaths" info update, holds a counter for the total number of player deaths in the current session.
How to register to features
To make sure the data you have is full and consistent, please follow these steps in order:
1. Update your manifest file
set the relevant game events
The first step is to declare the game for which your app wants to register features.
The declaration is made by adding the game’s class ID under the game_events section in your manifest.json.
This property is an array of game class ids that the app wants to register for.
Note that a single app can register for multiple games, but there is no wildcard support, so even if your app wants to consume events from all the supported games, you should set each one of them.
This is how the value would look like if the app is interested in receiving events for LoL and CS:GO:
"data":{
"game_events":[5426, 7764]
...
}
This field define from which games exactly your app should receive real-time game events like kill, death, etc. If you don't need real-time game events and just want to get general game info and state for the current running game, you can leave this field (game_events
) even empty, and use the overwolf.games API.
set the overlay permissions
The second step is to set the game IDs that your app targeted and permitted to display in-game overlay windows on them
This is how the value would look like if the app is interested in displaying an in-game overlay for LoL and CS:GO:
"game_targeting": {
"type": "dedicated",
"game_ids": [5426, 7764]
}
set auto-launch
If you like, you can define a list of games triggering the app to launch, using the launch_events manifest property.
This is how the value would look like if the app is interested to auto-launching for LoL and CS:GO:
"launch_events": [{
"event": "GameLaunch",
"tracked": false,
"event_data": {
"game_ids": [5426, 7764],
"wait_for_stable_framerate": 30
},
"start_minimized": true
}]
Along with the option to launch your app when a specific game is started (or launch with all games), you can launch your app when the OW client launches.
2. Listen to info updates or events
We mentioned above that each feature is broken down into two entity types: info updates and events.
The next step is to add a listener to the relevant entity type in your code.
Listen to game events
You can receive this entity type by registering to the overwolf.games.events.onNewEvents event listener.
Listen to info updates
You can receive this entity type by registering to the overwolf.games.events.onInfoUpdates2 event listener.
To get all the current info state and all the info-updates that happend BEFORE you registered to this event listener, make sure to call overwolf.games.events.getInfo(). Read more about it on chapter 4.
3. Call setRequiredFeatures()
The final step is to call overwolf.games.events.setRequiredFeatures. Once the app wants to start receiving specific info updates and events, you call this function with an array of feature names that you would like your app to use.
This is an example when an app requires Rocket League features:
overwolf.games.events.setRequiredFeatures(['stats', 'match'], function(info) {
console.log(info);
});
4. Get current info state
In some cases, you might add the listener to onInfoUpdates2 or to onNewEvents AFTER the info update has already happened so that the app will miss the info-update event.
Also, you might want to receive all info updates that happened before setRequiredFeatures() succeeded.
For those reasons, as a final step, you should call overwolf.games.events.getInfo() to get the current info state.