From c331d1bd7308d2dd4d800f8a912d789882349e71 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:27:11 +0200 Subject: [PATCH] Replicate explosion armor damage --- Fika.Core/Coop/Players/CoopBot.cs | 29 ++++++++++++++++++ Fika.Core/Coop/Players/CoopPlayer.cs | 32 ++++++++++++++++++++ Fika.Core/Coop/Players/ObservedCoopPlayer.cs | 32 ++++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/Fika.Core/Coop/Players/CoopBot.cs b/Fika.Core/Coop/Players/CoopBot.cs index 4e0d7d88..aac4c2fe 100644 --- a/Fika.Core/Coop/Players/CoopBot.cs +++ b/Fika.Core/Coop/Players/CoopBot.cs @@ -174,6 +174,35 @@ public override ShotInfoClass ApplyShot(DamageInfo damageInfo, EBodyPart bodyPar return hitInfo; } + public override void ApplyExplosionDamageToArmor(Dictionary armorDamage, DamageInfo damageInfo) + { + _preAllocatedArmorComponents.Clear(); + Inventory.GetPutOnArmorsNonAlloc(_preAllocatedArmorComponents); + List armorComponents = []; + foreach (ArmorComponent armorComponent in _preAllocatedArmorComponents) + { + float num = 0f; + foreach (KeyValuePair keyValuePair in armorDamage) + { + if (armorComponent.ShotMatches(keyValuePair.Key.BodyPartColliderType, keyValuePair.Key.ArmorPlateCollider)) + { + num += keyValuePair.Value; + armorComponents.Add(armorComponent); + } + } + if (num > 0f) + { + num = armorComponent.ApplyExplosionDurabilityDamage(num, damageInfo, _preAllocatedArmorComponents); + method_95(num, armorComponent); + } + } + + if (armorComponents.Count > 0) + { + QueueArmorDamagePackets([.. armorComponents]); + } + } + public override void Proceed(Weapon weapon, Callback callback, bool scheduled = true) { BotFirearmControllerHandler handler = new(this, weapon); diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index d045a465..b12e1ca4 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -1310,6 +1310,38 @@ public virtual void HandleWeaponPacket(in WeaponPacket packet) } } + public override void ApplyExplosionDamageToArmor(Dictionary armorDamage, DamageInfo damageInfo) + { + if (IsYourPlayer) + { + _preAllocatedArmorComponents.Clear(); + Inventory.GetPutOnArmorsNonAlloc(_preAllocatedArmorComponents); + List armorComponents = []; + foreach (ArmorComponent armorComponent in _preAllocatedArmorComponents) + { + float num = 0f; + foreach (KeyValuePair keyValuePair in armorDamage) + { + if (armorComponent.ShotMatches(keyValuePair.Key.BodyPartColliderType, keyValuePair.Key.ArmorPlateCollider)) + { + num += keyValuePair.Value; + armorComponents.Add(armorComponent); + } + } + if (num > 0f) + { + num = armorComponent.ApplyExplosionDurabilityDamage(num, damageInfo, _preAllocatedArmorComponents); + method_95(num, armorComponent); + } + } + + if (armorComponents.Count > 0) + { + QueueArmorDamagePackets([.. armorComponents]); + } + } + } + public void QueueArmorDamagePackets(ArmorComponent[] armorComponents) { int amount = armorComponents.Length; diff --git a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs index 9e9bfd2f..d6f45db2 100644 --- a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs +++ b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs @@ -414,6 +414,38 @@ public override ShotInfoClass ApplyShot(DamageInfo damageInfo, EBodyPart bodyPar return hitInfo; } + public override void ApplyExplosionDamageToArmor(Dictionary armorDamage, DamageInfo damageInfo) + { + if (isServer) + { + _preAllocatedArmorComponents.Clear(); + Inventory.GetPutOnArmorsNonAlloc(_preAllocatedArmorComponents); + List armorComponents = []; + foreach (ArmorComponent armorComponent in _preAllocatedArmorComponents) + { + float num = 0f; + foreach (KeyValuePair keyValuePair in armorDamage) + { + if (armorComponent.ShotMatches(keyValuePair.Key.BodyPartColliderType, keyValuePair.Key.ArmorPlateCollider)) + { + num += keyValuePair.Value; + armorComponents.Add(armorComponent); + } + } + if (num > 0f) + { + num = armorComponent.ApplyExplosionDurabilityDamage(num, damageInfo, _preAllocatedArmorComponents); + method_95(num, armorComponent); + } + } + + if (armorComponents.Count > 0) + { + QueueArmorDamagePackets([.. armorComponents]); + } + } + } + public ShotInfoClass ApplyClientShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct400 shotId) { ShotReactions(damageInfo, bodyPartType);