From c8fbf1fb8ae44558c77978b44d14e1d6867a0407 Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 8 Jul 2024 14:18:07 +0100 Subject: [PATCH] Dogtags now get generated by BSG --- .../Patches/Quests/DogtagPatch.cs | 105 ------------------ .../SPT.SinglePlayer/SPTSingleplayerPlugin.cs | 1 - 2 files changed, 106 deletions(-) delete mode 100644 project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs diff --git a/project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs b/project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs deleted file mode 100644 index fb5a315..0000000 --- a/project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs +++ /dev/null @@ -1,105 +0,0 @@ -using SPT.Reflection.Patching; -using EFT; -using EFT.InventoryLogic; -using System; -using System.Reflection; -using HarmonyLib; - -namespace SPT.SinglePlayer.Patches.Quests -{ - public class DogtagPatch : ModulePatch - { - static DogtagPatch() - { - _ = nameof(EquipmentClass.GetSlot); - _ = nameof(DamageInfo.Weapon); - } - - protected override MethodBase GetTargetMethod() - { - return AccessTools.Method(typeof(Player), nameof(Player.OnBeenKilledByAggressor)); - } - - /// - /// Patch OnBeenKilledByAggressor() - /// - /// - /// Player who killed this individuak - /// Data on how they died - [PatchPostfix] - private static void PatchPostfix(Player __instance, Player aggressor, DamageInfo damageInfo) - { - if (__instance.Profile?.Info?.Side == EPlayerSide.Savage) - { - // Scav died, we don't care - return; - } - - Item dogtagItem = GetDogTagItemFromPlayerWhoDied(__instance); - if (dogtagItem == null) - { - if (__instance.IsYourPlayer) - { - // Human player, expected behaviour - return; - } - - Logger.LogError($"DogtagPatch error > DogTag slot item on: {__instance.Profile?.Info?.Nickname} is null somehow."); - return; - } - - var itemComponent = dogtagItem.GetItemComponent(); - if (itemComponent == null) - { - Logger.LogError("DogtagPatch error > DogTagComponent on dog tag slot is null. Something went horrifically wrong!"); - return; - } - - UpdateDogtagItemWithDeathDetails(__instance, aggressor, damageInfo, itemComponent); - } - - private static Item GetDogTagItemFromPlayerWhoDied(Player __instance) - { - var equipment = __instance.Equipment; - if (equipment == null) - { - Logger.LogError("DogtagPatch error > Player has no equipment"); - - return null; - } - - var dogtagSlot = equipment.GetSlot(EquipmentSlot.Dogtag); - if (dogtagSlot == null) - { - Logger.LogError("DogtagPatch error > Player has no dogtag slot"); - - return null; - } - - var dogtagItem = dogtagSlot?.ContainedItem; - - return dogtagItem; - } - - private static void UpdateDogtagItemWithDeathDetails(Player __instance, Player aggressor, DamageInfo damageInfo, DogtagComponent itemComponent) - { - var victimProfileInfo = __instance.Profile.Info; - - itemComponent.AccountId = __instance.Profile.AccountId; - itemComponent.ProfileId = __instance.Profile.Id; - itemComponent.Nickname = victimProfileInfo.Nickname; - itemComponent.Side = victimProfileInfo.Side; - itemComponent.KillerName = aggressor.Profile.Info.Nickname; - itemComponent.Time = DateTime.Now; - itemComponent.Status = "Killed by "; - itemComponent.KillerAccountId = aggressor.Profile.AccountId; - itemComponent.KillerProfileId = aggressor.Profile.Id; - itemComponent.WeaponName = damageInfo.Weapon.Name; - - if (__instance.Profile.Info.Experience > 0) - { - itemComponent.Level = victimProfileInfo.Level; - } - } - } -} diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index abed0f2..0c487e0 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -28,7 +28,6 @@ namespace SPT.SinglePlayer new EmptyInfilFixPatch().Enable(); new VoIPTogglerPatch().Enable(); new ScavExperienceGainPatch().Enable(); - new DogtagPatch().Enable(); new MainMenuControllerPatch().Enable(); new HealthControllerPatch().Enable(); new PlayerPatch().Enable();