Prepare for v1.1.0

- Add viewstats_overview.menu
- Add NEMESIS WEAPON to Overview tab
- Add pilot melee kills, executions, roadkills and Titan executions to Overview tab
This commit is contained in:
okvdai
2023-04-24 18:29:48 +02:00
parent f71255e55b
commit 1c2244e10d
5 changed files with 2216 additions and 37 deletions
+1 -1
View File
@@ -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.0.0", "Version": "1.1.0-prerelease",
"LoadPriority": 1, "LoadPriority": 1,
"Scripts": [ "Scripts": [
{ {
File diff suppressed because it is too large Load Diff
+20 -7
View File
@@ -1,7 +1,9 @@
global function GetStatsFromToneAPI global function GetStatsFromToneAPI
global function getWeaponKillsFromToneApi global function getWeaponKillsFromToneApi
global function getNemesisWeaponFromToneAPI
global table globalToneAPIKillData = {} global table globalToneAPIKillData = {}
global table globalToneAPIDeathData = {}
void function GetStatsFromToneAPI() void function GetStatsFromToneAPI()
{ {
@@ -14,11 +16,12 @@ void function GetStatsFromToneAPI_threaded(){
if(NSIsMasterServerAuthenticated()) break if(NSIsMasterServerAuthenticated()) break
WaitFrame() WaitFrame()
} }
//SetConVarString("ToneURL", "https://toneapi.sleepycat.date/v1")
//SetConVarString("ToneURL", "https://toneapi.sleepycat.date/v2_test")
print("[PULSE] Loaded, getting data...") print("[PULSE] Loaded, getting data...")
HttpRequest getStats HttpRequest getStats
getStats.method = HttpRequestMethod.GET getStats.method = HttpRequestMethod.GET
getStats.url = "https://tone.sleepycat.date/v1/client/weapons" getStats.url = "https://tone.sleepycat.date/v2_test/client/weapons"
getStats.queryParameters["player"] <- [NSGetLocalPlayerUID().tostring()] getStats.queryParameters["player"] <- [NSGetLocalPlayerUID().tostring()]
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
{ {
@@ -26,9 +29,8 @@ void function GetStatsFromToneAPI_threaded(){
table JSONForConversion = DecodeJSON(response.body) table JSONForConversion = DecodeJSON(response.body)
foreach (var key, var value in JSONForConversion) { foreach (var key, var value in JSONForConversion) {
table test = expect table(value) table test = expect table(value)
//this won't work on v2 since kills will be an integer already globalToneAPIKillData[string(key)] <- test.kills
string kills = expect string(test.kills) globalToneAPIDeathData[string(key)] <- test.deaths
globalToneAPIKillData[string(key)] <- kills.tointeger()
print("[PULSE] " + key + " has been added.") print("[PULSE] " + key + " has been added.")
} }
print("[PULSE] Kill data has been processed.") print("[PULSE] Kill data has been processed.")
@@ -45,8 +47,6 @@ void function GetStatsFromToneAPI_threaded(){
int function getWeaponKillsFromToneApi(string weaponRef){ int function getWeaponKillsFromToneApi(string weaponRef){
//Sliced names are to be removed afterwards
//print("[PULSE]" + weaponRef)
if(weaponRef.find("mp_weapon") != null){ if(weaponRef.find("mp_weapon") != null){
weaponRef = weaponRef.slice(10) weaponRef = weaponRef.slice(10)
} }
@@ -57,3 +57,16 @@ int function getWeaponKillsFromToneApi(string weaponRef){
} }
return 0 return 0
} }
int function getNemesisWeaponFromToneAPI(string weaponRef){
if(weaponRef.find("mp_weapon") != null){
weaponRef = weaponRef.slice(10)
}
if(weaponRef in globalToneAPIKillData){
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIDeathData[weaponRef] + " deaths")
return expect int(globalToneAPIDeathData[weaponRef])
}
return 0
}
+19 -20
View File
@@ -118,7 +118,7 @@ function UpdateViewStatsOverviewMenu()
table<string, table> weaponData = GetOverviewWeaponData() table<string, table> weaponData = GetOverviewWeaponData()
table mostKillsData = weaponData[ "most_kills" ] table mostKillsData = weaponData[ "most_kills" ]
table mostUsedData = weaponData[ "most_used" ] table nemesisWeapon = weaponData[ "nemesis_weapon" ]
table highestKPMData = weaponData[ "highest_kpm" ] table highestKPMData = weaponData[ "highest_kpm" ]
var weaponImageElem var weaponImageElem
@@ -158,14 +158,14 @@ function UpdateViewStatsOverviewMenu()
weaponNameElem = Hud_GetChild( file.menu, "WeaponName1" ) weaponNameElem = Hud_GetChild( file.menu, "WeaponName1" )
weaponDescElem = Hud_GetChild( file.menu, "WeaponDesc1" ) weaponDescElem = Hud_GetChild( file.menu, "WeaponDesc1" )
noDataElem = Hud_GetChild( file.menu, "WeaponImageTextOverlay1" ) noDataElem = Hud_GetChild( file.menu, "WeaponImageTextOverlay1" )
if ( mostUsedData.ref != "" ) if ( nemesisWeapon.ref != "" )
{ {
SetItemImageWidth( weaponImageElem, expect string( mostUsedData.ref ) ) SetItemImageWidth( weaponImageElem, expect string( nemesisWeapon.ref ) )
RuiSetImage( weaponRui, "buttonImage", GetItemImage( expect string( mostUsedData.ref ) ) ) RuiSetImage( weaponRui, "buttonImage", GetItemImage( expect string( nemesisWeapon.ref ) ) )
Hud_Show( weaponImageElem ) Hud_Show( weaponImageElem )
Hud_SetText( weaponNameElem, mostUsedData.printName ) Hud_SetText( weaponNameElem, nemesisWeapon.printName )
Hud_Show( weaponNameElem ) Hud_Show( weaponNameElem )
SetStatsLabelValue( file.menu, "WeaponDesc1", HoursToTimeString( expect float( mostUsedData.val ) ) ) Hud_SetText( weaponDescElem, "#STATS_MOST_KILLS_VALUE", nemesisWeapon.val )
Hud_Show( weaponDescElem ) Hud_Show( weaponDescElem )
Hud_Hide( noDataElem ) Hud_Hide( noDataElem )
} }
@@ -321,26 +321,25 @@ function UpdateViewStatsOverviewMenu()
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue0" ), string( totalPilotKills ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue0" ), string( totalPilotKills ) )
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue1" ), string( GetPlayerStatInt( player, "kills_stats", "titanKillsAsPilot" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue1" ), string( GetPlayerStatInt( player, "kills_stats", "titanKillsAsPilot" ) ) )
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue2" ), string( GetPlayerStatInt( player, "kills_stats", "totalNPC" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue2" ), string( GetPlayerStatInt( player, "kills_stats", "totalNPC" ) ) )
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue3" ), string( GetPlayerStatInt( player, "kills_stats", "pilotKickMeleePilot" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue3" ), string( getWeaponKillsFromToneApi("pilot_emptyhanded") ) )
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue4" ), string( GetPlayerStatInt( player, "kills_stats", "pilotExecutePilot" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue4" ), string( getWeaponKillsFromToneApi("human_execution") ) )
// Hud_SetText( GetElem( file.menu, "KillsAsPilotValue5" ), string( GetPlayerStatInt( player, "kills_stats", "titanFallKill" ) ) ) // Hud_SetText( GetElem( file.menu, "KillsAsPilotValue5" ), string( GetPlayerStatInt( player, "kills_stats", "titanFallKill" ) ) )
var titanMeleeKills = 0
titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_ion")
int totalTitanExecutions = 0 titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_scorch")
totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionIon" ) titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_northstar")
totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionScorch" ) titanMeleeKills += getWeaponKillsFromToneApi("titan_sword")
totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionNorthstar" ) titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_tone")
totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionRonin" ) titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_legion")
totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionTone" ) titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_vanguard")
totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionLegion" ) titanMeleeKills += getWeaponKillsFromToneApi("auto_titan_melee")
totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionVanguard" )
Hud_SetText( GetElem( file.menu, "KillsAsTitanValue0" ), string( GetPlayerStatInt( player, "kills_stats", "pilotKillsAsTitan" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsTitanValue0" ), string( GetPlayerStatInt( player, "kills_stats", "pilotKillsAsTitan" ) ) )
Hud_SetText( GetElem( file.menu, "KillsAsTitanValue1" ), string( GetPlayerStatInt( player, "kills_stats", "titanKillsAsTitan" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsTitanValue1" ), string( GetPlayerStatInt( player, "kills_stats", "titanKillsAsTitan" ) ) )
Hud_SetText( GetElem( file.menu, "KillsAsTitanValue2" ), string( totalTitanExecutions ) ) Hud_SetText( GetElem( file.menu, "KillsAsTitanValue2" ), string( titanMeleeKills ) )
Hud_SetText( GetElem( file.menu, "KillsAsTitanValue3" ), string( GetPlayerStatInt( player, "kills_stats", "titanMeleePilot" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsTitanValue3" ), string( GetPlayerStatInt( player, "kills_stats", "titanMeleePilot" ) ) )
Hud_SetText( GetElem( file.menu, "KillsAsTitanValue4" ), string( GetPlayerStatInt( player, "kills_stats", "titanStepCrushPilot" ) ) ) Hud_SetText( GetElem( file.menu, "KillsAsTitanValue4" ), string( getWeaponKillsFromToneApi("damagedef_titan_step") ) )
} }
function PlotKDPointsOnGraph( menu, graphIndex, values, dottedAverage ) function PlotKDPointsOnGraph( menu, graphIndex, values, dottedAverage )
@@ -306,10 +306,10 @@ table<string, table> function GetOverviewWeaponData()
Table[ "most_kills" ].ref <- "" Table[ "most_kills" ].ref <- ""
Table[ "most_kills" ].printName <- "" Table[ "most_kills" ].printName <- ""
Table[ "most_kills" ].val <- 0 Table[ "most_kills" ].val <- 0
Table[ "most_used" ] <- {} Table[ "nemesis_weapon" ] <- {}
Table[ "most_used" ].ref <- "" Table[ "nemesis_weapon" ].ref <- ""
Table[ "most_used" ].printName <- "" Table[ "nemesis_weapon" ].printName <- ""
Table[ "most_used" ].val <- 0 Table[ "nemesis_weapon" ].val <- 0
Table[ "highest_kpm" ] <- {} Table[ "highest_kpm" ] <- {}
Table[ "highest_kpm" ].ref <- "" Table[ "highest_kpm" ].ref <- ""
Table[ "highest_kpm" ].printName <- "" Table[ "highest_kpm" ].printName <- ""
@@ -346,12 +346,12 @@ table<string, table> function GetOverviewWeaponData()
Table[ "most_kills" ].val = val Table[ "most_kills" ].val = val
} }
float fVal = GetPlayerStatFloat( player, "weapon_stats", "hoursUsed", weaponName ) int nval = getNemesisWeaponFromToneAPI(weaponName)
if ( fVal > Table[ "most_used" ].val ) if ( nval > Table[ "nemesis_weapon" ].val )
{ {
Table[ "most_used" ].ref = weaponName Table[ "nemesis_weapon" ].ref = weaponName
Table[ "most_used" ].printName = weaponDisplayName Table[ "nemesis_weapon" ].printName = weaponDisplayName
Table[ "most_used" ].val = fVal Table[ "nemesis_weapon" ].val = nval
} }
local killsPerMinute = 0 local killsPerMinute = 0