diff --git a/project/SPT.Core/Patches/ConsistencySinglePatch.cs b/project/SPT.Core/Patches/ConsistencySinglePatch.cs index a75772b..a0dfccc 100644 --- a/project/SPT.Core/Patches/ConsistencySinglePatch.cs +++ b/project/SPT.Core/Patches/ConsistencySinglePatch.cs @@ -19,6 +19,7 @@ namespace SPT.Core.Patches private static bool PatchPrefix(ref object __result) { __result = Task.FromResult(new FakeFileCheckerResult()); + return false; } } diff --git a/project/SPT.Custom/CustomAI/AiHelpers.cs b/project/SPT.Custom/CustomAI/AiHelpers.cs index 857be59..9a21a6a 100644 --- a/project/SPT.Custom/CustomAI/AiHelpers.cs +++ b/project/SPT.Custom/CustomAI/AiHelpers.cs @@ -15,7 +15,7 @@ namespace SPT.Custom.CustomAI { if (___botOwner_0.Profile.Info.IsStreamerModeAvailable) { - // PMCs can sometimes have thier role changed to 'assaultGroup' by the client, we need a alternate way to figure out if they're a spt pmc + // PMCs can sometimes have their role changed to 'assaultGroup' by the client, we need an alternate way to figure out if they're a spt pmc return true; } diff --git a/project/SPT.Custom/Patches/AddTraitorScavsPatch.cs b/project/SPT.Custom/Patches/AddTraitorScavsPatch.cs index 1d21c8c..fac3f42 100644 --- a/project/SPT.Custom/Patches/AddTraitorScavsPatch.cs +++ b/project/SPT.Custom/Patches/AddTraitorScavsPatch.cs @@ -18,7 +18,7 @@ namespace SPT.Custom.Patches /// public class AddTraitorScavsPatch : ModulePatch { - private static int? TraitorChancePercent; + private static int? _traitorChancePercent; protected override MethodBase GetTargetMethod() { @@ -28,14 +28,14 @@ namespace SPT.Custom.Patches [PatchPrefix] public static bool PatchPrefix(ref BotsGroup __result, IBotGame ____game, DeadBodiesController ____deadBodiesController, BotOwner bot, BotZone zone) { - if (!TraitorChancePercent.HasValue) + if (!_traitorChancePercent.HasValue) { string json = RequestHandler.GetJson("/singleplayer/scav/traitorscavhostile"); - TraitorChancePercent = JsonConvert.DeserializeObject(json); + _traitorChancePercent = JsonConvert.DeserializeObject(json); } WildSpawnType role = bot.Profile.Info.Settings.Role; - if (AiHelpers.BotIsPlayerScav(role, bot.Profile.Info.Nickname) && new Random().Next(1, 100) < TraitorChancePercent) + if (AiHelpers.BotIsPlayerScav(role, bot.Profile.Info.Nickname) && new Random().Next(1, 100) < _traitorChancePercent) { Logger.LogInfo($"Making {bot.name} ({bot.Profile.Nickname}) hostile to player"); diff --git a/project/SPT.Custom/Patches/BossSpawnChancePatch.cs b/project/SPT.Custom/Patches/BossSpawnChancePatch.cs deleted file mode 100644 index 185e0d9..0000000 --- a/project/SPT.Custom/Patches/BossSpawnChancePatch.cs +++ /dev/null @@ -1,57 +0,0 @@ -using SPT.Reflection.Patching; -using SPT.Reflection.Utils; -using System.Linq; -using System.Reflection; - -namespace SPT.Custom.Patches -{ - /// - /// Boss spawn chance is 100%, all the time, this patch adjusts the chance to the maps boss wave value - /// - public class BossSpawnChancePatch : ModulePatch - { - private static float[] _bossSpawnPercent; - - protected override MethodBase GetTargetMethod() - { - var desiredType = PatchConstants.LocalGameType; - var desiredMethod = desiredType - .GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly) - .SingleOrDefault(IsTargetMethod); - - Logger.LogDebug($"{this.GetType().Name} Type: {desiredType.Name}"); - Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name ?? "NOT FOUND"}"); - - return desiredMethod; - } - - private static bool IsTargetMethod(MethodInfo mi) - { - var parameters = mi.GetParameters(); - return (parameters.Length == 3 - && parameters[0].Name == "isPVEOffline" - && parameters[1].Name == "wavesSettings" - && parameters[2].Name == "bossLocationSpawn"); - } - - [PatchPrefix] - public static void PatchPrefix(BossLocationSpawn[] bossLocationSpawn) - { - _bossSpawnPercent = bossLocationSpawn.Select(s => s.BossChance).ToArray(); - } - - [PatchPostfix] - public static void PatchPostfix(ref BossLocationSpawn[] __result) - { - if (__result.Length != _bossSpawnPercent.Length) - { - return; - } - - for (var i = 0; i < _bossSpawnPercent.Length; i++) - { - __result[i].BossChance = _bossSpawnPercent[i]; - } - } - } -} diff --git a/project/SPT.Custom/Patches/CopyPmcQuestsToPlayerScavPatch.cs b/project/SPT.Custom/Patches/CopyPmcQuestsToPlayerScavPatch.cs index 82014f7..b1dd457 100644 --- a/project/SPT.Custom/Patches/CopyPmcQuestsToPlayerScavPatch.cs +++ b/project/SPT.Custom/Patches/CopyPmcQuestsToPlayerScavPatch.cs @@ -28,8 +28,8 @@ namespace SPT.Custom.Patches // Iterate over all quests on pmc that are flagged as being for scavs foreach (var quest in pmcProfile.QuestsData.Where(x => x.Template?.PlayerGroup == EFT.EPlayerGroup.Scav)) { - // If quest doesn't exist in scav, add it - bool any = false; + // If quest doesn't exist in scav but does in pmc, add it + var any = false; foreach (var questInProfile in scavProfile.QuestsData) { if (questInProfile.Id == quest.Id) diff --git a/project/SPT.Custom/Patches/FixPmcSpawnParamsNullErrorPatch.cs b/project/SPT.Custom/Patches/FixPmcSpawnParamsNullErrorPatch.cs index 6f64699..52b3c9a 100644 --- a/project/SPT.Custom/Patches/FixPmcSpawnParamsNullErrorPatch.cs +++ b/project/SPT.Custom/Patches/FixPmcSpawnParamsNullErrorPatch.cs @@ -20,8 +20,8 @@ namespace SPT.Custom.Patches { return; } - - // Is a boss and follower and a pmc + + // Is a boss and follower and a pmc - nullguard SpawnParams property if (bot.SpawnProfileData.SpawnParams == null) { bot.SpawnProfileData.SpawnParams = new BotSpawnParams(); diff --git a/project/SPT.Custom/Patches/IsEnemyPatch.cs b/project/SPT.Custom/Patches/IsEnemyPatch.cs deleted file mode 100644 index 13c1139..0000000 --- a/project/SPT.Custom/Patches/IsEnemyPatch.cs +++ /dev/null @@ -1,132 +0,0 @@ -using SPT.Reflection.Patching; -using EFT; -using System.Linq; -using System.Reflection; -using HarmonyLib; - -namespace SPT.Custom.Patches -{ - public class IsEnemyPatch : ModulePatch - { - protected override MethodBase GetTargetMethod() - { - return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.IsEnemy)); - } - - /// - /// IsEnemy() - /// Goal: Make bots take Side into account when deciding if another player/bot is an enemy - /// Check enemy cache list first, if not found, check side, if they differ, add to enemy list and return true - /// Needed to ensure bot checks the enemy side, not just its botType - /// - [PatchPrefix] - public static bool PatchPrefix(ref bool __result, BotsGroup __instance, IPlayer player) - { - if (player == null) - { - __result = false; - - return false; // Skip original - } - - if (__instance.InitialBotType == WildSpawnType.peacefullZryachiyEvent - || __instance.InitialBotType == WildSpawnType.shooterBTR - || __instance.InitialBotType == WildSpawnType.gifter - || __instance.InitialBotType == WildSpawnType.sectantWarrior - || __instance.InitialBotType == WildSpawnType.sectantPriest - || __instance.InitialBotType == WildSpawnType.sectactPriestEvent - || __instance.InitialBotType == WildSpawnType.ravangeZryachiyEvent) - { - return true; // Do original code - } - - var isEnemy = false; // default not an enemy - - // Check existing enemies list - // Could also check x.Value.Player?.Id - BSG do it this way - if (!__instance.Enemies.IsNullOrEmpty() && __instance.Enemies.Any(x => x.Key.Id == player.Id)) - { - __result = true; - return false; // Skip original - } - - // Weird edge case - without this you get spammed with key already in enemy list error when you move around on lighthouse - // Make zryachiy use existing isEnemy() code - if (__instance.InitialBotType == WildSpawnType.bossZryachiy) - { - return false; // Skip original - } - - if (__instance.Side == EPlayerSide.Usec) - { - if (player.Side == EPlayerSide.Bear || player.Side == EPlayerSide.Savage || - ShouldAttackUsec(player)) - { - isEnemy = true; - __instance.AddEnemy(player, EBotEnemyCause.checkAddTODO); - } - } - else if (__instance.Side == EPlayerSide.Bear) - { - if (player.Side == EPlayerSide.Usec || player.Side == EPlayerSide.Savage || - ShouldAttackBear(player)) - { - isEnemy = true; - __instance.AddEnemy(player, EBotEnemyCause.checkAddTODO); - } - } - else if (__instance.Side == EPlayerSide.Savage) - { - if (player.Side != EPlayerSide.Savage) - { - //Lets exUsec warn Usecs and fire at will at Bears - if (__instance.InitialBotType == WildSpawnType.exUsec) - { - return true; // Do original method - } - // everyone else is an enemy to savage (scavs) - isEnemy = true; - __instance.AddEnemy(player, EBotEnemyCause.checkAddTODO); - } - } - - __result = isEnemy; - - return false; // Skip original - } - - /// - /// Return True when usec default behavior is attack + bot is usec - /// - /// - /// bool - private static bool ShouldAttackUsec(IPlayer requester) - { - var requesterMind = requester?.AIData?.BotOwner?.Settings?.FileSettings?.Mind; - - if (requesterMind == null) - { - return false; - } - - return requester.IsAI && requesterMind.DEFAULT_USEC_BEHAVIOUR == EWarnBehaviour.AlwaysEnemies && requester.Side == EPlayerSide.Usec; - } - - /// - /// Return True when bear default behavior is attack + bot is bear - /// - /// - /// - private static bool ShouldAttackBear(IPlayer requester) - { - var requesterMind = requester.AIData?.BotOwner?.Settings?.FileSettings?.Mind; - - if (requesterMind == null) - { - return false; - } - - return requester.IsAI && requesterMind.DEFAULT_BEAR_BEHAVIOUR == EWarnBehaviour.AlwaysEnemies && requester.Side == EPlayerSide.Bear; - } - } -} diff --git a/project/SPT.Debugging/Patches/PMCBotSpawnLocationPatch.cs b/project/SPT.Debugging/Patches/PMCBotSpawnLocationPatch.cs index b40d8d1..d375622 100644 --- a/project/SPT.Debugging/Patches/PMCBotSpawnLocationPatch.cs +++ b/project/SPT.Debugging/Patches/PMCBotSpawnLocationPatch.cs @@ -45,7 +45,7 @@ namespace SPT.Debugging.Patches // TODO: Fine-grained spawn selection if (count > this._playerSpawnPoints.Count()) { - ConsoleScreen.Log($"[SPT PMC Bot spawn] Wanted ${count} but only {this._playerSpawnPoints.Count()} found, returning all"); + ConsoleScreen.Log($"[SPT PMC Bot spawn] Wanted: ${count} but only {this._playerSpawnPoints.Count()} spawn points found, returning all"); return this._playerSpawnPoints; } return this._playerSpawnPoints.OrderBy(x => _rnd.Next()).Take(count).ToList(); @@ -64,7 +64,7 @@ namespace SPT.Debugging.Patches public static bool PatchPrefix(GClass1575 __instance, BotCreationDataClass data) { var firstBotRole = data.Profiles[0].Info.Settings.Role; - if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC) + if (firstBotRole is not (WildSpawnType.pmcBEAR or WildSpawnType.pmcUSEC)) { ConsoleScreen.Log("[SPT PMC Bot spawn] Spawning a set of Scavs. Skipping..."); return true; // Do original method diff --git a/project/SPT.SinglePlayer/Patches/MainMenu/PVEModeWelcomeMessagePatch.cs b/project/SPT.SinglePlayer/Patches/MainMenu/PVEModeWelcomeMessagePatch.cs index c71fdd0..0b68170 100644 --- a/project/SPT.SinglePlayer/Patches/MainMenu/PVEModeWelcomeMessagePatch.cs +++ b/project/SPT.SinglePlayer/Patches/MainMenu/PVEModeWelcomeMessagePatch.cs @@ -17,7 +17,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu if (variable == "pve_first_time") { __result = true; - return false; + return false; // Skip original method } return true; // Do original method diff --git a/project/SPT.SinglePlayer/Patches/MainMenu/RemoveClothingItemExternalObtainLabelPatch.cs b/project/SPT.SinglePlayer/Patches/MainMenu/RemoveClothingItemExternalObtainLabelPatch.cs index 31da705..ddedb7e 100644 --- a/project/SPT.SinglePlayer/Patches/MainMenu/RemoveClothingItemExternalObtainLabelPatch.cs +++ b/project/SPT.SinglePlayer/Patches/MainMenu/RemoveClothingItemExternalObtainLabelPatch.cs @@ -5,7 +5,7 @@ using System.Reflection; namespace SPT.SinglePlayer.Patches.MainMenu { /// - /// Remove the label shown on some of ragmans clothing options to "buy from website" + /// Remove the label shown on some of Ragmans clothing options to "buy from website" /// internal class RemoveClothingItemExternalObtainLabelPatch : ModulePatch { diff --git a/project/SPT.SinglePlayer/Patches/Progression/ScavExperienceGainPatch.cs b/project/SPT.SinglePlayer/Patches/Progression/ScavExperienceGainPatch.cs index 657a776..c6bb562 100644 --- a/project/SPT.SinglePlayer/Patches/Progression/ScavExperienceGainPatch.cs +++ b/project/SPT.SinglePlayer/Patches/Progression/ScavExperienceGainPatch.cs @@ -9,7 +9,7 @@ using HarmonyLib; namespace SPT.SinglePlayer.Patches.Progression { /// - /// Fix xp gained value being 0 after a scav raid + /// Fix XP gained value being 0 after a scav raid /// public class ScavExperienceGainPatch : ModulePatch {