Add global K/D calculation
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"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": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,6 +20,8 @@ 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"
|
||||||
@@ -65,6 +68,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...")
|
||||||
|
|||||||
@@ -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 ) )
|
||||||
|
|||||||
Reference in New Issue
Block a user