diff options
author | William Miller <william-millennium@hotmail.com> | 2024-07-17 06:10:06 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 11:10:06 +0200 |
commit | 26d649fa7bf53e83758dd824297f402c8b9d174e (patch) | |
tree | ed39bb8f22d1dbff4fe11c425a0866b75199320c /Northstar.CustomServers | |
parent | f586107e62dc0dfa09f1b08cbf418d31d0346886 (diff) | |
download | NorthstarMods-26d649fa7bf53e83758dd824297f402c8b9d174e.tar.gz NorthstarMods-26d649fa7bf53e83758dd824297f402c8b9d174e.zip |
Fix "Kills by Auto-Titan" not registering at all (#817)
This is a quick fix that will redirect the attacker entity to a proper NPC owned by the player.
By default behavior of the game, attackers are always the final entity in the owning hiearchy, which is always a player if owned NPCs kills enemies.
This change properly redirects the code to the correct NPC whenever they have an owning player.
Diffstat (limited to 'Northstar.CustomServers')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut index 674923e7..74a9088b 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut @@ -493,23 +493,32 @@ void function HandleKillStats( entity victim, entity attacker, var damageInfo ) // get the player and it's pet titan entity player entity playerPetTitan - if ( attacker.IsPlayer() ) + entity inflictor = DamageInfo_GetInflictor( damageInfo ) + + if ( IsValid( inflictor ) ) { - // the player is just the attacker - player = attacker - playerPetTitan = player.GetPetTitan() + if ( inflictor.IsProjectile() && IsValid( inflictor.GetOwner() ) ) // Attackers are always the final entity in the owning hierarchy, projectile owners though migh be a player's NPC minion (i.e Auto-Titans) + attacker = inflictor.GetOwner() + + else if ( inflictor.IsNPC() ) // NPCs are bypassed as Attackers if they are owned by players, instead they become just inflictors + attacker = inflictor } - else if ( attacker.IsTitan() && IsPetTitan( attacker ) ) + + if ( attacker.IsNPC() ) { - // the attacker is the player's auto titan + if ( !attacker.IsTitan() ) // Normal NPCs case + return + + if ( !IsPetTitan( attacker ) ) // NPC Titans case + return + player = attacker.GetTitanSoul().GetBossPlayer() playerPetTitan = attacker } + else if ( attacker.IsPlayer() ) // Still checks this because worldspawn might be the attacker + player = attacker else - { - // attacker could be something like an NPC, or worldspawn return - } // check things once, for performance int damageSource = DamageInfo_GetDamageSourceIdentifier( damageInfo ) |