Skip to content

Commit

Permalink
Move assistances to new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon committed Jan 6, 2025
1 parent 570bd3b commit be16c87
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -795,13 +795,16 @@ bool function PlayerOrNPCKilled( entity ent, var damageInfo )

foreach( DamageHistoryStruct attackerInfo in victim.e.recentDamageHistory )
{
if ( !IsValidPlayer( attackerInfo.attacker ) || attackerInfo.attacker == victim )
if ( !IsValid( attackerInfo.attacker ) || !attackerInfo.attacker.IsPlayer() || attackerInfo.attacker == victim )
continue

bool exists = attackerInfo.attacker.GetEncodedEHandle() in alreadyAssisted ? true : false
if( attackerInfo.attacker != attacker && !exists )
{
alreadyAssisted[attackerInfo.attacker.GetEncodedEHandle()] <- true
foreach ( player in GetPlayerArray() )
Remote_CallFunction_Replay( player, "ServerCallback_SetAssistInformation", attackerInfo.damageSourceId, attacker.GetEncodedEHandle(), ent.GetEncodedEHandle(), attackerInfo.time )

foreach ( callback in svGlobal.onPlayerAssistCallbacks )
callback( attackerInfo.attacker, victim )
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void function BaseGametype_Init_MPSP()

AddCallback_OnNPCKilled( CheckForAutoTitanDeath )
AddCallback_OnPlayerKilled( CheckForAutoTitanDeath )
AddCallback_OnPlayerAssist( PlayerAssistedKill )
RegisterSignal( "PlayerRespawnStarted" )
RegisterSignal( "KillCamOver" )

Expand Down Expand Up @@ -250,6 +251,18 @@ void function CodeCallback_OnPlayerRespawned( entity player )
ClearLastAttacker( player ) // so dying to anything doesn't credit the same attacker after respawning
}

void function PlayerAssistedKill( entity attacker, entity victim )
{
if( victim.IsPlayer() )
{
AddPlayerScore( attacker, "PilotAssist" )
attacker.AddToPlayerGameStat( PGS_ASSISTS, 1 )

if ( attacker.IsPlayer() )
Highlight_SetDeathRecapHighlight( attacker, "killer_outline" )
}
}

void function CodeCallback_OnPlayerKilled( entity player, var damageInfo )
{
PlayerOrNPCKilled( player, damageInfo )
Expand Down Expand Up @@ -307,28 +320,6 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga
eHandle = inflictor.GetEncodedEHandle()
int methodOfDeath = DamageInfo_GetDamageSourceIdentifier( damageInfo )

table<int, bool> alreadyAssisted
if ( IsValid( attacker ) )
{
foreach( DamageHistoryStruct attackerInfo in player.e.recentDamageHistory )
{
if ( !IsValid( attackerInfo.attacker ) || !attackerInfo.attacker.IsPlayer() || attackerInfo.attacker == player )
continue

bool exists = attackerInfo.attacker.GetEncodedEHandle() in alreadyAssisted ? true : false
if( attackerInfo.attacker != attacker && !exists )
{
alreadyAssisted[attackerInfo.attacker.GetEncodedEHandle()] <- true
Remote_CallFunction_NonReplay( attackerInfo.attacker, "ServerCallback_SetAssistInformation", attackerInfo.damageSourceId, attacker.GetEncodedEHandle(), player.GetEncodedEHandle(), attackerInfo.time )
AddPlayerScore( attackerInfo.attacker, "PilotAssist" )
attackerInfo.attacker.AddToPlayerGameStat( PGS_ASSISTS, 1 )
}
}

if( attacker.IsPlayer() )
Highlight_SetDeathRecapHighlight( attacker, "killer_outline" )
}

player.p.rematchOrigin = player.p.deathOrigin
if ( IsValid( attacker ) && methodOfDeath == eDamageSourceId.titan_execution )
{
Expand Down
30 changes: 10 additions & 20 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_score.nut
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void function Score_Init()
{
SvXP_Init()
AddCallback_OnClientConnected( InitPlayerForScoreEvents )
AddCallback_OnPlayerAssist( TitanAssistedKill )
}

void function InitPlayerForScoreEvents( entity player )
Expand Down Expand Up @@ -216,30 +217,19 @@ void function ScoreEvent_TitanKilled( entity victim, entity attacker, var damage
AddPlayerScore( attacker, "KillTitan" )
}

entity soul = victim.GetTitanSoul()
if ( IsValid( soul ) )
{
table<int, bool> alreadyAssisted

foreach( DamageHistoryStruct attackerInfo in soul.e.recentDamageHistory )
{
if ( !IsValid( attackerInfo.attacker ) || !attackerInfo.attacker.IsPlayer() || attackerInfo.attacker == soul )
continue

bool exists = attackerInfo.attacker.GetEncodedEHandle() in alreadyAssisted ? true : false
if( attackerInfo.attacker != attacker && !exists )
{
alreadyAssisted[attackerInfo.attacker.GetEncodedEHandle()] <- true
AddPlayerScore(attackerInfo.attacker, "TitanAssist" )
Remote_CallFunction_NonReplay( attackerInfo.attacker, "ServerCallback_SetAssistInformation", attackerInfo.damageSourceId, attacker.GetEncodedEHandle(), soul.GetEncodedEHandle(), attackerInfo.time )
}
}
}

if( !victim.IsNPC() ) // don't let killing a npc titan plays dialogue
KilledPlayerTitanDialogue( attacker, victim )
}

void function TitanAssistedKill( entity attacker, entity victim )
{
if ( IsSoul( victim ) )
{
AddPlayerScore( attacker, "TitanAssist" )
attacker.AddToPlayerGameStat( PGS_ASSISTS, 1 )
}
}

void function ScoreEvent_NPCKilled( entity victim, entity attacker, var damageInfo )
{
try
Expand Down

0 comments on commit be16c87

Please sign in to comment.