Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to PlayerAssist callback #729

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,27 @@ bool function PlayerOrNPCKilled( entity ent, var damageInfo )
return true
}

void function HandleAssists( entity victim, var damageInfo )
{
if ( !victim.IsPlayer() )
return

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

if ( attackerInfo.attacker != attacker && !( attackerInfo.attacker.GetEncodedEHandle() in alreadyAssisted ) )
{
alreadyAssisted[attackerInfo.attacker.GetEncodedEHandle()] <- true
foreach ( callback in svGlobal.onPlayerAssistCallbacks )
callback( attacker, victim )
}
}
}

// used to calculate build time credit in special cases. Cloak Drones and Suicide Spectres use it for now.
float function CalculateBuildTimeCredit( entity attacker, entity target, float damage, int health, int maxHealth, string playlistVarStr, float defaultCredit )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void function CodeCallback_OnPlayerKilled( entity player, var damageInfo )
{
PlayerOrNPCKilled( player, damageInfo )
HandleDeathPackage( player, damageInfo )
HandleAssists( player, damageInfo )
thread PostDeathThread_MP( player, damageInfo )
}

Expand Down
Loading