Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2df433810 | ||
|
|
0f80026a94 | ||
|
|
9701fa5559 | ||
|
|
1c2244e10d | ||
|
|
f71255e55b | ||
|
|
3268f5b75c | ||
|
|
7dce384024 | ||
|
|
4c45bc233a | ||
|
|
a18faecd0a | ||
|
|
5bfe63f1c5 | ||
|
|
66dfb9d53a | ||
|
|
e8cbfeb3cc |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Name": "ToneAPI.pulse",
|
"Name": "ToneAPI.pulse",
|
||||||
"Description": "placeholder text",
|
"Description": "Displays Tone API kill data in the Stats tab.",
|
||||||
"Version": "0.0.1",
|
"Version": "1.1.0-prerelease",
|
||||||
"LoadPriority": 1,
|
"LoadPriority": 1,
|
||||||
"Scripts": [
|
"Scripts": [
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,29 @@
|
|||||||
global function GetStatsFromToneAPI
|
global function GetStatsFromToneAPI
|
||||||
global function getWeaponKillsFromToneApi
|
global function getWeaponKillsFromToneApi
|
||||||
|
global function getNemesisWeaponFromToneAPI
|
||||||
|
global function getDWEFromToneAPI
|
||||||
|
|
||||||
global table globalToneAPIKillData = {}
|
global table globalToneAPIKillData = {}
|
||||||
|
global table globalToneAPIDeathData = {}
|
||||||
|
global table globalToneAPIDWEData = {}
|
||||||
|
|
||||||
void function GetStatsFromToneAPI()
|
void function GetStatsFromToneAPI()
|
||||||
{
|
{
|
||||||
//SetConVarString("ToneURL", "https://toneapi.sleepycat.date/v1")
|
thread GetStatsFromToneAPI_threaded()
|
||||||
|
}
|
||||||
|
|
||||||
|
void function GetStatsFromToneAPI_threaded(){
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
if(NSIsMasterServerAuthenticated()) break
|
||||||
|
WaitFrame()
|
||||||
|
}
|
||||||
|
|
||||||
|
//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)
|
||||||
{
|
{
|
||||||
@@ -17,9 +31,9 @@ void function GetStatsFromToneAPI()
|
|||||||
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()
|
globalToneAPIDWEData[string(key)] <- test.deaths_while_equipped
|
||||||
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.")
|
||||||
@@ -36,20 +50,39 @@ void function GetStatsFromToneAPI()
|
|||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var key, var value in globalToneAPIKillData) {
|
|
||||||
print(key)
|
|
||||||
print(value)
|
|
||||||
}
|
|
||||||
if(weaponRef in globalToneAPIKillData){
|
if(weaponRef in globalToneAPIKillData){
|
||||||
print("found!")
|
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIKillData[weaponRef] + " kills")
|
||||||
print(globalToneAPIKillData[weaponRef])
|
|
||||||
return expect int(globalToneAPIKillData[weaponRef])
|
return expect int(globalToneAPIKillData[weaponRef])
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int function getNemesisWeaponFromToneAPI(string weaponRef){
|
||||||
|
|
||||||
|
if(weaponRef.find("mp_weapon") != null){
|
||||||
|
weaponRef = weaponRef.slice(10)
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -51,12 +51,19 @@ function UpdateViewStatsOverviewMenu()
|
|||||||
int timesMVP = GetPlayerStatInt( player, "game_stats", "mvp_total" )
|
int timesMVP = GetPlayerStatInt( player, "game_stats", "mvp_total" )
|
||||||
int timesTop3 = GetPlayerStat_AllCompetitiveModesAndMapsInt( player, "game_stats", "top3OnTeam" )
|
int timesTop3 = GetPlayerStat_AllCompetitiveModesAndMapsInt( player, "game_stats", "top3OnTeam" )
|
||||||
|
|
||||||
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat0" ), Localize( "#STATS_HEADER_TIME_PLAYED" ), timePlayed )
|
//SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat0" ), Localize( "#STATS_HEADER_TIME_PLAYED" ), timePlayed )
|
||||||
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat1" ), Localize( "#STATS_GAMES_PLAYED" ), string( gamesPlayed ) )
|
//SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat1" ), Localize( "#STATS_GAMES_PLAYED" ), string( gamesPlayed ) )
|
||||||
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat2" ), Localize( "#STATS_GAMES_WON" ), string( gamesWon ) )
|
//SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat2" ), Localize( "#STATS_GAMES_WON" ), string( gamesWon ) )
|
||||||
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat3" ), Localize( "#STATS_GAMES_WIN_PERCENT" ), Localize( "#STATS_PERCENTAGE", winPercent ) )
|
//SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat3" ), Localize( "#STATS_GAMES_WIN_PERCENT" ), Localize( "#STATS_PERCENTAGE", winPercent ) )
|
||||||
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat4" ), Localize( "#STATS_GAMES_MVP" ), string( timesMVP ) )
|
//SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat4" ), Localize( "#STATS_GAMES_MVP" ), string( timesMVP ) )
|
||||||
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat5" ), Localize( "#STATS_GAMES_TOP3" ), string( timesTop3 ) )
|
//SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat5" ), Localize( "#STATS_GAMES_TOP3" ), string( timesTop3 ) )
|
||||||
|
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat0" ), Localize( "#STATS_HEADER_TIME_PLAYED" ), string( 0 ))
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat1" ), Localize( "#STATS_GAMES_PLAYED" ), string( 0 ) )
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat2" ), Localize( "#STATS_GAMES_WON" ), string( 0 ) )
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat3" ), Localize( "#STATS_GAMES_WIN_PERCENT" ), string( 0 ) )
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat4" ), Localize( "#STATS_GAMES_MVP" ), string( 0 ) )
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat5" ), Localize( "#STATS_GAMES_TOP3" ), string( 0 ) )
|
||||||
|
|
||||||
//#########################
|
//#########################
|
||||||
// Modes
|
// Modes
|
||||||
@@ -118,7 +125,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 +165,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 )
|
||||||
}
|
}
|
||||||
@@ -190,7 +197,7 @@ function UpdateViewStatsOverviewMenu()
|
|||||||
Hud_Show( weaponImageElem )
|
Hud_Show( weaponImageElem )
|
||||||
Hud_SetText( weaponNameElem, highestKPMData.printName )
|
Hud_SetText( weaponNameElem, highestKPMData.printName )
|
||||||
Hud_Show( weaponNameElem )
|
Hud_Show( weaponNameElem )
|
||||||
Hud_SetText( weaponDescElem, "#STATS_MOST_EFFICIENT_VALUE", highestKPMData.val )
|
Hud_SetText( weaponDescElem, highestKPMData.val + " K/D")
|
||||||
Hud_Show( weaponDescElem )
|
Hud_Show( weaponDescElem )
|
||||||
Hud_Hide( noDataElem )
|
Hud_Hide( noDataElem )
|
||||||
}
|
}
|
||||||
@@ -246,7 +253,22 @@ function UpdateViewStatsOverviewMenu()
|
|||||||
//#########################
|
//#########################
|
||||||
|
|
||||||
// Lifetime
|
// Lifetime
|
||||||
local lifetimeAverage = player.GetPersistentVar( "kdratio_lifetime" ).tofloat()
|
|
||||||
|
var totalPilotKills = 0
|
||||||
|
|
||||||
|
foreach (var key, var value in globalToneAPIKillData) {
|
||||||
|
totalPilotKills += value
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalPilotDeaths = 0
|
||||||
|
|
||||||
|
foreach (var key, var value in globalToneAPIDWEData) {
|
||||||
|
totalPilotDeaths += value
|
||||||
|
}
|
||||||
|
|
||||||
|
float kdval = float(totalPilotKills) / float(totalPilotDeaths)
|
||||||
|
|
||||||
|
local lifetimeAverage = kdval
|
||||||
local formattedLifetimeAverage
|
local formattedLifetimeAverage
|
||||||
if ( lifetimeAverage % 1 == 0 )
|
if ( lifetimeAverage % 1 == 0 )
|
||||||
formattedLifetimeAverage = format( "%.0f", lifetimeAverage )
|
formattedLifetimeAverage = format( "%.0f", lifetimeAverage )
|
||||||
@@ -311,36 +333,29 @@ function UpdateViewStatsOverviewMenu()
|
|||||||
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, lifetimeAveragePVP )
|
||||||
|
|
||||||
var totalPilotKills = 0
|
|
||||||
|
|
||||||
foreach (var key, var value in globalToneAPIKillData) {
|
|
||||||
totalPilotKills += value
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
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 )
|
||||||
|
|||||||
@@ -0,0 +1,227 @@
|
|||||||
|
//TODO: Kills Per Minute stat
|
||||||
|
|
||||||
|
global function InitViewStatsTitansMenu
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
var menu
|
||||||
|
var[NUM_PERSISTENT_TITAN_LOADOUTS] buttons
|
||||||
|
array<ItemDisplayData> allTitans
|
||||||
|
table<string, array<string> > titanStatLoadout
|
||||||
|
} file
|
||||||
|
|
||||||
|
void function InitViewStatsTitansMenu()
|
||||||
|
{
|
||||||
|
var menu = GetMenu( "ViewStats_Titans_Menu" )
|
||||||
|
file.menu = menu
|
||||||
|
|
||||||
|
Hud_SetText( Hud_GetChild( file.menu, "MenuTitle" ), "#STATS_TITANS" )
|
||||||
|
|
||||||
|
AddMenuEventHandler( file.menu, eUIEvent.MENU_OPEN, OnViewStatsTitans_Open )
|
||||||
|
|
||||||
|
for ( int i = 0; i < NUM_PERSISTENT_TITAN_LOADOUTS; i++ )
|
||||||
|
{
|
||||||
|
var button = Hud_GetChild( menu, "Button" + i )
|
||||||
|
//button.s.rowIndex <- i
|
||||||
|
//Hud_AddEventHandler( button, UIE_CLICK, OnButton_Activate )
|
||||||
|
Hud_AddEventHandler( button, UIE_GET_FOCUS, OnButton_Focused )
|
||||||
|
file.buttons[i] = button
|
||||||
|
}
|
||||||
|
|
||||||
|
AddMenuFooterOption( file.menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" )
|
||||||
|
}
|
||||||
|
|
||||||
|
void function OnViewStatsTitans_Open()
|
||||||
|
{
|
||||||
|
UI_SetPresentationType( ePresentationType.STORE_PRIME_TITANS )
|
||||||
|
RunMenuClientFunction( "UpdateTitanModel", 0 )
|
||||||
|
|
||||||
|
// Get Titan list
|
||||||
|
file.allTitans = GetVisibleItemsOfType( eItemTypes.TITAN )
|
||||||
|
var dataTable = GetDataTable( $"datatable/titan_properties.rpak" )
|
||||||
|
|
||||||
|
foreach ( titan in file.allTitans )
|
||||||
|
{
|
||||||
|
file.titanStatLoadout[ titan.ref ] <- []
|
||||||
|
|
||||||
|
int row = GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "titanRef" ), titan.ref )
|
||||||
|
file.titanStatLoadout[ titan.ref ].append( GetDataTableString( dataTable, row, GetDataTableColumnByName( dataTable, "primary" ) ) )
|
||||||
|
file.titanStatLoadout[ titan.ref ].append( GetDataTableString( dataTable, row, GetDataTableColumnByName( dataTable, "ordnance" ) ) )
|
||||||
|
file.titanStatLoadout[ titan.ref ].append( GetDataTableString( dataTable, row, GetDataTableColumnByName( dataTable, "special" ) ) )
|
||||||
|
file.titanStatLoadout[ titan.ref ].append( GetDataTableString( dataTable, row, GetDataTableColumnByName( dataTable, "antirodeo" ) ) )
|
||||||
|
file.titanStatLoadout[ titan.ref ].append( GetDataTableString( dataTable, row, GetDataTableColumnByName( dataTable, "coreAbility" ) ) )
|
||||||
|
file.titanStatLoadout[ titan.ref ].append( GetDataTableString( dataTable, row, GetDataTableColumnByName( dataTable, "melee" ) ) )
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateButtons( 0, file.buttons )
|
||||||
|
UpdateStatsForTitan( file.allTitans[ 0 ].ref, 0 )
|
||||||
|
}
|
||||||
|
|
||||||
|
void function UpdateButtons( int selectedIndex, var[NUM_PERSISTENT_TITAN_LOADOUTS] buttons )
|
||||||
|
{
|
||||||
|
foreach ( index, button in buttons )
|
||||||
|
{
|
||||||
|
TitanLoadoutDef loadout = GetCachedTitanLoadout( index )
|
||||||
|
RHud_SetText( button, GetTitanLoadoutName( loadout ) )
|
||||||
|
|
||||||
|
Hud_SetEnabled( button, true )
|
||||||
|
Hud_SetVisible( button, true )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//void function OnButton_Activate( var button )
|
||||||
|
//{
|
||||||
|
// int id = int( Hud_GetScriptID( button ) )
|
||||||
|
// if ( !IsControllerModeActive() )
|
||||||
|
// UpdateStatsForTitan( file.allTitans[ id ].ref, id )
|
||||||
|
//}
|
||||||
|
|
||||||
|
void function OnButton_Focused( var button )
|
||||||
|
{
|
||||||
|
int id = int( Hud_GetScriptID( button ) )
|
||||||
|
//if ( IsControllerModeActive() )
|
||||||
|
UpdateStatsForTitan( file.allTitans[ id ].ref, id )
|
||||||
|
}
|
||||||
|
|
||||||
|
void function UpdateStatsForTitan( string titanRef, int loadoutIndex )
|
||||||
|
{
|
||||||
|
entity player = GetUIPlayer()
|
||||||
|
if ( player == null )
|
||||||
|
return
|
||||||
|
|
||||||
|
RunMenuClientFunction( "UpdateTitanModel", loadoutIndex )
|
||||||
|
RunMenuClientFunction( "UpdateStorePrimeBg", loadoutIndex )
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Hud_SetText( Hud_GetChild( file.menu, "TitanName" ), GetItemName( titanRef ) )
|
||||||
|
|
||||||
|
// Locked info
|
||||||
|
var lockLabel = GetElementsByClassname( file.menu, "LblTitanLocked" )[0]
|
||||||
|
|
||||||
|
if ( IsItemLocked( player, titanRef ) )
|
||||||
|
{
|
||||||
|
Hud_SetText( lockLabel, "#LOUADOUT_UNLOCK_REQUIREMENT_LEVEL", GetUnlockLevelReq( titanRef ) )
|
||||||
|
Hud_Show( lockLabel )
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Hud_Hide( lockLabel )
|
||||||
|
}
|
||||||
|
|
||||||
|
string timeUsed = StatToTimeString( "time_stats", "hours_as_titan_" + titanRef )
|
||||||
|
int shotsHit
|
||||||
|
foreach ( weaponRef in file.titanStatLoadout[ titanRef ] )
|
||||||
|
shotsHit += GetPlayerStatInt( player, "weapon_stats", "shotsHit", weaponRef )
|
||||||
|
int coresEarned = GetPlayerStatInt( player, "titan_stats", "coresEarned", titanRef )
|
||||||
|
|
||||||
|
int crits
|
||||||
|
bool critsApplicable = false
|
||||||
|
foreach ( weaponRef in file.titanStatLoadout[ titanRef ] )
|
||||||
|
{
|
||||||
|
if ( GetWeaponInfoFileKeyField_Global( weaponRef, "critical_hit" ) == true )
|
||||||
|
{
|
||||||
|
critsApplicable = true
|
||||||
|
crits += GetPlayerStatInt( player, "weapon_stats", "critHits", weaponRef )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string critHitsValue = Localize( "#STATS_NOT_APPLICABLE" )
|
||||||
|
if ( critsApplicable )
|
||||||
|
critHitsValue = string( crits )
|
||||||
|
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat0" ), Localize( "#STATS_HEADER_TIME_USED" ), timeUsed )
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat1" ), Localize( "#STATS_HEADER_SHOTS_HIT" ), string( shotsHit ) )
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat2" ), Localize( "#STATS_HEADER_CORES_EARNED" ), string( coresEarned ) )
|
||||||
|
SetStatBoxDisplay( Hud_GetChild( file.menu, "Stat3" ), Localize( "#STATS_HEADER_CRITICAL_HITS" ), critHitsValue )
|
||||||
|
|
||||||
|
string nextUnlockRef = GetNextUnlockForTitanLevel( player, titanRef, TitanGetRawLevel( player, titanRef ) + 1 )
|
||||||
|
if ( nextUnlockRef != "" )
|
||||||
|
{
|
||||||
|
var rui = Hud_GetRui( Hud_GetChild( file.menu, "NextUnlock" ) )
|
||||||
|
|
||||||
|
if ( nextUnlockRef == "random" )
|
||||||
|
{
|
||||||
|
RuiSetString( rui, "unlockName", "" )
|
||||||
|
RuiSetImage( rui, "unlockImage", $"rui/menu/common/unlock_random" )
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ItemDisplayData displayData
|
||||||
|
if ( IsSubItemType( GetItemType( nextUnlockRef ) ) )
|
||||||
|
displayData = GetItemDisplayData( nextUnlockRef, titanRef )
|
||||||
|
else
|
||||||
|
displayData = GetItemDisplayData( nextUnlockRef )
|
||||||
|
RuiSetString( rui, "unlockName", displayData.name )
|
||||||
|
RuiSetImage( rui, "unlockImage", displayData.image )
|
||||||
|
|
||||||
|
vector aspect = GetItemImageAspect( nextUnlockRef )
|
||||||
|
|
||||||
|
float mult = 1.0
|
||||||
|
if ( aspect.x > aspect.y )
|
||||||
|
mult = 120.0 / aspect.x
|
||||||
|
else
|
||||||
|
mult = 120.0 / aspect.y
|
||||||
|
|
||||||
|
aspect.x *= mult
|
||||||
|
aspect.y *= mult
|
||||||
|
|
||||||
|
RuiSetFloat2( rui, "unlockImageSize", aspect )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalKills
|
||||||
|
int pilotKills
|
||||||
|
int titanKills
|
||||||
|
int aiKills
|
||||||
|
foreach ( weaponRef in file.titanStatLoadout[ titanRef ] )
|
||||||
|
{
|
||||||
|
totalKills += getWeaponKillsFromToneApi(weaponRef)
|
||||||
|
pilotKills += GetPlayerStatInt( player, "weapon_kill_stats", "pilots", weaponRef )
|
||||||
|
titanKills += GetPlayerStatInt( player, "weapon_kill_stats", "titansTotal", weaponRef )
|
||||||
|
aiKills += GetPlayerStatInt( player, "weapon_kill_stats", "ai", weaponRef )
|
||||||
|
}
|
||||||
|
|
||||||
|
// Total Kills Stats
|
||||||
|
SetStatsLabelValue( file.menu, "KillsValue0", totalKills )
|
||||||
|
SetStatsLabelValue( file.menu, "KillsValue1", pilotKills )
|
||||||
|
SetStatsLabelValue( file.menu, "KillsValue2", titanKills )
|
||||||
|
SetStatsLabelValue( file.menu, "KillsValue3", aiKills )
|
||||||
|
}
|
||||||
|
|
||||||
|
asset function GetTitanStatImage( string titanRef )
|
||||||
|
{
|
||||||
|
asset image
|
||||||
|
|
||||||
|
switch ( titanRef )
|
||||||
|
{
|
||||||
|
case "ion":
|
||||||
|
image = $"r2_ui/menus/loadout_icons/titans/ion_icon"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "scorch":
|
||||||
|
image = $"r2_ui/menus/loadout_icons/titans/scorch_icon"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "northstar":
|
||||||
|
image = $"r2_ui/menus/loadout_icons/titans/northstar_icon"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "ronin":
|
||||||
|
image = $"r2_ui/menus/loadout_icons/titans/ronin_icon"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "tone":
|
||||||
|
image = $"r2_ui/menus/loadout_icons/titans/tone_icon"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "legion":
|
||||||
|
image = $"r2_ui/menus/loadout_icons/titans/legion_icon"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "vanguard":
|
||||||
|
image = $"r2_ui/menus/loadout_icons/titans/vanguard_icon"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return image
|
||||||
|
}
|
||||||
@@ -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,24 +346,29 @@ 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
|
float kdval = 0
|
||||||
local hoursEquipped = GetPlayerStatFloat( player, "weapon_stats", "hoursEquipped", weaponName )
|
float kval = 0
|
||||||
local killCount = GetPlayerStatInt( player, "weapon_kill_stats", "total", weaponName )
|
float dval = 0
|
||||||
if ( hoursEquipped > 0 )
|
if( getWeaponKillsFromToneApi(weaponName) != 0 && getDWEFromToneAPI(weaponName) != 0){
|
||||||
killsPerMinute = format( "%.2f", ( killCount / ( hoursEquipped * 60.0 ) ).tofloat() )
|
kval = float(getWeaponKillsFromToneApi(weaponName))
|
||||||
if ( killsPerMinute.tofloat() > Table[ "highest_kpm" ].val.tofloat() )
|
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" ].ref = weaponName
|
||||||
Table[ "highest_kpm" ].printName = weaponDisplayName
|
Table[ "highest_kpm" ].printName = weaponDisplayName
|
||||||
Table[ "highest_kpm" ].val = killsPerMinute
|
Table[ "highest_kpm" ].val = kdval
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user