v1.2.1 (#19)
* Update README.md * Add global K/D calculation * Display current and latest version in terminal #18
This commit is contained in:
@@ -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...")
|
||||
|
||||
@@ -46,6 +46,7 @@ void function OnViewStats_Open()
|
||||
fetchGamemodeStatsFromToneAPI(mapName)
|
||||
}
|
||||
GetWeaponStatsFromToneAPI()
|
||||
GetGlobalDataFromToneAPI()
|
||||
GetMapStatsFromToneAPI()
|
||||
GetGamemodeStatsFromToneAPI()
|
||||
UI_SetPresentationType( ePresentationType.DEFAULT )
|
||||
|
||||
@@ -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 ) )
|
||||
|
||||
Reference in New Issue
Block a user