add passives to loadout

This commit is contained in:
2023-08-10 12:33:09 +02:00
parent 4deda3a113
commit 06202bb311
+100 -28
View File
@@ -1,4 +1,6 @@
global function killstat_Init
global
function killstat_Init
struct {
string killstatVersion
@@ -10,9 +12,12 @@ struct {
string matchId
string gameMode
string map
} file
}
file
void function killstat_Init() {
void
function killstat_Init() {
file.killstatVersion = GetConVarString("killstat_version")
file.Tone_URI = GetConVarString("Tone_URI")
file.Tone_token = GetConVarString("Tone_token")
@@ -32,12 +37,16 @@ void function killstat_Init() {
string prefix = "\x1b[38;5;81m[TONE API]\x1b[0m "
void function JoinMessage(entity player) {
void
function JoinMessage(entity player) {
//Chat_ServerPrivateMessage(player, prefix + "This server collects data using the Tone API. Check your data here: \x1b[34mtoneapi.com/" + player.GetPlayerName()+ "\x1b[0m", false, false)
Chat_ServerPrivateMessage(player, prefix + "This server collects data using the WIP Tone API. View statistics at https://toneapi.github.io/ToneAPI_webclient/", false, false)
}
void function killstat_Begin() {
void
function killstat_Begin() {
//TODO : request MatchID from API ------------------------------------------------------------------------------------------------
//TODO : request anonymization data from API
@@ -45,7 +54,10 @@ void function killstat_Begin() {
Log("Sending kill data to " + file.Tone_URI + "/kill")
}
void function killstat_Record(entity victim, entity attacker, var damageInfo) {
void
function killstat_Record(entity victim, entity attacker,
var damageInfo) {
if (!victim.IsPlayer() || !attacker.IsPlayer() || GetGameState() != eGameState.Playing)
return
// if(file.matchId)
@@ -53,7 +65,8 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
table attackerValues = {}
table<string, var> victimValues = {}
table < string,
var > victimValues = {}
array < entity > attackerWeapons = attacker.GetMainWeapons()
array < entity > victimWeapons = victim.GetMainWeapons()
@@ -91,7 +104,6 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
attacker = {
name = attacker.GetPlayerName()
id = attacker.GetUID()
titan = GetTitan(attacker)
velocity = Distance( < 0, 0, 0 > , attacker.GetVelocity())
cloaked = attacker.IsCloaked(true)
state = GetMovementState(attacker)
@@ -120,12 +132,14 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
name = GetWeaponName(aow2)
mods = GetWeaponMods(aow2)
}
passive1 = getPlayerPassive1(attacker)
passive2 = getPlayerPassive2(attacker)
titan = GetTitan(attacker)
}
}
victim = {
name = victim.GetPlayerName()
id = victim.GetUID()
titan = GetTitan(victim)
velocity = Distance( < 0, 0, 0 > , victim.GetVelocity())
cloaked = victim.IsCloaked(true)
state = GetMovementState(victim)
@@ -154,6 +168,9 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
name = GetWeaponName(vow2)
mods = GetWeaponMods(vow2)
}
passive1 = getPlayerPassive1(victim)
passive2 = getPlayerPassive2(victim)
titan = GetTitan(victim)
}
}
}
@@ -166,15 +183,20 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
Tone_HTTP_Request(
request,
void function ( HttpRequestResponse response ) {}
void
function(HttpRequestResponse response) {}
)
}
void function killstat_End() {
void
function killstat_End() {
Log("-----END KILLSTAT-----")
}
string function GetMovementState(entity player){
string
function GetMovementState(entity player) {
Assert(IsPilot(player))
//IsPhaseShifted
//IsStanding
@@ -195,7 +217,9 @@ string function GetMovementState(entity player){
// 1. primary
// 2. secondary
// 3. anti-titan
int function MainWeaponSort(entity a, entity b) {
int
function MainWeaponSort(entity a, entity b) {
int aID = a.GetDamageSourceID()
int bID = b.GetDamageSourceID()
@@ -213,11 +237,13 @@ int function MainWeaponSort(entity a, entity b) {
return aIdx < bIdx ? -1 : 1
}
entity function GetNthWeapon(array<entity> weapons, int index) {
entity
function GetNthWeapon(array < entity > weapons, int index) {
return index < weapons.len() ? weapons[index] : null
}
string function GetWeaponName(entity weapon) {
string
function GetWeaponName(entity weapon) {
string s = "null"
if (weapon != null) {
s = weapon.GetWeaponClassName()
@@ -225,7 +251,8 @@ string function GetWeaponName(entity weapon) {
return s
}
int function GetWeaponMods(entity weapon) {
int
function GetWeaponMods(entity weapon) {
if (weapon == null) {
return 0
}
@@ -234,22 +261,26 @@ int function GetWeaponMods(entity weapon) {
return modBits
}
string function GetTitan(entity player) {
string
function GetTitan(entity player) {
if (!player.IsTitan()) return "null"
return GetTitanCharacterName(player)
}
void function Log(string s) {
void
function Log(string s) {
print(prefix + " " + s)
}
void function Tone_Test_Auth(){
void
function Tone_Test_Auth() {
HttpRequest request
request.method = HttpRequestMethod.POST
request.url = file.Tone_URI + "/"
Tone_HTTP_Request(
request,
void function ( HttpRequestResponse response ) {
void
function(HttpRequestResponse response) {
Log("Tone API Online !")
file.connected = true
}
@@ -257,7 +288,8 @@ void function Tone_Test_Auth(){
}
void function Tone_Register_Match(){
void
function Tone_Register_Match() {
HttpRequest request
request.method = HttpRequestMethod.POST
request.url = file.Tone_URI + "/match"
@@ -268,7 +300,8 @@ void function Tone_Register_Match(){
})
Tone_HTTP_Request(
request,
void function ( HttpRequestResponse response ) {
void
function(HttpRequestResponse response) {
Log("match ID : " + response.body)
file.matchId = response.body
}
@@ -276,18 +309,21 @@ void function Tone_Register_Match(){
}
void function Tone_HTTP_Request(HttpRequest request, void functionref( HttpRequestResponse ) cbSuccess){
void
function Tone_HTTP_Request(HttpRequest request, void functionref(HttpRequestResponse) cbSuccess) {
if (!request.method) request.method = HttpRequestMethod.POST
if (request.url == "") {
Log("[ERRR] Couldn't find URI for request. This should be reported")
return
}
request.headers = {Authorization = ["Bearer "+ file.Tone_token]}
request.headers = {
Authorization = ["Bearer " + file.Tone_token]
}
NSHttpRequest(
request,
void function ( HttpRequestResponse response ) : (cbSuccess)
{
void
function(HttpRequestResponse response): (cbSuccess) {
if (response.statusCode == 200 || response.statusCode == 201) {
cbSuccess(response)
} else {
@@ -296,8 +332,8 @@ void function Tone_HTTP_Request(HttpRequest request, void functionref( HttpReque
Log("[WARN]" + response.body)
}
},
void function ( HttpRequestFailure failure )
{
void
function(HttpRequestFailure failure) {
Log("[WARN] Couldn't request the server! ToneAPI may be down.")
Log("[WARN]" + failure.errorCode)
Log("[WARN]" + failure.errorMessage)
@@ -305,6 +341,25 @@ void function Tone_HTTP_Request(HttpRequest request, void functionref( HttpReque
)
}
string
function getPlayerPassive1(player entity) {
foreach(string passive in passive1Names) {
if (PlayerHasPassive(player, passive)) {
return passive
}
}
return null
}
string
function getPlayerPassive2(player entity) {
foreach(string passive in passive2Names) {
if (PlayerHasPassive(player, passive)) {
return passive
}
}
return null
}
array < int > MAIN_DAMAGE_SOURCES = [
// primaries
@@ -344,3 +399,20 @@ array<int> MAIN_DAMAGE_SOURCES = [
eDamageSourceId.mp_weapon_arc_launcher,
eDamageSourceId.mp_weapon_defender
]
array < string > passive1Names = [
"pas_ordnance_pack",
"pas_power_cell",
"pas_fast_embark",
"pas_fast_health_regen"
]
array < string > passive2Names = [
"pas_stealth_movement",
"pas_wallhang",
"pas_ads_hover",
"pas_enemy_death_icons",
"pas_at_hunter"
]