Author SHA1 Message Date
okvdai 340a2a0516 Update README.md 2023-04-24 23:40:14 +02:00
okvdai 3120fae436 Fix menu_stats_overview.nut 2023-04-20 18:36:25 +02:00
okvdai 4b779d2730 Create menu_stats_overview.nut
Still need to figure out why kill count doesn't correlate with data shown on the site...
2023-04-19 23:05:57 +02:00
okvdai 559be46b38 Add menu_stats_utility.nut 2023-04-19 21:42:07 +02:00
okvdai e82a29e317 Update pulse.gnut 2023-04-19 19:56:43 +02:00
legonzaur 223299024b Merge branch 'development' of https://github.com/ToneAPI/pulse into development 2023-04-19 19:44:11 +02:00
legonzaur 6c720ed8d1 Shows kills on weapons, as they should do 2023-04-19 19:43:26 +02:00
okvdai 9d5c9956ad Fix sh_stats.gnut
We can now enter the lobby!
2023-04-19 18:22:56 +02:00
okvdai d20ec3a1ac Update README.md 2023-04-19 17:53:30 +02:00
okvdai 2e771bfe17 Initial commit
Commit pulse.gnut for fixing.
2023-04-19 14:10:47 +02:00
6 changed files with 66 additions and 2513 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"Name": "ToneAPI.pulse", "Name": "ToneAPI.pulse",
"Description": "Displays Tone API kill data in the Stats tab.", "Description": "placeholder text",
"Version": "1.1.0-prerelease", "Version": "0.0.1",
"LoadPriority": 1, "LoadPriority": 1,
"Scripts": [ "Scripts": [
{ {
File diff suppressed because it is too large Load Diff
+13 -46
View File
@@ -1,29 +1,15 @@
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()
{ {
thread GetStatsFromToneAPI_threaded() //SetConVarString("ToneURL", "https://toneapi.sleepycat.date/v1")
}
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/v2_test/client/weapons" getStats.url = "https://tone.sleepycat.date/v1/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)
{ {
@@ -31,9 +17,9 @@ 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)
globalToneAPIKillData[string(key)] <- test.kills //this won't work on v2 since kills will be an integer already
globalToneAPIDeathData[string(key)] <- test.deaths string kills = expect string(test.kills)
globalToneAPIDWEData[string(key)] <- test.deaths_while_equipped 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.")
@@ -50,39 +36,20 @@ 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)
} }
foreach (var key, var value in globalToneAPIKillData) {
print(key)
print(value)
}
if(weaponRef in globalToneAPIKillData){ if(weaponRef in globalToneAPIKillData){
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIKillData[weaponRef] + " kills") print("found!")
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
}
+34 -49
View File
@@ -51,19 +51,12 @@ 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
@@ -125,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 nemesisWeapon = weaponData[ "nemesis_weapon" ] table mostUsedData = weaponData[ "most_used" ]
table highestKPMData = weaponData[ "highest_kpm" ] table highestKPMData = weaponData[ "highest_kpm" ]
var weaponImageElem var weaponImageElem
@@ -165,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 ( nemesisWeapon.ref != "" ) if ( mostUsedData.ref != "" )
{ {
SetItemImageWidth( weaponImageElem, expect string( nemesisWeapon.ref ) ) SetItemImageWidth( weaponImageElem, expect string( mostUsedData.ref ) )
RuiSetImage( weaponRui, "buttonImage", GetItemImage( expect string( nemesisWeapon.ref ) ) ) RuiSetImage( weaponRui, "buttonImage", GetItemImage( expect string( mostUsedData.ref ) ) )
Hud_Show( weaponImageElem ) Hud_Show( weaponImageElem )
Hud_SetText( weaponNameElem, nemesisWeapon.printName ) Hud_SetText( weaponNameElem, mostUsedData.printName )
Hud_Show( weaponNameElem ) Hud_Show( weaponNameElem )
Hud_SetText( weaponDescElem, "#STATS_MOST_KILLS_VALUE", nemesisWeapon.val ) SetStatsLabelValue( file.menu, "WeaponDesc1", HoursToTimeString( expect float( mostUsedData.val ) ) )
Hud_Show( weaponDescElem ) Hud_Show( weaponDescElem )
Hud_Hide( noDataElem ) Hud_Hide( noDataElem )
} }
@@ -197,7 +190,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, highestKPMData.val + " K/D") Hud_SetText( weaponDescElem, "#STATS_MOST_EFFICIENT_VALUE", highestKPMData.val )
Hud_Show( weaponDescElem ) Hud_Show( weaponDescElem )
Hud_Hide( noDataElem ) Hud_Hide( noDataElem )
} }
@@ -253,22 +246,7 @@ 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 )
@@ -333,29 +311,36 @@ 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( getWeaponKillsFromToneApi("pilot_emptyhanded") ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue3" ), string( GetPlayerStatInt( player, "kills_stats", "pilotKickMeleePilot" ) ) )
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue4" ), string( getWeaponKillsFromToneApi("human_execution") ) ) Hud_SetText( GetElem( file.menu, "KillsAsPilotValue4" ), string( GetPlayerStatInt( player, "kills_stats", "pilotExecutePilot" ) ) )
// 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")
titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_scorch") int totalTitanExecutions = 0
titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_northstar") totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionIon" )
titanMeleeKills += getWeaponKillsFromToneApi("titan_sword") totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionScorch" )
titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_tone") totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionNorthstar" )
titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_legion") totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionRonin" )
titanMeleeKills += getWeaponKillsFromToneApi("titan_punch_vanguard") totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionTone" )
titanMeleeKills += getWeaponKillsFromToneApi("auto_titan_melee") totalTitanExecutions += GetPlayerStatInt( player, "kills_stats", "titanExocutionLegion" )
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( titanMeleeKills ) ) Hud_SetText( GetElem( file.menu, "KillsAsTitanValue2" ), string( totalTitanExecutions ) )
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( getWeaponKillsFromToneApi("damagedef_titan_step") ) ) Hud_SetText( GetElem( file.menu, "KillsAsTitanValue4" ), string( GetPlayerStatInt( player, "kills_stats", "titanStepCrushPilot" ) ) )
} }
function PlotKDPointsOnGraph( menu, graphIndex, values, dottedAverage ) function PlotKDPointsOnGraph( menu, graphIndex, values, dottedAverage )
@@ -1,227 +0,0 @@
//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
}
+16 -21
View File
@@ -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[ "nemesis_weapon" ] <- {} Table[ "most_used" ] <- {}
Table[ "nemesis_weapon" ].ref <- "" Table[ "most_used" ].ref <- ""
Table[ "nemesis_weapon" ].printName <- "" Table[ "most_used" ].printName <- ""
Table[ "nemesis_weapon" ].val <- 0 Table[ "most_used" ].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,29 +346,24 @@ table<string, table> function GetOverviewWeaponData()
Table[ "most_kills" ].val = val Table[ "most_kills" ].val = val
} }
int nval = getNemesisWeaponFromToneAPI(weaponName) float fVal = GetPlayerStatFloat( player, "weapon_stats", "hoursUsed", weaponName )
if ( nval > Table[ "nemesis_weapon" ].val ) if ( fVal > Table[ "most_used" ].val )
{ {
Table[ "nemesis_weapon" ].ref = weaponName Table[ "most_used" ].ref = weaponName
Table[ "nemesis_weapon" ].printName = weaponDisplayName Table[ "most_used" ].printName = weaponDisplayName
Table[ "nemesis_weapon" ].val = nval Table[ "most_used" ].val = fVal
} }
float kdval = 0 local killsPerMinute = 0
float kval = 0 local hoursEquipped = GetPlayerStatFloat( player, "weapon_stats", "hoursEquipped", weaponName )
float dval = 0 local killCount = GetPlayerStatInt( player, "weapon_kill_stats", "total", weaponName )
if( getWeaponKillsFromToneApi(weaponName) != 0 && getDWEFromToneAPI(weaponName) != 0){ if ( hoursEquipped > 0 )
kval = float(getWeaponKillsFromToneApi(weaponName)) killsPerMinute = format( "%.2f", ( killCount / ( hoursEquipped * 60.0 ) ).tofloat() )
dval = float(getDWEFromToneAPI(weaponName)) if ( killsPerMinute.tofloat() > Table[ "highest_kpm" ].val.tofloat() )
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 = kdval Table[ "highest_kpm" ].val = killsPerMinute
} }
} }