diff --git a/project/SPT.Custom/Patches/PmcFirstAidPatch.cs b/project/SPT.Custom/Patches/PmcFirstAidPatch.cs index d620890..04b4bad 100644 --- a/project/SPT.Custom/Patches/PmcFirstAidPatch.cs +++ b/project/SPT.Custom/Patches/PmcFirstAidPatch.cs @@ -42,7 +42,7 @@ namespace SPT.Custom.Patches [PatchPrefix] private static bool PatchPrefix(BotOwner ___botOwner_0) { - if (___botOwner_0.IsRole((WildSpawnType.pmcUSEC)) || ___botOwner_0.IsRole(WildSpawnType.pmcBEAR)) + if (___botOwner_0.IsRole(WildSpawnType.pmcUSEC) || ___botOwner_0.IsRole(WildSpawnType.pmcBEAR)) { var healthController = ___botOwner_0.GetPlayer.ActiveHealthController; diff --git a/project/SPT.SinglePlayer/Patches/ScavMode/FixSavageInventoryScreenPatch.cs b/project/SPT.SinglePlayer/Patches/ScavMode/FixSavageInventoryScreenPatch.cs new file mode 100644 index 0000000..f2a4944 --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/ScavMode/FixSavageInventoryScreenPatch.cs @@ -0,0 +1,55 @@ +using EFT; +using HarmonyLib; +using SPT.Reflection.Patching; +using System.Reflection; +using System.Linq; + + +namespace SPT.SinglePlayer.Patches.ScavMode +{ + /// + /// Get Profile at LocalGame End to use in FixSavageInventoryScreenPatch + /// + public class GetProfileAtEndOfRaidPatch : ModulePatch + { + public static string Profile { get; private set; } + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(LocalGame), nameof(LocalGame.Stop)); + } + + [PatchPrefix] + private static void PatchPrefix(LocalGame __instance) + { + GetProfileAtEndOfRaidPatch.Profile = __instance.Profile_0.ToJson(); + } + } + /// + /// Get profile from other patch (GetProfileAtEndOfRaidPatch) + /// if our profile is savage Create new Session.AllProfiles and pass in our own profile to allow us to use the ScavengerInventoryScreen + /// + public class FixSavageInventoryScreenPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(PostRaidHealthScreenClass), nameof(PostRaidHealthScreenClass.method_2)); + } + + [PatchPrefix] + private static void PatchPrefix(ref ISession ___iSession) + { + var profile = GetProfileAtEndOfRaidPatch.Profile.ParseJsonTo(); + if (profile.Side != EPlayerSide.Savage) + { + return; + } + var session = (ProfileEndpointFactoryAbstractClass)___iSession; + session.AllProfiles = new Profile[] + { + session.AllProfiles.First(x => x.Side != EPlayerSide.Savage), + profile + }; + session.ProfileOfPet.UncoverAll(); + } + } +} diff --git a/project/SPT.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs b/project/SPT.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs index dc2c361..49878e4 100644 --- a/project/SPT.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs +++ b/project/SPT.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs @@ -124,7 +124,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode .Single(field => field.FieldType == typeof(MatchmakerPlayerControllerClass)) ?.GetValue(menuController) as MatchmakerPlayerControllerClass; - var gclass = new MatchmakerOfflineRaidScreen.CreateRaidSettingsForProfileClass(profile?.Info, ref raidSettings, matchmakerPlayersController, ESessionMode.Regular); + var gclass = new MatchmakerOfflineRaidScreen.CreateRaidSettingsForProfileClass(profile?.Info, ref raidSettings, matchmakerPlayersController, ESessionMode.Pve); gclass.OnShowNextScreen += LoadOfflineRaidNextScreen; diff --git a/project/SPT.SinglePlayer/Patches/ScavMode/ScavExfilPatchOld.cs b/project/SPT.SinglePlayer/Patches/ScavMode/ScavExfilPatchOld.cs deleted file mode 100644 index d92628c..0000000 --- a/project/SPT.SinglePlayer/Patches/ScavMode/ScavExfilPatchOld.cs +++ /dev/null @@ -1,123 +0,0 @@ -using SPT.Reflection.CodeWrapper; -using SPT.Reflection.Patching; -using SPT.Reflection.Utils; -using EFT; -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Reflection.Emit; -using UnityEngine; - -namespace SPT.SinglePlayer.Patches.ScavMode -{ - public class ScavExfilPatchOld : ModulePatch - { - private static Type _profileType; - private static Type _profileInfoType; - private static Type _fenceTraderInfoType; - - static ScavExfilPatchOld() - { - _profileType = PatchConstants.EftTypes.Single(x => x.GetMethod("AddToCarriedQuestItems") != null); - _profileInfoType = PatchConstants.EftTypes.Single(x => x.GetMethod("GetExperience") != null); - _fenceTraderInfoType = PatchConstants.EftTypes.Single(x => x.GetMethod("NewExfiltrationPrice") != null); - } - - protected override MethodBase GetTargetMethod() - { - var desiredType = PatchConstants.LocalGameType.BaseType; - var desiredMethod = desiredType - .GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.CreateInstance) - .Single(IsTargetMethod); - - Logger.LogDebug($"{this.GetType().Name} Type: {desiredType?.Name}"); - Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name}"); - - return desiredMethod; - } - - private static bool IsTargetMethod(MethodInfo methodInfo) - { - return (methodInfo.IsVirtual - && methodInfo.GetParameters().Length == 0 - && methodInfo.ReturnType == typeof(void) - && methodInfo.GetMethodBody().LocalVariables.Count > 0); - } - - [PatchTranspiler] - private static IEnumerable PatchTranspile(ILGenerator generator, IEnumerable instructions) - { - var codes = new List(instructions); - var searchCode = new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(PatchConstants.ExfilPointManagerType, "EligiblePoints", new System.Type[] { typeof(Profile) })); - var searchIndex = -1; - - for (var i = 0; i < codes.Count; i++) - { - if (codes[i].opcode == searchCode.opcode && codes[i].operand == searchCode.operand) - { - searchIndex = i; - break; - } - } - - // Patch failed. - if (searchIndex == -1) - { - Logger.LogError(string.Format("Patch {0} failed: Could not find reference code.", MethodBase.GetCurrentMethod())); - return instructions; - } - - searchIndex -= 3; - - var brFalseLabel = generator.DefineLabel(); - var brLabel = generator.DefineLabel(); - var newCodes = CodeGenerator.GenerateInstructions(new List() - { - new Code(OpCodes.Ldarg_0), - new Code(OpCodes.Call, PatchConstants.LocalGameType.BaseType, "get_Profile_0"), - new Code(OpCodes.Ldfld, typeof(Profile), "Info"), - new Code(OpCodes.Ldfld, _profileInfoType, "Side"), - new Code(OpCodes.Ldc_I4_4), - new Code(OpCodes.Ceq), - new Code(OpCodes.Brfalse, brFalseLabel), - new Code(OpCodes.Call, PatchConstants.ExfilPointManagerType, "get_Instance"), - new Code(OpCodes.Ldarg_0), - new Code(OpCodes.Ldfld, PatchConstants.LocalGameType.BaseType, "gparam_0"), - new Code(OpCodes.Box, typeof(PlayerOwner)), - new Code(OpCodes.Callvirt, typeof(PlayerOwner), "get_Player"), - new Code(OpCodes.Callvirt, typeof(Player), "get_Position"), - new Code(OpCodes.Ldarg_0), - new Code(OpCodes.Call, PatchConstants.LocalGameType.BaseType, "get_Profile_0"), - new Code(OpCodes.Ldfld, typeof(Profile), "Id"), - new Code(OpCodes.Ldarg_0), - new Code(OpCodes.Call, PatchConstants.LocalGameType.BaseType, "get_Profile_0"), - new Code(OpCodes.Call, _profileType, "get_FenceInfo"), - new Code(OpCodes.Call, _fenceTraderInfoType, "get_AvailableExitsCount"), - new Code(OpCodes.Callvirt, PatchConstants.ExfilPointManagerType, "ScavExfiltrationClaim", new System.Type[]{ typeof(Vector3), typeof(string), typeof(int) }), - new Code(OpCodes.Call, PatchConstants.ExfilPointManagerType, "get_Instance"), - new Code(OpCodes.Call, PatchConstants.ExfilPointManagerType, "get_Instance"), - new Code(OpCodes.Ldarg_0), - new Code(OpCodes.Call, PatchConstants.LocalGameType.BaseType, "get_Profile_0"), - new Code(OpCodes.Ldfld, typeof(Profile), "Id"), - new Code(OpCodes.Callvirt, PatchConstants.ExfilPointManagerType, "GetScavExfiltrationMask"), - new Code(OpCodes.Ldarg_0), - new Code(OpCodes.Call, PatchConstants.LocalGameType.BaseType, "get_Profile_0"), - new Code(OpCodes.Ldfld, typeof(Profile), "Id"), - new Code(OpCodes.Callvirt, PatchConstants.ExfilPointManagerType, "ScavExfiltrationClaim", new System.Type[]{ typeof(int), typeof(string) }), - new Code(OpCodes.Br, brLabel), - new CodeWithLabel(OpCodes.Call, brFalseLabel, PatchConstants.ExfilPointManagerType, "get_Instance"), - new Code(OpCodes.Ldarg_0), - new Code(OpCodes.Call, PatchConstants.LocalGameType.BaseType, "get_Profile_0"), - new Code(OpCodes.Callvirt, PatchConstants.ExfilPointManagerType, "EligiblePoints", new System.Type[]{ typeof(Profile) }), - new CodeWithLabel(OpCodes.Stloc_2, brLabel) - }); - - codes.RemoveRange(searchIndex, 5); - codes.InsertRange(searchIndex, newCodes); - - return codes.AsEnumerable(); - } - } -} \ No newline at end of file diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index 61bd5a6..15b5150 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -26,7 +26,6 @@ namespace SPT.SinglePlayer new TinnitusFixPatch().Enable(); new SmokeGrenadeFuseSoundFixPatch().Enable(); new EmptyInfilFixPatch().Enable(); - new ScavExperienceGainPatch().Enable(); new MainMenuControllerPatch().Enable(); new HealthControllerPatch().Enable(); new PlayerPatch().Enable(); @@ -34,10 +33,11 @@ namespace SPT.SinglePlayer new PostRaidHealingPricePatch().Enable(); new InRaidQuestAvailablePatch().Enable(); new ExfilPointManagerPatch().Enable(); - new ScavEncyclopediaPatch().Enable(); new HideoutQuestIgnorePatch().Enable(); new SpawnProcessNegativeValuePatch().Enable(); new SpawnPmcPatch().Enable(); + new ScavExperienceGainPatch().Enable(); + new ScavEncyclopediaPatch().Enable(); new ScavProfileLoadPatch().Enable(); new ScavPrefabLoadPatch().Enable(); new ScavExfilPatch().Enable(); @@ -46,7 +46,7 @@ namespace SPT.SinglePlayer new GetTraderServicesPatch().Enable(); new PurchaseTraderServicePatch().Enable(); new LightKeeperServicesPatch().Enable(); - + // Still need new DisableReadyLocationReadyPatch().Enable(); new BotTemplateLimitPatch().Enable(); @@ -56,7 +56,6 @@ namespace SPT.SinglePlayer new ScavRepAdjustmentPatch().Enable(); new PluginErrorNotifierPatch().Enable(); new GetNewBotTemplatesPatch().Enable(); - new ScavLateStartPatch().Enable(); new LabsKeycardRemovalPatch().Enable(); new MapReadyButtonPatch().Enable(); new RemoveUsedBotProfilePatch().Enable(); @@ -70,6 +69,8 @@ namespace SPT.SinglePlayer new EnableRefIntermScreenPatch().Enable(); new EnablePlayerScavPatch().Enable(); new ScavFoundInRaidPatch().Enable(); + new GetProfileAtEndOfRaidPatch().Enable(); + new FixSavageInventoryScreenPatch().Enable(); } catch (Exception ex) {