Add best K/D calculation
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
global function GetStatsFromToneAPI
|
||||
global function getWeaponKillsFromToneApi
|
||||
global function getNemesisWeaponFromToneAPI
|
||||
global function getDWEFromToneAPI
|
||||
|
||||
global table globalToneAPIKillData = {}
|
||||
global table globalToneAPIDeathData = {}
|
||||
global table globalToneAPIDWEData = {}
|
||||
|
||||
void function GetStatsFromToneAPI()
|
||||
{
|
||||
@@ -31,6 +33,7 @@ void function GetStatsFromToneAPI_threaded(){
|
||||
table test = expect table(value)
|
||||
globalToneAPIKillData[string(key)] <- test.kills
|
||||
globalToneAPIDeathData[string(key)] <- test.deaths
|
||||
globalToneAPIDWEData[string(key)] <- test.deaths_while_equipped
|
||||
print("[PULSE] " + key + " has been added.")
|
||||
}
|
||||
print("[PULSE] Kill data has been processed.")
|
||||
@@ -64,9 +67,22 @@ int function getNemesisWeaponFromToneAPI(string weaponRef){
|
||||
weaponRef = weaponRef.slice(10)
|
||||
}
|
||||
|
||||
if(weaponRef in globalToneAPIKillData){
|
||||
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIDeathData[weaponRef] + " deaths")
|
||||
if(weaponRef in globalToneAPIDeathData){
|
||||
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIDeathData[weaponRef] + " nemesis weapon kills")
|
||||
return expect int(globalToneAPIDeathData[weaponRef])
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
int function getDWEFromToneAPI(string weaponRef){
|
||||
|
||||
if(weaponRef.find("mp_weapon") != null){
|
||||
weaponRef = weaponRef.slice(10)
|
||||
}
|
||||
|
||||
if(weaponRef in globalToneAPIDWEData){
|
||||
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIDeathData[weaponRef] + " deaths while equipped")
|
||||
return expect int(globalToneAPIDWEData[weaponRef])
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -190,7 +190,7 @@ function UpdateViewStatsOverviewMenu()
|
||||
Hud_Show( weaponImageElem )
|
||||
Hud_SetText( weaponNameElem, highestKPMData.printName )
|
||||
Hud_Show( weaponNameElem )
|
||||
Hud_SetText( weaponDescElem, "#STATS_MOST_EFFICIENT_VALUE", highestKPMData.val )
|
||||
Hud_SetText( weaponDescElem, highestKPMData.val + " K/D")
|
||||
Hud_Show( weaponDescElem )
|
||||
Hud_Hide( noDataElem )
|
||||
}
|
||||
|
||||
@@ -354,16 +354,21 @@ table<string, table> function GetOverviewWeaponData()
|
||||
Table[ "nemesis_weapon" ].val = nval
|
||||
}
|
||||
|
||||
local killsPerMinute = 0
|
||||
local hoursEquipped = GetPlayerStatFloat( player, "weapon_stats", "hoursEquipped", weaponName )
|
||||
local killCount = GetPlayerStatInt( player, "weapon_kill_stats", "total", weaponName )
|
||||
if ( hoursEquipped > 0 )
|
||||
killsPerMinute = format( "%.2f", ( killCount / ( hoursEquipped * 60.0 ) ).tofloat() )
|
||||
if ( killsPerMinute.tofloat() > Table[ "highest_kpm" ].val.tofloat() )
|
||||
float kdval = 0
|
||||
float kval = 0
|
||||
float dval = 0
|
||||
if( getWeaponKillsFromToneApi(weaponName) != 0 && getDWEFromToneAPI(weaponName) != 0){
|
||||
kval = float(getWeaponKillsFromToneApi(weaponName))
|
||||
dval = float(getDWEFromToneAPI(weaponName))
|
||||
if (kval / dval > kdval){
|
||||
kdval = float(getWeaponKillsFromToneApi(weaponName) / getDWEFromToneAPI(weaponName))
|
||||
}
|
||||
}
|
||||
if ( kdval > Table[ "highest_kpm" ].val.tofloat() )
|
||||
{
|
||||
Table[ "highest_kpm" ].ref = weaponName
|
||||
Table[ "highest_kpm" ].printName = weaponDisplayName
|
||||
Table[ "highest_kpm" ].val = killsPerMinute
|
||||
Table[ "highest_kpm" ].val = kdval
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user