diff --git a/project/SPT.SinglePlayer/Patches/ScavMode/ScavIsPlayerEnemyPatch.cs b/project/SPT.SinglePlayer/Patches/ScavMode/ScavIsPlayerEnemyPatch.cs new file mode 100644 index 0000000..1f4611b --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/ScavMode/ScavIsPlayerEnemyPatch.cs @@ -0,0 +1,29 @@ +using EFT; +using HarmonyLib; +using SPT.Reflection.Patching; +using System.Reflection; + +namespace SPT.SinglePlayer.Patches.ScavMode +{ + /// + /// This patch ensures that PMC AI is always hostile towards the player and scavs if the player it checks is a (scav) + /// + public class ScavIsPlayerEnemyPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.IsPlayerEnemy)); + } + + [PatchPrefix] + public static bool Prefix(BotsGroup __instance, IPlayer player, ref bool __result) + { + if (player.Side is EPlayerSide.Savage && __instance.InitialBotType is WildSpawnType.pmcBEAR or WildSpawnType.pmcUSEC) + { + __result = true; + return false; + } + return true; + } + } +} diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index 8d79316..f98f134 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -60,6 +60,7 @@ namespace SPT.SinglePlayer new RemoveStashUpgradeLabelPatch().Enable(); new RemoveClothingItemExternalObtainLabelPatch().Enable(); new FixLocalRaidPatch().Enable(); + new ScavIsPlayerEnemyPatch().Enable(); } catch (Exception ex) {