Skip to content

Commit

Permalink
Add validity check to HandleDistanceAndTimeStats_Threaded
Browse files Browse the repository at this point in the history
  • Loading branch information
CTalvio authored Dec 3, 2023
1 parent bdb73b1 commit a3ffc59
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut
Original file line number Diff line number Diff line change
Expand Up @@ -931,44 +931,47 @@ void function HandleDistanceAndTimeStats_Threaded()
// track distance stats
foreach ( entity player in GetPlayerArray() )
{
if ( player.p.lastPosForDistanceStatValid )
if ( IsValid(player) )
{
// not 100% sure on using Distance2D over Distance tbh
float distInches = Distance2D( player.p.lastPosForDistanceStat, player.GetOrigin() )
float distMiles = distInches / 63360.0

// more generic distance stats
Stats_IncrementStat( player, "distance_stats", "total", "", distMiles )
if ( player.IsTitan() )
{
Stats_IncrementStat( player, "distance_stats", "asTitan_" + GetTitanCharacterName( player ), "", distMiles )
Stats_IncrementStat( player, "distance_stats", "asTitan", "", distMiles )
}
else
Stats_IncrementStat( player, "distance_stats", "asPilot", "", distMiles )


string state = ""
// specific distance stats
if ( player.IsWallRunning() )
state = "wallrunning"
else if ( PlayerIsRodeoingTitan( player ) )
if ( player.p.lastPosForDistanceStatValid )
{
if ( player.GetTitanSoulBeingRodeoed().GetTeam() == player.GetTeam() )
state = "onFriendlyTitan"
// not 100% sure on using Distance2D over Distance tbh
float distInches = Distance2D( player.p.lastPosForDistanceStat, player.GetOrigin() )
float distMiles = distInches / 63360.0

// more generic distance stats
Stats_IncrementStat( player, "distance_stats", "total", "", distMiles )
if ( player.IsTitan() )
{
Stats_IncrementStat( player, "distance_stats", "asTitan_" + GetTitanCharacterName( player ), "", distMiles )
Stats_IncrementStat( player, "distance_stats", "asTitan", "", distMiles )
}
else
state = "onEnemyTitan"
Stats_IncrementStat( player, "distance_stats", "asPilot", "", distMiles )


string state = ""
// specific distance stats
if ( player.IsWallRunning() )
state = "wallrunning"
else if ( PlayerIsRodeoingTitan( player ) )
{
if ( player.GetTitanSoulBeingRodeoed().GetTeam() == player.GetTeam() )
state = "onFriendlyTitan"
else
state = "onEnemyTitan"
}
else if ( player.IsZiplining() )
state = "ziplining"
else if ( !player.IsOnGround() )
state = "inAir"

if ( state != "" )
Stats_IncrementStat( player, "distance_stats", state, "", distMiles )
}
else if ( player.IsZiplining() )
state = "ziplining"
else if ( !player.IsOnGround() )
state = "inAir"

if ( state != "" )
Stats_IncrementStat( player, "distance_stats", state, "", distMiles )
player.p.lastPosForDistanceStat = player.GetOrigin()
}

player.p.lastPosForDistanceStat = player.GetOrigin()
}

float timeSeconds = Time() - lastTickTime
Expand Down

0 comments on commit a3ffc59

Please sign in to comment.