0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 06:10:45 -05:00

Allow Scavs to enter raids and Raid setting should save correct now prayge

This commit is contained in:
Kaeno 2024-08-01 20:29:07 +01:00
parent edfe0451ac
commit 8e29dec47a
3 changed files with 54 additions and 32 deletions

View File

@ -22,10 +22,11 @@ namespace SPT.Custom.Patches
[PatchPrefix] [PatchPrefix]
private static void PatchPrefix(object controller, UpdatableToggle ____offlineModeToggle) private static void PatchPrefix(object controller, UpdatableToggle ____offlineModeToggle)
{ {
var raidSettings = Traverse.Create(controller).Field<RaidSettings>("RaidSettings").Value; //var raidSettings = Traverse.Create(controller).Field<RaidSettings>("RaidSettings").Value;
var offlineRaidSettings = Traverse.Create(controller).Field<RaidSettings>("OfflineRaidSettings").Value;
// Default checkbox to be unchecked so we're in PvE // Default checkbox to be unchecked so we're in PvE
____offlineModeToggle.isOn = false; ____offlineModeToggle.isOn = false;
// Get settings from server // Get settings from server
var json = RequestHandler.GetJson("/singleplayer/settings/raid/menu"); var json = RequestHandler.GetJson("/singleplayer/settings/raid/menu");
@ -37,15 +38,26 @@ namespace SPT.Custom.Patches
return; return;
} }
raidSettings.BotSettings.BotAmount = settings.AiAmount; //raidSettings.BotSettings.BotAmount = settings.AiAmount;
raidSettings.WavesSettings.BotAmount = settings.AiAmount; //raidSettings.WavesSettings.BotAmount = settings.AiAmount;
raidSettings.WavesSettings.BotDifficulty = settings.AiDifficulty; //raidSettings.WavesSettings.BotDifficulty = settings.AiDifficulty;
raidSettings.WavesSettings.IsBosses = settings.BossEnabled; //raidSettings.WavesSettings.IsBosses = settings.BossEnabled;
raidSettings.BotSettings.IsScavWars = false; //raidSettings.BotSettings.IsScavWars = false;
raidSettings.WavesSettings.IsTaggedAndCursed = settings.TaggedAndCursed; //raidSettings.WavesSettings.IsTaggedAndCursed = settings.TaggedAndCursed;
raidSettings.TimeAndWeatherSettings.IsRandomWeather = settings.RandomWeather; //raidSettings.TimeAndWeatherSettings.IsRandomWeather = settings.RandomWeather;
raidSettings.TimeAndWeatherSettings.IsRandomTime = settings.RandomTime; //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] [PatchPostfix]
private static void PatchPostfix(MatchmakerOfflineRaidScreen __instance, DefaultUIButton ____changeSettingsButton, UiElementBlocker ____onlineBlocker) private static void PatchPostfix(MatchmakerOfflineRaidScreen __instance, DefaultUIButton ____changeSettingsButton, UiElementBlocker ____onlineBlocker)

View File

@ -1,31 +1,41 @@
using EFT; using Comfort.Common;
using EFT;
using HarmonyLib; using HarmonyLib;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
namespace SPT.SinglePlayer.Patches.ScavMode namespace SPT.SinglePlayer.Patches.ScavMode
{ {
public class EnablePlayerScavPatch : ModulePatch public class EnablePlayerScavPatch : ModulePatch
{ {
/// <summary>
/// Temporarily trick client into thinking we are PMC and in offline mode to allow loading of scavs in PVE mode private static RaidSettings StoredRaidsettings { get; set; }
/// </summary> private static RaidSettings StoredRaidsettings1 { get; set; }
protected override MethodBase GetTargetMethod() /// <summary>
/// Modifys the raidsettings to retain raidsettings options in menu and allows scav to load into raid
/// </summary>
protected override MethodBase GetTargetMethod()
{ {
return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_22)); return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_22));
} }
[PatchPrefix] [PatchPrefix]
private static void PatchPrefix(ref RaidSettings ___raidSettings_0) private static void PatchPrefix(ref RaidSettings ___raidSettings_0, ref RaidSettings ___raidSettings_1, MainMenuController __instance)
{ {
___raidSettings_0.RaidMode = ERaidMode.Local; StoredRaidsettings = ___raidSettings_0;
___raidSettings_0.IsPveOffline = true; StoredRaidsettings1 = ___raidSettings_1;
} ___raidSettings_0.RaidMode = ERaidMode.Local;
[PatchPostfix] ___raidSettings_0.IsPveOffline = true;
private static void PatchPostfix(ref RaidSettings ___raidSettings_0) ___raidSettings_0.WavesSettings = ___raidSettings_1.WavesSettings;
{ ___raidSettings_0.BotSettings = ___raidSettings_1.BotSettings;
___raidSettings_0.RaidMode = ERaidMode.Online; ___raidSettings_1.Apply(___raidSettings_0);
___raidSettings_0.IsPveOffline = true; }
} [PatchPostfix]
} private static void PatchPostfix(ref RaidSettings ___raidSettings_0)
{
___raidSettings_0.RaidMode = ERaidMode.Online;
___raidSettings_0.IsPveOffline = true;
}
}
} }

View File

@ -55,12 +55,12 @@ namespace SPT.SinglePlayer
new DisableMatchmakerPlayerPreviewButtonsPatch().Enable(); new DisableMatchmakerPlayerPreviewButtonsPatch().Enable();
new EnableRefForPVEPatch().Enable(); new EnableRefForPVEPatch().Enable();
new EnableRefIntermScreenPatch().Enable(); new EnableRefIntermScreenPatch().Enable();
//new EnablePlayerScavPatch().Enable(); new EnablePlayerScavPatch().Enable();
new ScavFoundInRaidPatch().Enable(); new ScavFoundInRaidPatch().Enable();
new GetProfileAtEndOfRaidPatch().Enable(); new GetProfileAtEndOfRaidPatch().Enable();
new FixSavageInventoryScreenPatch().Enable(); new FixSavageInventoryScreenPatch().Enable();
new InsuranceScreenPatch().Enable(); new InsuranceScreenPatch().Enable();
//new ApplyRaidSettingsPatch().Enable(); //new ApplyRaidSettingsPatch().Enable(); Should be no longer needed keeping here just to be safe.
new FixQuestAchieveControllersPatch().Enable(); new FixQuestAchieveControllersPatch().Enable();
} }
catch (Exception ex) catch (Exception ex)