diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index fa7e49a6..d02f37e9 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -432,6 +432,10 @@ public void HandleTeammateKill(ref DamageInfoStruct damage, EBodyPart bodyPart, return; } +#if DEBUG + FikaPlugin.Instance.FikaLogger.LogWarning($"HandleTeammateKill: Weapon {(damage.Weapon != null ? damage.Weapon.Name.Localized() : "None")}"); +#endif + if (role != WildSpawnType.pmcBEAR) { if (role == WildSpawnType.pmcUSEC) @@ -813,37 +817,13 @@ public override void OnDead(EDamageType damageType) { StartCoroutine(LocalPlayerDied()); } - } - - private void FindKillerWeapon() - { - GStruct448 itemResult = FindItemById(lastWeaponId, false, false); - if (!itemResult.Succeeded) - { - foreach (ThrowWeapItemClass grenadeClass in Singleton.Instance.CoopHandler.LocalGameInstance.ThrownGrenades) - { - if (grenadeClass.Id == lastWeaponId) - { - LastDamageInfo.Weapon = grenadeClass; - break; - } - } - return; - } - - LastDamageInfo.Weapon = itemResult.Value; - } + } /// /// TODO: Refactor... BSG code makes this difficult /// private void GenerateDogtagDetails() { - if (LastDamageInfo.Weapon is null && !string.IsNullOrEmpty(lastWeaponId)) - { - FindKillerWeapon(); - } - string accountId = AccountId; string profileId = ProfileId; string nickname = Profile.Nickname; diff --git a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs index 2ce268bd..7004b8b4 100644 --- a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs +++ b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs @@ -1548,6 +1548,30 @@ public void SetAggressorData(string killerId, EBodyPart bodyPart, string weaponI } LastBodyPart = bodyPart; lastWeaponId = weaponId; + + if (LastDamageInfo.Weapon is null && !string.IsNullOrEmpty(lastWeaponId)) + { + FindKillerWeapon(); + } + } + + private void FindKillerWeapon() + { + GStruct448 itemResult = FindItemById(lastWeaponId, false, false); + if (!itemResult.Succeeded) + { + foreach (ThrowWeapItemClass grenadeClass in Singleton.Instance.CoopHandler.LocalGameInstance.ThrownGrenades) + { + if (grenadeClass.Id == lastWeaponId) + { + LastDamageInfo.Weapon = grenadeClass; + break; + } + } + return; + } + + LastDamageInfo.Weapon = itemResult.Value; } private class RemoveHandsControllerHandler(ObservedCoopPlayer coopPlayer, Callback callback)