add passives to loadout
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
global function killstat_Init
|
global
|
||||||
|
|
||||||
|
function killstat_Init
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
string killstatVersion
|
string killstatVersion
|
||||||
@@ -10,9 +12,12 @@ struct {
|
|||||||
string matchId
|
string matchId
|
||||||
string gameMode
|
string gameMode
|
||||||
string map
|
string map
|
||||||
} file
|
}
|
||||||
|
file
|
||||||
|
|
||||||
void function killstat_Init() {
|
void
|
||||||
|
|
||||||
|
function killstat_Init() {
|
||||||
file.killstatVersion = GetConVarString("killstat_version")
|
file.killstatVersion = GetConVarString("killstat_version")
|
||||||
file.Tone_URI = GetConVarString("Tone_URI")
|
file.Tone_URI = GetConVarString("Tone_URI")
|
||||||
file.Tone_token = GetConVarString("Tone_token")
|
file.Tone_token = GetConVarString("Tone_token")
|
||||||
@@ -32,12 +37,16 @@ void function killstat_Init() {
|
|||||||
|
|
||||||
string prefix = "\x1b[38;5;81m[TONE API]\x1b[0m "
|
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 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)
|
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 MatchID from API ------------------------------------------------------------------------------------------------
|
||||||
//TODO : request anonymization data from API
|
//TODO : request anonymization data from API
|
||||||
|
|
||||||
@@ -45,20 +54,24 @@ void function killstat_Begin() {
|
|||||||
Log("Sending kill data to " + file.Tone_URI + "/kill")
|
Log("Sending kill data to " + file.Tone_URI + "/kill")
|
||||||
}
|
}
|
||||||
|
|
||||||
void function killstat_Record(entity victim, entity attacker, var damageInfo) {
|
void
|
||||||
if ( !victim.IsPlayer() || !attacker.IsPlayer() || GetGameState() != eGameState.Playing )
|
|
||||||
|
function killstat_Record(entity victim, entity attacker,
|
||||||
|
var damageInfo) {
|
||||||
|
if (!victim.IsPlayer() || !attacker.IsPlayer() || GetGameState() != eGameState.Playing)
|
||||||
return
|
return
|
||||||
// if(file.matchId)
|
// if(file.matchId)
|
||||||
// return
|
// return
|
||||||
|
|
||||||
|
|
||||||
table attackerValues = {}
|
table attackerValues = {}
|
||||||
table<string, var> victimValues = {}
|
table < string,
|
||||||
|
var > victimValues = {}
|
||||||
|
|
||||||
array<entity> attackerWeapons = attacker.GetMainWeapons()
|
array < entity > attackerWeapons = attacker.GetMainWeapons()
|
||||||
array<entity> victimWeapons = victim.GetMainWeapons()
|
array < entity > victimWeapons = victim.GetMainWeapons()
|
||||||
array<entity> attackerOffhandWeapons = attacker.GetOffhandWeapons()
|
array < entity > attackerOffhandWeapons = attacker.GetOffhandWeapons()
|
||||||
array<entity> victimOffhandWeapons = victim.GetOffhandWeapons()
|
array < entity > victimOffhandWeapons = victim.GetOffhandWeapons()
|
||||||
|
|
||||||
attackerWeapons.sort(MainWeaponSort)
|
attackerWeapons.sort(MainWeaponSort)
|
||||||
victimWeapons.sort(MainWeaponSort)
|
victimWeapons.sort(MainWeaponSort)
|
||||||
@@ -91,9 +104,8 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
|
|||||||
attacker = {
|
attacker = {
|
||||||
name = attacker.GetPlayerName()
|
name = attacker.GetPlayerName()
|
||||||
id = attacker.GetUID()
|
id = attacker.GetUID()
|
||||||
titan = GetTitan(attacker)
|
velocity = Distance( < 0, 0, 0 > , attacker.GetVelocity())
|
||||||
velocity = Distance(<0,0,0>, attacker.GetVelocity())
|
cloaked = attacker.IsCloaked(true)
|
||||||
cloaked = attacker.IsCloaked( true )
|
|
||||||
state = GetMovementState(attacker)
|
state = GetMovementState(attacker)
|
||||||
current_weapon = {
|
current_weapon = {
|
||||||
name = GetWeaponName(attacker.GetLatestPrimaryWeapon())
|
name = GetWeaponName(attacker.GetLatestPrimaryWeapon())
|
||||||
@@ -120,14 +132,16 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
|
|||||||
name = GetWeaponName(aow2)
|
name = GetWeaponName(aow2)
|
||||||
mods = GetWeaponMods(aow2)
|
mods = GetWeaponMods(aow2)
|
||||||
}
|
}
|
||||||
|
passive1 = getPlayerPassive1(attacker)
|
||||||
|
passive2 = getPlayerPassive2(attacker)
|
||||||
|
titan = GetTitan(attacker)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
victim = {
|
victim = {
|
||||||
name = victim.GetPlayerName()
|
name = victim.GetPlayerName()
|
||||||
id = victim.GetUID()
|
id = victim.GetUID()
|
||||||
titan = GetTitan(victim)
|
velocity = Distance( < 0, 0, 0 > , victim.GetVelocity())
|
||||||
velocity = Distance(<0,0,0>, victim.GetVelocity())
|
cloaked = victim.IsCloaked(true)
|
||||||
cloaked = victim.IsCloaked( true )
|
|
||||||
state = GetMovementState(victim)
|
state = GetMovementState(victim)
|
||||||
current_weapon = {
|
current_weapon = {
|
||||||
name = GetWeaponName(victim.GetLatestPrimaryWeapon())
|
name = GetWeaponName(victim.GetLatestPrimaryWeapon())
|
||||||
@@ -154,6 +168,9 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
|
|||||||
name = GetWeaponName(vow2)
|
name = GetWeaponName(vow2)
|
||||||
mods = GetWeaponMods(vow2)
|
mods = GetWeaponMods(vow2)
|
||||||
}
|
}
|
||||||
|
passive1 = getPlayerPassive1(victim)
|
||||||
|
passive2 = getPlayerPassive2(victim)
|
||||||
|
titan = GetTitan(victim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,27 +183,32 @@ void function killstat_Record(entity victim, entity attacker, var damageInfo) {
|
|||||||
|
|
||||||
Tone_HTTP_Request(
|
Tone_HTTP_Request(
|
||||||
request,
|
request,
|
||||||
void function ( HttpRequestResponse response ) {}
|
void
|
||||||
|
function(HttpRequestResponse response) {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
void function killstat_End() {
|
void
|
||||||
|
|
||||||
|
function killstat_End() {
|
||||||
Log("-----END KILLSTAT-----")
|
Log("-----END KILLSTAT-----")
|
||||||
}
|
}
|
||||||
|
|
||||||
string function GetMovementState(entity player){
|
string
|
||||||
|
|
||||||
|
function GetMovementState(entity player) {
|
||||||
Assert(IsPilot(player))
|
Assert(IsPilot(player))
|
||||||
//IsPhaseShifted
|
//IsPhaseShifted
|
||||||
//IsStanding
|
//IsStanding
|
||||||
if(player.IsWallHanging())
|
if (player.IsWallHanging())
|
||||||
return "WallHanging"
|
return "WallHanging"
|
||||||
if(player.IsWallRunning())
|
if (player.IsWallRunning())
|
||||||
return "WallRunning"
|
return "WallRunning"
|
||||||
if(player.IsZiplining())
|
if (player.IsZiplining())
|
||||||
return "Ziplining"
|
return "Ziplining"
|
||||||
if(!player.IsOnGround())
|
if (!player.IsOnGround())
|
||||||
return "Airborne"
|
return "Airborne"
|
||||||
if(player.IsCrouched())
|
if (player.IsCrouched())
|
||||||
return "Crouching"
|
return "Crouching"
|
||||||
return "OnGround"
|
return "OnGround"
|
||||||
}
|
}
|
||||||
@@ -195,7 +217,9 @@ string function GetMovementState(entity player){
|
|||||||
// 1. primary
|
// 1. primary
|
||||||
// 2. secondary
|
// 2. secondary
|
||||||
// 3. anti-titan
|
// 3. anti-titan
|
||||||
int function MainWeaponSort(entity a, entity b) {
|
int
|
||||||
|
|
||||||
|
function MainWeaponSort(entity a, entity b) {
|
||||||
int aID = a.GetDamageSourceID()
|
int aID = a.GetDamageSourceID()
|
||||||
int bID = b.GetDamageSourceID()
|
int bID = b.GetDamageSourceID()
|
||||||
|
|
||||||
@@ -213,11 +237,13 @@ int function MainWeaponSort(entity a, entity b) {
|
|||||||
return aIdx < bIdx ? -1 : 1
|
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
|
return index < weapons.len() ? weapons[index] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
string function GetWeaponName(entity weapon) {
|
string
|
||||||
|
function GetWeaponName(entity weapon) {
|
||||||
string s = "null"
|
string s = "null"
|
||||||
if (weapon != null) {
|
if (weapon != null) {
|
||||||
s = weapon.GetWeaponClassName()
|
s = weapon.GetWeaponClassName()
|
||||||
@@ -225,7 +251,8 @@ string function GetWeaponName(entity weapon) {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
int function GetWeaponMods(entity weapon) {
|
int
|
||||||
|
function GetWeaponMods(entity weapon) {
|
||||||
if (weapon == null) {
|
if (weapon == null) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -234,22 +261,26 @@ int function GetWeaponMods(entity weapon) {
|
|||||||
return modBits
|
return modBits
|
||||||
}
|
}
|
||||||
|
|
||||||
string function GetTitan(entity player) {
|
string
|
||||||
if(!player.IsTitan()) return "null"
|
function GetTitan(entity player) {
|
||||||
|
if (!player.IsTitan()) return "null"
|
||||||
return GetTitanCharacterName(player)
|
return GetTitanCharacterName(player)
|
||||||
}
|
}
|
||||||
|
|
||||||
void function Log(string s) {
|
void
|
||||||
|
function Log(string s) {
|
||||||
print(prefix + " " + s)
|
print(prefix + " " + s)
|
||||||
}
|
}
|
||||||
|
|
||||||
void function Tone_Test_Auth(){
|
void
|
||||||
|
function Tone_Test_Auth() {
|
||||||
HttpRequest request
|
HttpRequest request
|
||||||
request.method = HttpRequestMethod.POST
|
request.method = HttpRequestMethod.POST
|
||||||
request.url = file.Tone_URI + "/"
|
request.url = file.Tone_URI + "/"
|
||||||
Tone_HTTP_Request(
|
Tone_HTTP_Request(
|
||||||
request,
|
request,
|
||||||
void function ( HttpRequestResponse response ) {
|
void
|
||||||
|
function(HttpRequestResponse response) {
|
||||||
Log("Tone API Online !")
|
Log("Tone API Online !")
|
||||||
file.connected = true
|
file.connected = true
|
||||||
}
|
}
|
||||||
@@ -257,7 +288,8 @@ void function Tone_Test_Auth(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void function Tone_Register_Match(){
|
void
|
||||||
|
function Tone_Register_Match() {
|
||||||
HttpRequest request
|
HttpRequest request
|
||||||
request.method = HttpRequestMethod.POST
|
request.method = HttpRequestMethod.POST
|
||||||
request.url = file.Tone_URI + "/match"
|
request.url = file.Tone_URI + "/match"
|
||||||
@@ -268,7 +300,8 @@ void function Tone_Register_Match(){
|
|||||||
})
|
})
|
||||||
Tone_HTTP_Request(
|
Tone_HTTP_Request(
|
||||||
request,
|
request,
|
||||||
void function ( HttpRequestResponse response ) {
|
void
|
||||||
|
function(HttpRequestResponse response) {
|
||||||
Log("match ID : " + response.body)
|
Log("match ID : " + response.body)
|
||||||
file.matchId = response.body
|
file.matchId = response.body
|
||||||
}
|
}
|
||||||
@@ -276,28 +309,31 @@ void function Tone_Register_Match(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void function Tone_HTTP_Request(HttpRequest request, void functionref( HttpRequestResponse ) cbSuccess){
|
void
|
||||||
if(!request.method) request.method = HttpRequestMethod.POST
|
function Tone_HTTP_Request(HttpRequest request, void functionref(HttpRequestResponse) cbSuccess) {
|
||||||
if(request.url == ""){
|
if (!request.method) request.method = HttpRequestMethod.POST
|
||||||
|
if (request.url == "") {
|
||||||
Log("[ERRR] Couldn't find URI for request. This should be reported")
|
Log("[ERRR] Couldn't find URI for request. This should be reported")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
request.headers = {Authorization = ["Bearer "+ file.Tone_token]}
|
request.headers = {
|
||||||
|
Authorization = ["Bearer " + file.Tone_token]
|
||||||
|
}
|
||||||
|
|
||||||
NSHttpRequest(
|
NSHttpRequest(
|
||||||
request,
|
request,
|
||||||
void function ( HttpRequestResponse response ) : (cbSuccess)
|
void
|
||||||
{
|
function(HttpRequestResponse response): (cbSuccess) {
|
||||||
if(response.statusCode == 200 || response.statusCode == 201){
|
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||||
cbSuccess(response)
|
cbSuccess(response)
|
||||||
}else{
|
} else {
|
||||||
Log("[WARN] Something might be wrong with your token")
|
Log("[WARN] Something might be wrong with your token")
|
||||||
Log("[WARN]" + response.statusCode)
|
Log("[WARN]" + response.statusCode)
|
||||||
Log("[WARN]" + response.body)
|
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] Couldn't request the server! ToneAPI may be down.")
|
||||||
Log("[WARN]" + failure.errorCode)
|
Log("[WARN]" + failure.errorCode)
|
||||||
Log("[WARN]" + failure.errorMessage)
|
Log("[WARN]" + failure.errorMessage)
|
||||||
@@ -305,8 +341,27 @@ 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
|
||||||
|
}
|
||||||
|
|
||||||
array<int> MAIN_DAMAGE_SOURCES = [
|
string
|
||||||
|
function getPlayerPassive2(player entity) {
|
||||||
|
foreach(string passive in passive2Names) {
|
||||||
|
if (PlayerHasPassive(player, passive)) {
|
||||||
|
return passive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
array < int > MAIN_DAMAGE_SOURCES = [
|
||||||
// primaries
|
// primaries
|
||||||
eDamageSourceId.mp_weapon_car,
|
eDamageSourceId.mp_weapon_car,
|
||||||
eDamageSourceId.mp_weapon_r97,
|
eDamageSourceId.mp_weapon_r97,
|
||||||
@@ -344,3 +399,20 @@ array<int> MAIN_DAMAGE_SOURCES = [
|
|||||||
eDamageSourceId.mp_weapon_arc_launcher,
|
eDamageSourceId.mp_weapon_arc_launcher,
|
||||||
eDamageSourceId.mp_weapon_defender
|
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"
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user