Skip to content

Commit

Permalink
Merge pull request #61 from GetDotaStats/v3.1
Browse files Browse the repository at this point in the history
V4
  • Loading branch information
jimmydorry committed Nov 18, 2015
2 parents a6a6d43 + 1090d17 commit 5d8b504
Show file tree
Hide file tree
Showing 23 changed files with 1,476 additions and 919 deletions.
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,36 @@ There are three stages of integration. For a fast integration, please follow the
### Stage 1 - Before you begin

1. Grab a copy of the library via our public repo [GetDotaStats/stat-collection](https://github.com/GetDotaStats/stat-collection).
2. Login to http://getdotastats.com, by clicking the big green button at the top of this page.
3. Register your mod on the site by navigating to `Custom Games -> Mods (My Section) -> Add a new mod`, or by going straight to the registration form.
4. Go back to your list of mods by navigating to `Custom Games -> Mods (My Section)`, or by going straight to the My Mods page. You should now see a new entry there, that matches the mod your just registered.
2. Login to [http://getdotastats.com](http://getdotastats.com/), by clicking the big green button at the top of this page.
3. Register your mod on the site by navigating to `Custom Games -> Mods (My Section) -> Add a new mod`, or by going straight to the [registration form](http://getdotastats.com/#s2__my__mod_request).
4. Go back to your list of mods by navigating to `Custom Games -> Mods (My Section)`, or by going straight to the [My Mods](http://getdotastats.com/#s2__my__mods) page. You should now see a new entry there, that matches the mod your just registered.
5. Take note of your *modID* key of 32characters. If you lose this string, refer back to this page.
6. Make sure not to share this key, as it is unique to your mod and is used when recording stats!<br>If you use Github, add a .gitignore file to the root of your project. Adding **`settings.kv`** to it will prevent from accidentally leaking your *modID*.
7. An Admin will review your mod registration and approve it if it meets the submission guidelines outlined on the registration page. While your mod is reviewed, you can continue following this guide.
6. Make sure not to share this key, as it is unique to your mod and is used when recording stats!<br>If you use Github, add a `.gitignore` file to the root of your project. Adding **`settings.kv`** to it will prevent from accidentally leaking your *modID*.
7. An Admin will review your mod registration and approve it if it meets the submission guidelines outlined on the registration page and has a few completed games recorded. While your mod is reviewed, you can continue following this guide.

### Stage 2 - Basic Integration

Now that you have the library and have completed the sign-up process, we can start the actual integration.

1. Merge the files downloaded in (Stage 1 - Step 1). If done successfully, you will see a statcollection folder in your **`game/YOUR_ADDON/scripts/vscripts`** folder.
2. In your addon_game_mode.lua file, add a require statement at the top of your code that points at our library initialiser file. **`require("statcollection/init")`**
3. Go into the scripts/vscripts/statcollection folder and inside the settings.kv file, change the modID XXXXXXX value to the modID key you noted above (Stage 1 - Step 4).
4. Check your game logic to ensure you set player win conditions nicely. This library hooks the SetGameWinner() function, so make sure to convert all of your `MakeTeamLose()` calls into `SetGameWinner(`) calls. Also make sure to check every win and lose condition, as this library will only send stats at POST_GAME after a winner has been declared.
1. Merge the files downloaded in (Stage 1 - Step 1). If done successfully, you will see a statcollection folder in your **`game/YOUR_ADDON/scripts/vscripts`** folder. Pay attention to the included panorama files. They should be merged into content/YOUR_ADDON/panorama folder.
2. In your **`addon_game_mode.lua`** file, add a require statement at the top of your code that points at our library initialiser file. **`require("statcollection/init")`**
3. Go into the **`scripts/vscripts/`** folder and inside the settings.kv file, change the modID XXXXXXX value to the modID key you noted above (Stage 1 - Step 4). If your mod requires rounds, skip to Stage 2.5 in these instructions. If you can possibly help it, we advise modders to avoid using rounds.
4. Check your game logic to ensure you set player win conditions nicely. This library hooks the SetGameWinner() function, so make sure to convert all of your MakeTeamLose() calls into SetGameWinner() calls. Also make sure to check every win and lose condition, as this library will only send stats at POST_GAME after a winner has been declared.
5. Test your custom game (via workshop tools is fine), and see if stats were recorded. You can find games recently recorded against your steamID by navigating to `Custom Games -> Public Profile (My Section)`, or by going straight to your Public Profile.
8. You have completed the basic integration successfully if your games are recorded with a Phase value of 3 or higher (a column in the tables on both pages). If you don't see any recorded games, or they are not reaching Phase 3, refer to the troubleshooting section below.
7. Update your `settings.kv` by setting **"TESTING"** to *false*, and the **"MIN_PLAYERS"** to the minimum number of players required to have a proper game.
6. You have completed the basic integration successfully if the games recorded under your mod on the [RECENT GAMES](http://getdotastats.com/#s2__recent_games) page (or in your public profile) have a green phase value. If you don't see any recorded games, or they are not reaching the green phase, refer to the troubleshooting section below.
7. Update your settings.kv by setting TESTING to false, and the "MIN_PLAYERS" to the minimum number of players you believe are required to have an interesting (playable) game. Only set TESTING to true, when troubleshooting stats in your workshop tools.

### Stage 2.5 - Basic Integration for Round Based Games

Skip this section if your game is not round based. Implementing round based stats is not for the faint of heart. You will need the ability to think critically, and hopefully understand how the logic in your game works.

1. Your mod should already have our library files merged from Stage 2 - Step 1. If not, go back and do that now.
2. Go into the **`scripts/vscripts/statcollection`** folder and inside the settings.kv file. Set HAS_ROUNDS to true and both of the win conditions (GAME_WINNER and ANCIENT_EXPLOSION) to false.
3. In your game logic, call statCollection:submitRound(false) at the end of every round. At the end of the final round, call statCollection:submitRound(true). Make sure to update line 108 in the schema.lua (for local current_winner_team), as we have no generic way of determining who won your arbitrary round.
4. Double check your game logic to ensure you properly indicate which teams won each round, and that it is recorded in line 108 of **`schema.lua`**
5. Test your custom game (via workshop tools is fine), and see if stats were recorded. You will need to play your game all the way through (up to your win or lose condition), unless you created a way to skip to the end of the game. You can find games recently recorded against your steamID by navigating to `Custom Games -> Public Profile (My Section)`, or by going straight to your Public Profile.
6. You have completed the basic integration (for rounds) successfully if the games recorded under your mod on the [RECENT GAMES](http://getdotastats.com/#s2__recent_games) page (or in your public profile) have a green phase value. If you don't see any recorded games, or they are not reaching the green phase, refer to the troubleshooting section below.
7. Update your **`settings.kv`** by setting TESTING to false, and the "MIN_PLAYERS" to the minimum number of players you believe are required to have an interesting (playable) game. For most games, this will be a value of 2 or 4. Only set TESTING to true, when troubleshooting stats in your workshop tools, as this setting overrides MIN_PLAYERS to 0 and prints your schema stats (Stage 3) to console.

### Stage 3 - Advanced Integration **OPTIONAL**

Expand Down Expand Up @@ -99,11 +111,12 @@ Now that you have the library and have completed the sign-up process, we can sta
**My custom game never reaches Phase 3!**
* Have a look in your console log for an error.
* Check your win conditions. We hook SetGameWinner(), so make sure you don't use MakeTeamLose().
**I am in despair! Help me!**
* Contact us via one of our numerous channels of contact. You can find the official list on [our site](http://getdotastats.com/#site__contact)

### Implementations
- Noya [PMP] - https://github.com/MNoya/PMP
- Noya [Warchasers] - https://github.com/MNoya/Warchasers
- Azarak [The Predator] - http://steamcommunity.com/sharedfiles/filedetails/?id=494708836

### Recent Games
- Reported on the site: http://getdotastats.com/#s2__recent_games
Expand All @@ -112,7 +125,7 @@ Now that you have the library and have completed the sign-up process, we can sta
### Credits
- Big thanks to [SinZ163](https://github.com/SinZ163), [Noya](https://github.com/MNoya/), [Ash47](https://github.com/Ash47), [BMD](https://github.com/bmddota), and [Tet](https://github.com/tetl) for their contributions.is

### Contact
### Contact
- You can get in contact with us via Github issues, or via other methods http://getdotastats.com/#site__contact
- This repo should contain all of the code required to get stats working. It should work out of the box, but will require modification if you want record additional stats.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use strict";

function OnClientCheckIn(args) {

var payload = {
modIdentifier: args.modID,
steamID32: GetSteamID32(),
matchID: args.matchID,
schemaVersion: args.schemaVersion
};

$.Msg('Sending: ', payload);

$.AsyncWebRequest('http://getdotastats.com/s2/api/s2_check_in.php',
{
type: 'POST',
data: {payload: JSON.stringify(payload)},
success: function (data) {
$.Msg('GDS Reply: ', data)
}
});
}

function GetSteamID32() {
var playerInfo = Game.GetPlayerInfo(Game.GetLocalPlayerID());

var steamID64 = playerInfo.player_steamid,
steamIDPart = Number(steamID64.substring(3)),
steamID32 = String(steamIDPart - 61197960265728);

return steamID32;
}

(function () {
$.Msg("StatCollection Client Loaded");

GameEvents.Subscribe("statcollection_client", OnClientCheckIn);

})();
File renamed without changes.
Loading

0 comments on commit 5d8b504

Please sign in to comment.