Skip to content

Commit

Permalink
Merge pull request #219 from project-fika/fix-easy-kill-conditions
Browse files Browse the repository at this point in the history
Fix kills not tracking
  • Loading branch information
Lacyway authored Dec 7, 2024
2 parents 01c56d0 + 5b959e3 commit 61e732e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
30 changes: 5 additions & 25 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -813,37 +817,13 @@ public override void OnDead(EDamageType damageType)
{
StartCoroutine(LocalPlayerDied());
}
}

private void FindKillerWeapon()
{
GStruct448<Item> itemResult = FindItemById(lastWeaponId, false, false);
if (!itemResult.Succeeded)
{
foreach (ThrowWeapItemClass grenadeClass in Singleton<IFikaNetworkManager>.Instance.CoopHandler.LocalGameInstance.ThrownGrenades)
{
if (grenadeClass.Id == lastWeaponId)
{
LastDamageInfo.Weapon = grenadeClass;
break;
}
}
return;
}

LastDamageInfo.Weapon = itemResult.Value;
}
}

/// <summary>
/// TODO: Refactor... BSG code makes this difficult
/// </summary>
private void GenerateDogtagDetails()
{
if (LastDamageInfo.Weapon is null && !string.IsNullOrEmpty(lastWeaponId))
{
FindKillerWeapon();
}

string accountId = AccountId;
string profileId = ProfileId;
string nickname = Profile.Nickname;
Expand Down
24 changes: 24 additions & 0 deletions Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item> itemResult = FindItemById(lastWeaponId, false, false);
if (!itemResult.Succeeded)
{
foreach (ThrowWeapItemClass grenadeClass in Singleton<IFikaNetworkManager>.Instance.CoopHandler.LocalGameInstance.ThrownGrenades)
{
if (grenadeClass.Id == lastWeaponId)
{
LastDamageInfo.Weapon = grenadeClass;
break;
}
}
return;
}

LastDamageInfo.Weapon = itemResult.Value;
}

private class RemoveHandsControllerHandler(ObservedCoopPlayer coopPlayer, Callback callback)
Expand Down

0 comments on commit 61e732e

Please sign in to comment.