1 Commits
Author SHA1 Message Date
okvdai 586fa32b69 v1.2.1 (#19)
* Update README.md

* Add global K/D calculation

* Display current and latest version in terminal #18
2023-05-03 18:25:19 +02:00
6 changed files with 93 additions and 14 deletions
+2 -2
View File
@@ -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) 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)
<details> <details>
<summary>Features, more in-depth:</summary> <summary>Features, more in-depth:</summary>
@@ -36,7 +36,7 @@ Found a bug? Make an issue on Github [here.](https://github.com/ToneAPI/pulse/is
| Name | Description | | 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.| | Titans |Non-functional, see line above.|
| Titan executions |Shows only executions accumulated by player as Titan.| | Titan executions |Shows only executions accumulated by player as Titan.|
| Pilots meleed |Shows only melee kills accumulated by player as Titan.| | Pilots meleed |Shows only melee kills accumulated by player as Titan.|
+17 -1
View File
@@ -1,12 +1,28 @@
{ {
"Name": "ToneAPI.pulse", "Name": "ToneAPI.pulse",
"Description": "Displays Tone API kill data in the Stats tab.", "Description": "Displays Tone API kill data in the Stats tab.",
"Version": "1.2.0", "Version": "1.2.1",
"LoadPriority": 1, "LoadPriority": 1,
"ConVars": [ "ConVars": [
{ {
"Name": "ToneURL", "Name": "ToneURL",
"DefaultValue": "https://tone.sleepycat.date/v2/client" "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": [ "Scripts": [
+52 -2
View File
@@ -1,5 +1,6 @@
global function pulseInit global function pulseInit
global function GetWeaponStatsFromToneAPI global function GetWeaponStatsFromToneAPI
global function GetGlobalDataFromToneAPI
global function GetMapStatsFromToneAPI global function GetMapStatsFromToneAPI
global function GetGamemodeStatsFromToneAPI global function GetGamemodeStatsFromToneAPI
global function getWeaponKillsFromToneAPI global function getWeaponKillsFromToneAPI
@@ -19,10 +20,13 @@ global table globalToneAPIMapDistData = {}
global table globalToneAPIMapKillData = {} global table globalToneAPIMapKillData = {}
global table globalToneAPIMapMDistData = {} global table globalToneAPIMapMDistData = {}
global table globalToneAPIGamemodeData = {} global table globalToneAPIGamemodeData = {}
global table globalToneAPIAllPlayerKillData = {}
global table globalToneAPIAllPlayerDeathData = {}
global table< table > globalToneAPIGamemodeMapData = {} global table< table > globalToneAPIGamemodeMapData = {}
string prefix = "default" string prefix = "default"
string HTTPrequestURL = "default" string HTTPrequestURL = "default"
string currentVersion = "default"
int weaponEntries = 0 int weaponEntries = 0
int mapEntries = 0 int mapEntries = 0
int gamemodeEntries = 0 int gamemodeEntries = 0
@@ -30,9 +34,26 @@ int mapGamemodeEntries = 0
void function pulseInit() void function pulseInit()
{ {
HTTPrequestURL = GetConVarString("ToneURL")
prefix = "\x1b[38;2;255;178;102m[PULSE]\x1b[0m " 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() void function GetWeaponStatsFromToneAPI()
@@ -65,6 +86,35 @@ void function GetWeaponStatsFromToneAPI()
NSHttpRequest(getWeaponStats, onSuccess, onFailure) 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() void function GetMapStatsFromToneAPI()
{ {
print(prefix + "Getting map data...") print(prefix + "Getting map data...")
+1
View File
@@ -46,6 +46,7 @@ void function OnViewStats_Open()
fetchGamemodeStatsFromToneAPI(mapName) fetchGamemodeStatsFromToneAPI(mapName)
} }
GetWeaponStatsFromToneAPI() GetWeaponStatsFromToneAPI()
GetGlobalDataFromToneAPI()
GetMapStatsFromToneAPI() GetMapStatsFromToneAPI()
GetGamemodeStatsFromToneAPI() GetGamemodeStatsFromToneAPI()
UI_SetPresentationType( ePresentationType.DEFAULT ) UI_SetPresentationType( ePresentationType.DEFAULT )
@@ -295,6 +295,16 @@ function UpdateViewStatsOverviewMenu()
totalPilotKills += value 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 var totalPilotDeaths = 0
foreach (var key, var value in globalToneAPIDeathData) { foreach (var key, var value in globalToneAPIDeathData) {
@@ -321,16 +331,13 @@ function UpdateViewStatsOverviewMenu()
float dval = float(totalPilotDeaths) float dval = float(totalPilotDeaths)
float kdval = float(int((kval / dval)*100))/100 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 ] ) SetStatsLabelValue( file.menu, "LifetimeAverageValue", [ "#STATS_KD_VALUE", kdval ] )
// Lifetime (PVP) SetStatsLabelValue( file.menu, "LifetimePVPAverageValue", [ "#STATS_KD_VALUE", gkdval ] )
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 ] )
bool last10GamesStatsVisible = gamesPlayed >= NUM_GAMES_TRACK_KDRATIO ? true : false bool last10GamesStatsVisible = gamesPlayed >= NUM_GAMES_TRACK_KDRATIO ? true : false
SetLast10GamesStatVisibility( file.menu, last10GamesStatsVisible ) SetLast10GamesStatVisibility( file.menu, last10GamesStatsVisible )
@@ -378,7 +385,7 @@ function UpdateViewStatsOverviewMenu()
else else
kdratiopvp_match_average = format( "%.1f", kdratiopvp_match_average ) kdratiopvp_match_average = format( "%.1f", kdratiopvp_match_average )
SetStatsLabelValue( file.menu, "Last10GamesPVPValue", [ "#STATS_KD_VALUE", 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 ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue0" ), string( killsAsPilot ) )
+5
View File
@@ -0,0 +1,5 @@
{
"Major": "1",
"Minor": "2",
"Patch": "1"
}