diff --git a/project/SPT.Custom/Patches/SetPreRaidSettingsScreenDefaultsPatch.cs b/project/SPT.Custom/Patches/SetPreRaidSettingsScreenDefaultsPatch.cs index 4f02472..4fad5d0 100644 --- a/project/SPT.Custom/Patches/SetPreRaidSettingsScreenDefaultsPatch.cs +++ b/project/SPT.Custom/Patches/SetPreRaidSettingsScreenDefaultsPatch.cs @@ -22,10 +22,11 @@ namespace SPT.Custom.Patches [PatchPrefix] private static void PatchPrefix(object controller, UpdatableToggle ____offlineModeToggle) { - var raidSettings = Traverse.Create(controller).Field("RaidSettings").Value; + //var raidSettings = Traverse.Create(controller).Field("RaidSettings").Value; + var offlineRaidSettings = Traverse.Create(controller).Field("OfflineRaidSettings").Value; - // Default checkbox to be unchecked so we're in PvE - ____offlineModeToggle.isOn = false; + // Default checkbox to be unchecked so we're in PvE + ____offlineModeToggle.isOn = false; // Get settings from server var json = RequestHandler.GetJson("/singleplayer/settings/raid/menu"); @@ -37,15 +38,26 @@ namespace SPT.Custom.Patches return; } - raidSettings.BotSettings.BotAmount = settings.AiAmount; - raidSettings.WavesSettings.BotAmount = settings.AiAmount; - raidSettings.WavesSettings.BotDifficulty = settings.AiDifficulty; - raidSettings.WavesSettings.IsBosses = settings.BossEnabled; - raidSettings.BotSettings.IsScavWars = false; - raidSettings.WavesSettings.IsTaggedAndCursed = settings.TaggedAndCursed; - raidSettings.TimeAndWeatherSettings.IsRandomWeather = settings.RandomWeather; - raidSettings.TimeAndWeatherSettings.IsRandomTime = settings.RandomTime; - } + //raidSettings.BotSettings.BotAmount = settings.AiAmount; + //raidSettings.WavesSettings.BotAmount = settings.AiAmount; + //raidSettings.WavesSettings.BotDifficulty = settings.AiDifficulty; + //raidSettings.WavesSettings.IsBosses = settings.BossEnabled; + //raidSettings.BotSettings.IsScavWars = false; + //raidSettings.WavesSettings.IsTaggedAndCursed = settings.TaggedAndCursed; + //raidSettings.TimeAndWeatherSettings.IsRandomWeather = settings.RandomWeather; + //raidSettings.TimeAndWeatherSettings.IsRandomTime = settings.RandomTime; + + // We use PVE mode from Tarkov now we need to modify PVE MODE instead of ONLINE Mode + + offlineRaidSettings.BotSettings.BotAmount = settings.AiAmount; + offlineRaidSettings.WavesSettings.BotAmount = settings.AiAmount; + offlineRaidSettings.WavesSettings.BotDifficulty = settings.AiDifficulty; + offlineRaidSettings.WavesSettings.IsBosses = settings.BossEnabled; + offlineRaidSettings.BotSettings.IsScavWars = false; + offlineRaidSettings.WavesSettings.IsTaggedAndCursed = settings.TaggedAndCursed; + offlineRaidSettings.TimeAndWeatherSettings.IsRandomWeather = settings.RandomWeather; + offlineRaidSettings.TimeAndWeatherSettings.IsRandomTime = settings.RandomTime; + } [PatchPostfix] private static void PatchPostfix(MatchmakerOfflineRaidScreen __instance, DefaultUIButton ____changeSettingsButton, UiElementBlocker ____onlineBlocker) diff --git a/project/SPT.SinglePlayer/Patches/ScavMode/EnablePlayerScavPatch.cs b/project/SPT.SinglePlayer/Patches/ScavMode/EnablePlayerScavPatch.cs index 7d32b2f..e5f089d 100644 --- a/project/SPT.SinglePlayer/Patches/ScavMode/EnablePlayerScavPatch.cs +++ b/project/SPT.SinglePlayer/Patches/ScavMode/EnablePlayerScavPatch.cs @@ -1,31 +1,41 @@ -using EFT; +using Comfort.Common; +using EFT; using HarmonyLib; using SPT.Reflection.Patching; using System.Reflection; +using System.Runtime.CompilerServices; namespace SPT.SinglePlayer.Patches.ScavMode { public class EnablePlayerScavPatch : ModulePatch { - /// - /// Temporarily trick client into thinking we are PMC and in offline mode to allow loading of scavs in PVE mode - /// - protected override MethodBase GetTargetMethod() + + private static RaidSettings StoredRaidsettings { get; set; } + private static RaidSettings StoredRaidsettings1 { get; set; } + /// + /// Modifys the raidsettings to retain raidsettings options in menu and allows scav to load into raid + /// + protected override MethodBase GetTargetMethod() { return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_22)); } - [PatchPrefix] - private static void PatchPrefix(ref RaidSettings ___raidSettings_0) - { - ___raidSettings_0.RaidMode = ERaidMode.Local; - ___raidSettings_0.IsPveOffline = true; - } - [PatchPostfix] - private static void PatchPostfix(ref RaidSettings ___raidSettings_0) - { - ___raidSettings_0.RaidMode = ERaidMode.Online; - ___raidSettings_0.IsPveOffline = true; - } - } + [PatchPrefix] + private static void PatchPrefix(ref RaidSettings ___raidSettings_0, ref RaidSettings ___raidSettings_1, MainMenuController __instance) + { + StoredRaidsettings = ___raidSettings_0; + StoredRaidsettings1 = ___raidSettings_1; + ___raidSettings_0.RaidMode = ERaidMode.Local; + ___raidSettings_0.IsPveOffline = true; + ___raidSettings_0.WavesSettings = ___raidSettings_1.WavesSettings; + ___raidSettings_0.BotSettings = ___raidSettings_1.BotSettings; + ___raidSettings_1.Apply(___raidSettings_0); + } + [PatchPostfix] + private static void PatchPostfix(ref RaidSettings ___raidSettings_0) + { + ___raidSettings_0.RaidMode = ERaidMode.Online; + ___raidSettings_0.IsPveOffline = true; + } + } } diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index d43a2e6..bc6f80f 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -55,12 +55,12 @@ namespace SPT.SinglePlayer new DisableMatchmakerPlayerPreviewButtonsPatch().Enable(); new EnableRefForPVEPatch().Enable(); new EnableRefIntermScreenPatch().Enable(); - //new EnablePlayerScavPatch().Enable(); + new EnablePlayerScavPatch().Enable(); new ScavFoundInRaidPatch().Enable(); new GetProfileAtEndOfRaidPatch().Enable(); new FixSavageInventoryScreenPatch().Enable(); new InsuranceScreenPatch().Enable(); - //new ApplyRaidSettingsPatch().Enable(); + //new ApplyRaidSettingsPatch().Enable(); Should be no longer needed keeping here just to be safe. new FixQuestAchieveControllersPatch().Enable(); } catch (Exception ex)