0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 02: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]
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
____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)

View File

@ -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
{
/// <summary>
/// Temporarily trick client into thinking we are PMC and in offline mode to allow loading of scavs in PVE mode
/// </summary>
protected override MethodBase GetTargetMethod()
private static RaidSettings StoredRaidsettings { get; set; }
private static RaidSettings StoredRaidsettings1 { get; set; }
/// <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));
}
[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;
}
}
}

View File

@ -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)