diff --git a/README.md b/README.md index 8a7d615..d25adee 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Pulse is a clientside mod for [TF|2 + Northstar](https://github.com/R2Northstar/ Want to know what we have planned for future updates? See [here.](https://github.com/ToneAPI/pulse/projects?query=is%3Aopen) -Found a bug? Make an issue on Github [here.](https://github.com/ToneAPI/pulse/issues/new) +Found a bug? Make an issue on GitHub [here.](https://github.com/ToneAPI/pulse/issues/new)
Features, more in-depth: @@ -36,7 +36,7 @@ Found a bug? Make an issue on Github [here.](https://github.com/ToneAPI/pulse/is | Name | Description | |--------------------|------------------------------------------------------| - | Pilots |Shows **ALL KILLS** accumulated by player as Pilot. Differentiating Pilot and Titan kills will come in a later Tone API update.| + | Pilots |Shows **ALL KILLS** accumulated by player as Titan. Differentiating Pilot and Titan kills will come in a later Tone API update.| | Titans |Non-functional, see line above.| | Titan executions |Shows only executions accumulated by player as Titan.| | Pilots meleed |Shows only melee kills accumulated by player as Titan.| diff --git a/mod.json b/mod.json index 452d536..6113565 100644 --- a/mod.json +++ b/mod.json @@ -1,12 +1,28 @@ { "Name": "ToneAPI.pulse", "Description": "Displays Tone API kill data in the Stats tab.", - "Version": "1.2.0", + "Version": "1.2.1", "LoadPriority": 1, "ConVars": [ { "Name": "ToneURL", "DefaultValue": "https://tone.sleepycat.date/v2/client" + }, + { + "Name": "VersionURL", + "DefaultValue": "https://raw.githubusercontent.com/ToneAPI/pulse/main/version.json" + }, + { + "Name": "MajorVersion", + "DefaultValue": "1" + }, + { + "Name": "MinorVersion", + "DefaultValue": "2" + }, + { + "Name": "PatchVersion", + "DefaultValue": "1" } ], "Scripts": [ diff --git a/mod/scripts/vscripts/pulse.gnut b/mod/scripts/vscripts/pulse.gnut index 48efca0..c0cc1bf 100644 --- a/mod/scripts/vscripts/pulse.gnut +++ b/mod/scripts/vscripts/pulse.gnut @@ -1,5 +1,6 @@ global function pulseInit global function GetWeaponStatsFromToneAPI +global function GetGlobalDataFromToneAPI global function GetMapStatsFromToneAPI global function GetGamemodeStatsFromToneAPI global function getWeaponKillsFromToneAPI @@ -19,10 +20,13 @@ global table globalToneAPIMapDistData = {} global table globalToneAPIMapKillData = {} global table globalToneAPIMapMDistData = {} global table globalToneAPIGamemodeData = {} +global table globalToneAPIAllPlayerKillData = {} +global table globalToneAPIAllPlayerDeathData = {} global table< table > globalToneAPIGamemodeMapData = {} string prefix = "default" string HTTPrequestURL = "default" +string currentVersion = "default" int weaponEntries = 0 int mapEntries = 0 int gamemodeEntries = 0 @@ -30,9 +34,26 @@ int mapGamemodeEntries = 0 void function pulseInit() { - HTTPrequestURL = GetConVarString("ToneURL") prefix = "\x1b[38;2;255;178;102m[PULSE]\x1b[0m " - print(prefix + "v1.2.0 has been loaded.") + HTTPrequestURL = GetConVarString("ToneURL") + currentVersion = "v" + GetConVarString("MajorVersion") + "." + GetConVarString("MinorVersion") + "." + GetConVarString("PatchVersion") + HttpRequest getVersion + getVersion.method = HttpRequestMethod.GET + getVersion.url = GetConVarString("VersionURL") + void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) + { + table JSONDecoded = DecodeJSON(response.body) + if (JSONDecoded["Major"] == GetConVarString("MajorVersion") && JSONDecoded["Minor"] == GetConVarString("MinorVersion") && JSONDecoded["Patch"] == GetConVarString("PatchVersion")) { + print(prefix + currentVersion + " has been loaded and is up to date.") + } else { + print(prefix + currentVersion + " has been loaded. Recommend updating to latest version: v" + JSONDecoded["Major"] + "." + JSONDecoded["Minor"] + "." + JSONDecoded["Patch"] + ".") + } + } + void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure) + { + print(prefix + currentVersion + " has been loaded and has encountered an error getting latest version data.") + } + NSHttpRequest(getVersion, onSuccess, onFailure) } void function GetWeaponStatsFromToneAPI() @@ -65,6 +86,35 @@ void function GetWeaponStatsFromToneAPI() NSHttpRequest(getWeaponStats, onSuccess, onFailure) } +void function GetGlobalDataFromToneAPI() +{ + print(prefix + "Getting global data...") + weaponEntries = 0 + HttpRequest getGlobalStats + getGlobalStats.method = HttpRequestMethod.GET + getGlobalStats.url = HTTPrequestURL + "/weapons" + getGlobalStats.queryParameters["player"] <- ["!" + NSGetLocalPlayerUID()] + void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) + { + print(prefix + "Global data received, processing...") + table JSONForConversion = DecodeJSON(response.body) + foreach (var key, var value in JSONForConversion) { + table test = expect table(value) + globalToneAPIAllPlayerKillData[string(key)] <- test.kills + globalToneAPIAllPlayerDeathData[string(key)] <- test.deaths + weaponEntries += 1 + } + print(prefix + "Global data has been processed with a total of " + string(weaponEntries) + " entries.") + } + + void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure) + { + print(prefix + "Encountered an error getting global data...") + } + + NSHttpRequest(getGlobalStats, onSuccess, onFailure) +} + void function GetMapStatsFromToneAPI() { print(prefix + "Getting map data...") diff --git a/mod/scripts/vscripts/ui/menu_stats.nut b/mod/scripts/vscripts/ui/menu_stats.nut index 4ab5450..65bef5e 100644 --- a/mod/scripts/vscripts/ui/menu_stats.nut +++ b/mod/scripts/vscripts/ui/menu_stats.nut @@ -46,6 +46,7 @@ void function OnViewStats_Open() fetchGamemodeStatsFromToneAPI(mapName) } GetWeaponStatsFromToneAPI() + GetGlobalDataFromToneAPI() GetMapStatsFromToneAPI() GetGamemodeStatsFromToneAPI() UI_SetPresentationType( ePresentationType.DEFAULT ) diff --git a/mod/scripts/vscripts/ui/menu_stats_overview.nut b/mod/scripts/vscripts/ui/menu_stats_overview.nut index c99dbf6..a2a74c6 100644 --- a/mod/scripts/vscripts/ui/menu_stats_overview.nut +++ b/mod/scripts/vscripts/ui/menu_stats_overview.nut @@ -295,6 +295,16 @@ function UpdateViewStatsOverviewMenu() totalPilotKills += value } + var totalGlobalKills = 0 + foreach (var key, var value in globalToneAPIAllPlayerKillData) { + totalGlobalKills += value + } + + var totalGlobalDeaths = 0 + foreach (var key, var value in globalToneAPIAllPlayerDeathData) { + totalGlobalDeaths += value + } + var totalPilotDeaths = 0 foreach (var key, var value in globalToneAPIDeathData) { @@ -321,16 +331,13 @@ function UpdateViewStatsOverviewMenu() float dval = float(totalPilotDeaths) float kdval = float(int((kval / dval)*100))/100 + float gkval = float(totalGlobalKills) + float gdval = float(totalGlobalDeaths) + float gkdval = float(int((gkval / gdval)*100))/100 + SetStatsLabelValue( file.menu, "LifetimeAverageValue", [ "#STATS_KD_VALUE", kdval ] ) - // Lifetime (PVP) - local lifetimeAveragePVP = player.GetPersistentVar( "kdratio_lifetime_pvp" ).tofloat() - local formattedLifetimeAveragePVP - if ( lifetimeAveragePVP % 1 == 0 ) - formattedLifetimeAveragePVP = format( "%.0f", lifetimeAveragePVP ) - else - formattedLifetimeAveragePVP = format( "%.1f", lifetimeAveragePVP ) - SetStatsLabelValue( file.menu, "LifetimePVPAverageValue", [ "#STATS_KD_VALUE", formattedLifetimeAveragePVP ] ) + SetStatsLabelValue( file.menu, "LifetimePVPAverageValue", [ "#STATS_KD_VALUE", gkdval ] ) bool last10GamesStatsVisible = gamesPlayed >= NUM_GAMES_TRACK_KDRATIO ? true : false SetLast10GamesStatVisibility( file.menu, last10GamesStatsVisible ) @@ -378,7 +385,7 @@ function UpdateViewStatsOverviewMenu() else kdratiopvp_match_average = format( "%.1f", kdratiopvp_match_average ) SetStatsLabelValue( file.menu, "Last10GamesPVPValue", [ "#STATS_KD_VALUE", kdratiopvp_match_average ] ) - PlotKDPointsOnGraph( file.menu, 1, kdratiopvp_match, lifetimeAveragePVP ) + PlotKDPointsOnGraph( file.menu, 1, kdratiopvp_match, gkdval ) ///////////////////////// Hud_SetText( GetElem( file.menu, "KillsAsPilotValue0" ), string( killsAsPilot ) ) diff --git a/version.json b/version.json new file mode 100644 index 0000000..1d6e638 --- /dev/null +++ b/version.json @@ -0,0 +1,5 @@ +{ + "Major": "1", + "Minor": "2", + "Patch": "1" +} \ No newline at end of file