From 4c04ed5aeac0d4753ed08012167258d2f22ea41c Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sun, 24 Nov 2024 20:19:16 -0300 Subject: [PATCH] Add assist callback logic --- .../scripts/vscripts/mp/_base_gametype.gnut | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut index 362407b39..f96e0792f 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut @@ -786,6 +786,26 @@ bool function PlayerOrNPCKilled( entity ent, var damageInfo ) ScoreEvent_TitanKilled( ent, attacker, damageInfo ) else ScoreEvent_NPCKilled( ent, attacker, damageInfo ) + + entity victim = ent.IsTitan() ? ent.GetTitanSoul() : ent + if ( IsValid( victim ) ) + { + table alreadyAssisted + + foreach( DamageHistoryStruct attackerInfo in victim.e.recentDamageHistory ) + { + if ( !IsValidPlayer( attackerInfo.attacker ) || attackerInfo.attacker == victim ) + continue + + bool exists = attackerInfo.attacker.GetEncodedEHandle() in alreadyAssisted ? true : false + if( attackerInfo.attacker != attacker && !exists ) + { + alreadyAssisted[attackerInfo.attacker.GetEncodedEHandle()] <- true + foreach ( callback in svGlobal.onPlayerAssistCallbacks ) + callback( attackerInfo.attacker, victim ) + } + } + } } PostScoreEventUpdateStats( attacker, ent )