diff --git a/project/SPT.Custom/Patches/BotEnemyTargetPatch.cs b/project/SPT.Custom/Patches/BotEnemyTargetPatch.cs deleted file mode 100644 index 9810079..0000000 --- a/project/SPT.Custom/Patches/BotEnemyTargetPatch.cs +++ /dev/null @@ -1,52 +0,0 @@ -using SPT.Reflection.Patching; -using EFT; -using System.Reflection; -using HarmonyLib; - -namespace SPT.Custom.Patches -{ - public class BotEnemyTargetPatch : ModulePatch - { - protected override MethodBase GetTargetMethod() - { - return AccessTools.Method(typeof(BotsController), nameof(BotsController.AddEnemyToAllGroupsInBotZone)); - } - - /// - /// AddEnemyToAllGroupsInBotZone() - /// Goal: by default, AddEnemyToAllGroupsInBotZone doesn't check if the bot group is on the same side as the player. - /// The effect of this is that when you are a Scav and kill a Usec, every bot group in the zone will aggro you including other Scavs. - /// This should fix that. - /// - [PatchPrefix] - private static bool PatchPrefix(BotsController __instance, IPlayer aggressor, IPlayer groupOwner, IPlayer target) - { - BotZone botZone = groupOwner.AIData.BotOwner.BotsGroup.BotZone; - foreach (var item in __instance.Groups()) - { - if (item.Key != botZone) - { - continue; - } - - foreach (var group in item.Value.GetGroups(notNull: true)) - { - if (!group.Enemies.ContainsKey(aggressor) && ShouldAttack(aggressor, target, group)) - { - group.AddEnemy(aggressor, EBotEnemyCause.AddEnemyToAllGroupsInBotZone); - } - } - } - - return false; - } - private static bool ShouldAttack(IPlayer attacker, IPlayer victim, BotsGroup groupToCheck) - { - // Group should target if player attack a victim on the same side or if the group is not on the same side as the player. - bool shouldAttack = attacker.Side != groupToCheck.Side - || attacker.Side == victim.Side; - - return !groupToCheck.HaveMemberWithRole(WildSpawnType.gifter) && groupToCheck.ShallRevengeFor(victim) && shouldAttack; - } - } -} diff --git a/project/SPT.Custom/Patches/BotSelfEnemyPatch.cs b/project/SPT.Custom/Patches/BotSelfEnemyPatch.cs deleted file mode 100644 index 97a0482..0000000 --- a/project/SPT.Custom/Patches/BotSelfEnemyPatch.cs +++ /dev/null @@ -1,40 +0,0 @@ -using SPT.Reflection.Patching; -using EFT; -using System.Reflection; -using HarmonyLib; - -namespace SPT.Custom.Patches -{ - /// - /// Goal: patch removes the current bot from its own enemy list - occurs when adding bots type to its enemy array in difficulty settings - /// - public class BotSelfEnemyPatch : ModulePatch - { - protected override MethodBase GetTargetMethod() - { - return AccessTools.Method(typeof(BotOwner), nameof(BotOwner.PreActivate)); - } - - [PatchPrefix] - private static bool PatchPrefix(BotOwner __instance, BotsGroup group) - { - IPlayer selfToRemove = null; - - foreach (var enemy in group.Enemies) - { - if (enemy.Key.Id == __instance.Id) - { - selfToRemove = enemy.Key; - break; - } - } - - if (selfToRemove != null) - { - group.Enemies.Remove(selfToRemove); - } - - return true; - } - } -} diff --git a/project/SPT.Custom/Patches/BotsGroupLetBossesShootPmcsPatch.cs b/project/SPT.Custom/Patches/BotsGroupLetBossesShootPmcsPatch.cs deleted file mode 100644 index 10c515a..0000000 --- a/project/SPT.Custom/Patches/BotsGroupLetBossesShootPmcsPatch.cs +++ /dev/null @@ -1,30 +0,0 @@ -using SPT.Reflection.Patching; -using System.Reflection; -using HarmonyLib; - -namespace SPT.Custom.Patches -{ - public class BotsGroupLetBossesShootPmcsPatch : ModulePatch - { - protected override MethodBase GetTargetMethod() - { - return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.CheckAndAddEnemy)); - } - - /// - /// CheckAndAddEnemy() - /// Goal: This patch lets bosses shoot back once a PMC has shot them - /// Force method to always run the code - /// - [PatchPrefix] - private static bool PatchPrefix(ref bool ignoreAI) - { - // original - // return player.HealthController.IsAlive && (!player.AIData.IsAI || ignoreAI) && !this.Enemies.ContainsKey(player) && this.AddEnemy(player, EBotEnemyCause.checkAddTODO); - ignoreAI = true; - - - return true; // Do Original - } - } -} diff --git a/project/SPT.Custom/Patches/SetLocationIdOnRaidStartPatch.cs b/project/SPT.Custom/Patches/SetLocationIdOnRaidStartPatch.cs deleted file mode 100644 index 7537d64..0000000 --- a/project/SPT.Custom/Patches/SetLocationIdOnRaidStartPatch.cs +++ /dev/null @@ -1,68 +0,0 @@ -using SPT.Reflection.Patching; -using SPT.Reflection.Utils; -using EFT; -using System.Linq; -using System.Reflection; -using Comfort.Common; -using System; -using static LocationSettingsClass; - -namespace SPT.Custom.Patches -{ - /// - /// Local games do not set the locationId property like a network game does, `LocationId` is used by various bsg systems - /// e.g. btr/lightkeeper services - /// - public class SetLocationIdOnRaidStartPatch : ModulePatch - { - private static PropertyInfo _locationProperty; - - protected override MethodBase GetTargetMethod() - { - Type localGameBaseType = PatchConstants.LocalGameType.BaseType; - - // At this point, gameWorld.MainPlayer isn't set, so we need to use the LocalGame's `Location_0` property - _locationProperty = localGameBaseType.GetProperties(PatchConstants.PublicDeclaredFlags) - .SingleCustom(x => x.PropertyType == typeof(Location)); - - // Find the TimeAndWeatherSettings handling method - var desiredMethod = localGameBaseType.GetMethods(PatchConstants.PublicDeclaredFlags).SingleOrDefault(IsTargetMethod); - - Logger.LogDebug($"{GetType().Name} Type: {localGameBaseType?.Name}"); - Logger.LogDebug($"{GetType().Name} Method: {desiredMethod?.Name}"); - - return desiredMethod; - } - - private static bool IsTargetMethod(MethodInfo mi) - { - // Find method_3(TimeAndWeatherSettings timeAndWeather) - var parameters = mi.GetParameters(); - return (parameters.Length == 1 && parameters[0].ParameterType == typeof(TimeAndWeatherSettings)); - } - - [PatchPostfix] - private static void PatchPostfix(AbstractGame __instance) - { - var gameWorld = Singleton.Instance; - - // EFT.HideoutGame is an internal class, so we can't do static type checking :( - if (__instance.GetType().Name.Contains("HideoutGame")) - { - return; - } - - Location location = _locationProperty.GetValue(__instance) as Location; - - if (location == null) - { - Logger.LogError($"[SetLocationId] Failed to get location data"); - return; - } - - gameWorld.LocationId = location.Id; - - Logger.LogDebug($"[SetLocationId] Set locationId to: {location.Id}"); - } - } -} diff --git a/project/SPT.Custom/SPTCustomPlugin.cs b/project/SPT.Custom/SPTCustomPlugin.cs index 8fd3e1e..d01efde 100644 --- a/project/SPT.Custom/SPTCustomPlugin.cs +++ b/project/SPT.Custom/SPTCustomPlugin.cs @@ -22,25 +22,20 @@ namespace SPT.Custom new EasyBundlePatch().Enable(); // TODO: check if these patches are needed - // new BotsGroupLetBossesShootPmcsPatch().Enable(); - new CustomAiPatch().Enable(); - new AddTraitorScavsPatch().Enable(); new PmcTakesAgesToHealLimbsPatch().Enable(); - new SendFleaListingTaxAmountToServerPatch().Enable(); new DisableNonHalloweenExitsDuringEventPatch().Enable(); - // new SetLocationIdOnRaidStartPatch().Enable(); // new AllScavsHostileHostileToPlayerScavPatch().Enable(); // new CopyPmcQuestsToPlayerScavPatch().Enable(); // new MergeScavPmcQuestsOnInventoryLoadPatch().Enable(); - // Needed but needs editing - new IsEnemyPatch().Enable(); - // Still need + new SendFleaListingTaxAmountToServerPatch().Enable(); + new AddTraitorScavsPatch().Enable(); + new IsEnemyPatch().Enable(); // Might be able to refactor + new CustomAiPatch().Enable(); new SaveSettingsToSptFolderPatch().Enable(); new QTEPatch().Enable(); new RedirectClientImageRequestsPatch().Enable(); - new BotSelfEnemyPatch().Enable(); new DisableGameModeAdjustButtonPatch().Enable(); new FixPmcSpawnParamsNullErrorPatch().Enable(); new SetPreRaidSettingsScreenDefaultsPatch().Enable();