23 Commits
Author SHA1 Message Date
Okudai 6d2c3898ad Update README.md 2023-12-07 00:00:21 +01:00
Okudai 7cf39f94a1 Update README.md 2023-10-30 21:54:44 +01:00
okvdai 02ba70198f Update version numbers 2023-10-13 19:04:54 +02:00
okvdai f959f7dd91 Prepare for release v2.1.0 2023-10-03 23:37:41 +02:00
okvdai 7aa6c9476f Fix stats loading only after reloading mods 2023-09-03 15:20:57 +02:00
okvdai 0f0d89c9c3 Merge pulse-loeb-component.nut into pulse-common-func.gnut 2023-09-03 15:15:33 +02:00
okvdai d56b2878a2 Update ToneURL convar 2023-09-03 14:16:16 +02:00
okvdai 5a5591d7b4 Update pulse-loeb-component.nut 2023-07-31 22:58:52 +02:00
okvdai 48c415c9ba Dependency info 2023-07-07 18:41:31 +02:00
okvdai 11ae2bac90 Integrate with loeb #35 2023-07-07 18:30:26 +02:00
okvdai f7e4588f80 Update localisation 2023-06-21 14:44:04 +02:00
okvdai b8879c3560 Update viewstats_maps.menu 2023-06-21 14:37:50 +02:00
okvdai 1c5ab1514b Average kill distance calculation, better Hammer conversion 2023-06-21 14:36:41 +02:00
okvdai c538dd44f3 Hotfixes 2023-06-20 20:25:31 +02:00
okvdai df4ee8fb0c Rename pulseSuccessBool to pulseFailure 2023-06-20 20:21:49 +02:00
okvdai ba0c4d11c7 Change request failure message 2023-06-20 20:20:55 +02:00
okvdai c1cd3a6fc7 Format code 2023-06-20 20:17:52 +02:00
okvdai a8bbd9ea39 Fix typo in english localisation 2023-06-20 20:16:17 +02:00
okvdai ff06daefae Use NsIsSuccessHttpCode() for status code checking 2023-06-20 20:15:47 +02:00
okvdai e1d5801d9a Add melee_pilot_kunai into the melee kill stat 2023-06-20 16:30:02 +02:00
okvdai d4efc94e7d Add missing comma 2023-06-19 13:42:18 +02:00
okvdai 81b1b4f928 Cleanup in menu_stats_overview.nut 2023-06-15 19:22:06 +02:00
okvdai 1d6b09537f Add status code checking to request function
"Borrowed" from the servermod
2023-06-15 19:02:54 +02:00
14 changed files with 69 additions and 1700 deletions
+14 -2
View File
@@ -1,3 +1,5 @@
# SINCE 06.12.2023, PULSE IS **DEPRECATED** DUE TO THE CLOSING OF THE TONE API SERVICE. THANK YOU FOR USING THE MOD.
# pulse
**pulse** is a clientside mod for [TF|2 + Northstar](https://github.com/R2Northstar/Northstar) letting you view killstats collected by [the Tone API](https://toneapi.github.io/ToneAPI_webclient/) using the otherwise non-functional `Stats` tab.
@@ -73,11 +75,13 @@ Found a bug? Make an issue on GitHub [here.](https://github.com/ToneAPI/pulse/is
- Kills by Gamemode - piechart showing all kills (in percent) on chosen map by gamemode.
</details>
## DISCLAIMER
## DISCLAIMERS
The Tone API is NOT used by every server, view a list of supported servers [here.](https://tone.sleepycat.date/v2/client/servers)
The Tone API is NOT used by every server, view a list of supported servers [here.](https://toneapi.ovh/v2/client/servers)
**pulse** is very much a W.I.P as of right now, features may be missing/nonfunctional.
As of v2.1.0, **pulse** requires [loeb](https://github.com/okvdai/loeb)
## CHANGELOG
<details>
@@ -97,3 +101,11 @@ The Tone API is NOT used by every server, view a list of supported servers [here
- Polish. (Northstar isn't translated into Polish, but the game supports it.)
- Locking the Stats tab, avoiding situations where you could click too fast and see no stats. Also prevents the game from showing stats when the API is unreachable.
</details>
<details>
<summary> pulse v2.1.0 </summary>
- Changed endpoint
- Lots of bug fixes
- Uses new experimental loeb library
</details>
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "Pulse",
"description": "Adds stats (collected by the Tone API) back to the Stats tab.",
"version_number": "2.0.0",
"version_number": "2.1.1",
"website_url": "https://github.com/ToneAPI/pulse",
"dependencies": []
"dependencies": ["Okudai-loeb-1.0.1"]
}
+2 -6
View File
@@ -1,16 +1,12 @@
{
"Name": "ToneAPI.pulse",
"Description": "Displays Tone API kill data in the Stats tab.",
"Version": "2.0.0",
"Version": "2.1.1",
"LoadPriority": 1,
"ConVars": [
{
"Name": "ToneURL",
"DefaultValue": "https://tone.sleepycat.date/v2/client"
},
{
"Name": "VersionURL",
"DefaultValue": "https://raw.githubusercontent.com/ToneAPI/pulse/main/version.json"
"DefaultValue": "https://toneapi.ovh/v2/client"
}
],
"Scripts": [
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -532,7 +532,7 @@ resource/ui/menus/viewstats_pve.menu
visible 1
font Default_23
labelText "--"
allcaps 1
allcaps 0
textAlignment center
fgcolor_override "255 255 255 255"
//bgcolor_override "0 255 0 100"
@@ -3,7 +3,6 @@ globalize_all_functions
global string pulsePrefix
global bool pulseSuccessBool = true
table withMapName = {}
void function pulsePrefixSet() //Sets our prefix
{
@@ -18,7 +17,9 @@ void function pulsePrintt(string content) //Prints whatever we want printed with
bool function pulseRequestData(string givenURL, table parameterTable, string tablepath) //Gets data from API (see ToneURL within mod.json) and puts it into one table for processing.
{
table<string, array<string> > requestTable
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (parameterTable, requestTable, tablepath)
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (givenURL, parameterTable, requestTable, tablepath)
{
if (NSIsSuccessHttpCode(response.statusCode))
{
table DecodedJSON = DecodeJSON(response.body)
if ("map" in parameterTable)
@@ -29,12 +30,15 @@ bool function pulseRequestData(string givenURL, table parameterTable, string tab
} else {
pulseData[tablepath] <- DecodedJSON
}
pulseSuccessBool = false
} else {
pulsePrintt(format("%s, %s is unreachable.", response.statusCode, givenURL))
pulseLockStats()
}
void functionref (HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
}
void functionref (HttpRequestFailure) onFailure = void function(HttpRequestFailure failure) : (givenURL)
{
pulsePrintt("Something went wrong while getting data.")
pulseSuccessBool = true
pulsePrintt(format("Something went wrong, %s is unreachable", givenURL))
pulseLockStats()
}
foreach (key, value in parameterTable)
{
@@ -51,10 +55,20 @@ int function pulseParse(...) //Returns data from our pulseData table.
if (i < expect int(vargc) - 1) {
if (expect string (vargv[i]) in parser) {
parser = expect table(parser[expect string(vargv[i])])
} else {break}
} else break
} else {
result = expect int(parser[expect string(vargv[i])])
}
}
return result
}
void function pulseLockStats()
{
loebSetLockedButton(Localize("#MENU_TITLE_STATS"), true)
}
string function HammerToMeterString(float value)
{
return value > 0 && int((1.905 * value ))/100 > 0 ? string(int((1.905 * value ) )/100) + "m" : "0";
}
@@ -12,10 +12,12 @@ void function pulseInit()
pulsePrefixSet()
file.allMaps = GetPrivateMatchMaps()
pulsePrintt("Initialized.")
AddUICallback_OnLevelInit( pulseGetData )
}
void function pulseGetData()
{
print("data getter called")
string URL = GetConVarString("ToneURL")
array <string> URLpath = ["/weapons", "/weapons", "/gamemodes", "/gamemodes", "/maps"]
array <string> tablepath = ["weaponsLocal", "weaponsGlobal", "gamemodesAll", "gamemodesSeparated", "maps"]
File diff suppressed because it is too large Load Diff
@@ -159,13 +159,13 @@ void function UpdateStatsForMap( string mapName )
SetStatsLabelValue( file.menu, "KillsValue1", pulseParse("maps", mapName.slice(3), "deaths") )
SetStatsLabelValue( file.menu, "KillsLabel2", Localize("#MAPS_TSD") )
SetStatsLabelValue( file.menu, "KillsValue2", string(int((1.905 * float(pulseParse("maps", mapName.slice(3), "total_distance") ) ) )/100) + "m" )
SetStatsLabelValue( file.menu, "KillsValue2", HammerToMeterString(float(pulseParse("maps", mapName.slice(3), "total_distance"))))
SetStatsLabelValue( file.menu, "KillsLabel3", Localize("#MAPS_MSD") )
SetStatsLabelValue( file.menu, "KillsValue3", string(int((1.905 * float(pulseParse("maps", mapName.slice(3), "max_distance") ) ) )/100) + "m" )
SetStatsLabelValue( file.menu, "KillsValue3", HammerToMeterString(float(pulseParse("maps", mapName.slice(3), "max_distance"))))
SetStatsLabelValue( file.menu, "KillsLabel4", "--" )
SetStatsLabelValue( file.menu, "KillsValue4", "--" )
SetStatsLabelValue( file.menu, "KillsLabel4", Localize("#MAPS_ASD") )
SetStatsLabelValue( file.menu, "KillsValue4", HammerToMeterString(float(pulseParse("maps", mapName.slice(3), "max_distance")) / float(pulseParse("maps", mapName.slice(3), "kills"))))
//var anchorElem = Hud_GetChild( file.menu, "WeaponStatsBackground" )
//printt( Hud_GetX( anchorElem ) )
@@ -32,7 +32,7 @@ void function InitViewStatsOverviewMenu()
AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" )
}
void function GetTitanKills( string titanName )
void function GetTitanKills()
{
file.allTitans = GetVisibleItemsOfType( eItemTypes.TITAN )
var dataTable = GetDataTable( $"datatable/titan_properties.rpak" )
@@ -50,11 +50,14 @@ void function GetTitanKills( string titanName )
file.titanStatLoadout[ titan.ref ].append( GetDataTableString( dataTable, row, GetDataTableColumnByName( dataTable, "melee" ) ) )
}
foreach ( weaponRef in file.titanStatLoadout[ titanName ])
foreach ( titan in file.allTitans)
{
foreach ( weaponRef in file.titanStatLoadout[ titan.ref ])
{
titanKillData[weaponRef] <- pulseParse("weaponsLocal", weaponRef, "kills")
}
}
}
void function GetAllPilotWeapons()
{
@@ -68,15 +71,7 @@ void function GetAllPilotWeapons()
void function OnStatsOverview_Open()
{
UI_SetPresentationType( ePresentationType.NO_MODELS )
GetTitanKills("ion")
GetTitanKills("scorch")
GetTitanKills("northstar")
GetTitanKills("ronin")
GetTitanKills("tone")
GetTitanKills("legion")
GetTitanKills("vanguard")
GetTitanKills()
UpdateViewStatsOverviewMenu()
}
@@ -301,48 +296,35 @@ function UpdateViewStatsOverviewMenu()
// Lifetime
table playerweaponData = expect table(pulseData["weaponsLocal"])
table globalweaponData = expect table(pulseData["weaponsGlobal"])
var totalPilotKills = 0
foreach (var key, var value in playerweaponData) {
table values = expect table(value)
totalPilotKills += values["kills"]
}
var totalGlobalKills = 0
foreach (var key, var value in globalweaponData) {
table values = expect table(value)
totalGlobalKills += values["kills"]
}
var totalPilotDeaths = 0
foreach (var key, var value in playerweaponData) {
table values = expect table(value)
totalPilotKills += values["kills"]
totalPilotDeaths += values["deaths"]
}
var totalGlobalKills = 0
var totalGlobalDeaths = 0
foreach (var key, var value in globalweaponData) {
table values = expect table(value)
totalGlobalKills += values["kills"]
totalGlobalDeaths += values["deaths"]
}
var killsAsTitan = 0
var killsAsPilot = 0
foreach (var key, var value in playerweaponData) {
if (key in titanKillData) {
continue
killsAsTitan += titanKillData[string(key)]
} else {
killsAsPilot += pulseParse("weaponsLocal", string(key), "kills")
}
}
var killsAsTitan = 0
foreach (var key, var value in playerweaponData) {
if (key in titanKillData) {
killsAsTitan += titanKillData[string(key)]
}
}
float kval = float(totalPilotKills)
float dval = float(totalPilotDeaths)
float kdval = float(int((kval / dval)*100))/100
@@ -407,7 +389,7 @@ function UpdateViewStatsOverviewMenu()
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue0" ), string( killsAsPilot ) )
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, "KillsAsPilotValue3" ), string( pulseParse("weaponsLocal", "pilot_emptyhanded", "kills") ) )
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue3" ), string( pulseParse("weaponsLocal", "pilot_emptyhanded", "kills") + pulseParse("weaponsLocal", "melee_pilot_kunai", "kills") ) )
Hud_SetText( GetElem( file.menu, "KillsAsPilotValue4" ), string( pulseParse("weaponsLocal", "human_execution", "kills") ) )
// Hud_SetText( GetElem( file.menu, "KillsAsPilotValue5" ), string( GetPlayerStatInt( player, "kills_stats", "titanFallKill" ) ) )