From 5c11623ecbb1086d6b5f887906cb55336f4e65e0 Mon Sep 17 00:00:00 2001 From: okvdai <108829133+okvdai@users.noreply.github.com> Date: Mon, 1 May 2023 17:51:45 +0200 Subject: [PATCH] Fix inaccurate K/D calculation --- mod/scripts/vscripts/ui/menu_stats_overview.nut | 16 ++++++---------- mod/scripts/vscripts/ui/menu_stats_weapons.nut | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/mod/scripts/vscripts/ui/menu_stats_overview.nut b/mod/scripts/vscripts/ui/menu_stats_overview.nut index fb70e39..1ae8378 100644 --- a/mod/scripts/vscripts/ui/menu_stats_overview.nut +++ b/mod/scripts/vscripts/ui/menu_stats_overview.nut @@ -262,19 +262,15 @@ function UpdateViewStatsOverviewMenu() var totalPilotDeaths = 0 - foreach (var key, var value in globalToneAPIDWEData) { + foreach (var key, var value in globalToneAPIDeathData) { totalPilotDeaths += value } - float kdval = float(totalPilotKills) / float(totalPilotDeaths) + float kval = float(totalPilotKills) + float dval = float(totalPilotDeaths) + float kdval = float(int((kval / dval)*100))/100 - local lifetimeAverage = kdval - local formattedLifetimeAverage - if ( lifetimeAverage % 1 == 0 ) - formattedLifetimeAverage = format( "%.0f", lifetimeAverage ) - else - formattedLifetimeAverage = format( "%.1f", lifetimeAverage ) - SetStatsLabelValue( file.menu, "LifetimeAverageValue", [ "#STATS_KD_VALUE", formattedLifetimeAverage ] ) + SetStatsLabelValue( file.menu, "LifetimeAverageValue", [ "#STATS_KD_VALUE", kdval ] ) // Lifetime (PVP) local lifetimeAveragePVP = player.GetPersistentVar( "kdratio_lifetime_pvp" ).tofloat() @@ -313,7 +309,7 @@ function UpdateViewStatsOverviewMenu() else kdratio_match_average = format( "%.1f", kdratio_match_average ) SetStatsLabelValue( file.menu, "Last10GamesValue", [ "#STATS_KD_VALUE", kdratio_match_average ] ) - PlotKDPointsOnGraph( file.menu, 0, kdratio_match, lifetimeAverage ) + PlotKDPointsOnGraph( file.menu, 0, kdratio_match, kdval ) // Last 10 (PVP) local kdratiopvp_match_sum = 0 diff --git a/mod/scripts/vscripts/ui/menu_stats_weapons.nut b/mod/scripts/vscripts/ui/menu_stats_weapons.nut index 7a41c64..114f202 100644 --- a/mod/scripts/vscripts/ui/menu_stats_weapons.nut +++ b/mod/scripts/vscripts/ui/menu_stats_weapons.nut @@ -183,5 +183,5 @@ void function UpdateStatsForWeapon( string weaponRef ) SetStatsLabelValue( file.menu, "KillsValue0", getWeaponKillsFromToneAPI(weaponRef) ) SetStatsLabelValue( file.menu, "KillsValue1", getWeaponKillsFromToneAPI(weaponRef) ) SetStatsLabelValue( file.menu, "KillsValue2", GetPlayerStatInt( player, "weapon_kill_stats", "titansTotal", weaponRef ) ) - SetStatsLabelValue( file.menu, "KillsValue3", GetPlayerStatInt( player, "weapon_kill_stats", "ai", weaponRef ) ) + SetStatsLabelValue( file.menu, "KillsValue3", getDWEFromToneAPI(weaponRef)) }