mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Migrate PMCs (sptBear/sptUsec) To Bsg Types (pmcBEAR/pmcUSEC) (!135)
Co-authored-by: Dev <dev@dev.sp-tarkov.com> Co-authored-by: Kaeno <kaeno@noreply.dev.sp-tarkov.com> Reviewed-on: SPT/Modules#135
This commit is contained in:
parent
cb5751c86f
commit
b6aeea95a2
@ -6,7 +6,7 @@ namespace SPT.Custom.CustomAI
|
|||||||
public static class AiHelpers
|
public static class AiHelpers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bot is a PMC when it has IsStreamerModeAvailable flagged and has a wildspawn type of 'sptBear' or 'sptUsec'
|
/// Bot is a PMC when it has IsStreamerModeAvailable flagged and has a wildspawn type of 'pmcBEAR' or 'pmcUSEC'
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="botRoleToCheck">Bots role</param>
|
/// <param name="botRoleToCheck">Bots role</param>
|
||||||
/// <param name="___botOwner_0">Bot details</param>
|
/// <param name="___botOwner_0">Bot details</param>
|
||||||
@ -19,7 +19,7 @@ namespace SPT.Custom.CustomAI
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)botRoleToCheck == SPTPrePatcher.sptBearValue || (int)botRoleToCheck == SPTPrePatcher.sptUsecValue;
|
return botRoleToCheck == WildSpawnType.pmcBEAR || botRoleToCheck == WildSpawnType.pmcUSEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool BotIsPlayerScav(WildSpawnType role, string nickname)
|
public static bool BotIsPlayerScav(WildSpawnType role, string nickname)
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Reflection;
|
//using System.Reflection;
|
||||||
using SPT.PrePatch;
|
//using SPT.PrePatch;
|
||||||
using SPT.Reflection.Patching;
|
//using SPT.Reflection.Patching;
|
||||||
using EFT;
|
//using EFT;
|
||||||
using HarmonyLib;
|
//using HarmonyLib;
|
||||||
|
|
||||||
namespace SPT.Custom.Patches
|
//namespace SPT.Custom.Patches
|
||||||
{
|
//{
|
||||||
public class AddSptBotSettingsPatch : ModulePatch
|
// public class AddSptBotSettingsPatch : ModulePatch
|
||||||
{
|
// {
|
||||||
protected override MethodBase GetTargetMethod()
|
// protected override MethodBase GetTargetMethod()
|
||||||
{
|
// {
|
||||||
return AccessTools.Method(typeof(BotSettingsRepoClass), nameof(BotSettingsRepoClass.Init));
|
// return AccessTools.Method(typeof(BotSettingsRepoClass), nameof(BotSettingsRepoClass.Init));
|
||||||
}
|
// }
|
||||||
|
|
||||||
[PatchPrefix]
|
// [PatchPrefix]
|
||||||
private static void PatchPrefix(ref Dictionary<WildSpawnType, BotSettingsValuesClass> ___dictionary_0)
|
// private static void PatchPrefix(ref Dictionary<WildSpawnType, BotSettingsValuesClass> ___dictionary_0)
|
||||||
{
|
// {
|
||||||
if (___dictionary_0.ContainsKey((WildSpawnType)SPTPrePatcher.sptUsecValue))
|
// if (___dictionary_0.ContainsKey((WildSpawnType)SPTPrePatcher.sptUsecValue))
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
___dictionary_0.Add((WildSpawnType)SPTPrePatcher.sptUsecValue, new BotSettingsValuesClass(false, false, false, EPlayerSide.Savage.ToStringNoBox()));
|
// ___dictionary_0.Add((WildSpawnType)SPTPrePatcher.sptUsecValue, new BotSettingsValuesClass(false, false, false, EPlayerSide.Savage.ToStringNoBox()));
|
||||||
___dictionary_0.Add((WildSpawnType)SPTPrePatcher.sptBearValue, new BotSettingsValuesClass(false, false, false, EPlayerSide.Savage.ToStringNoBox()));
|
// ___dictionary_0.Add((WildSpawnType)SPTPrePatcher.sptBearValue, new BotSettingsValuesClass(false, false, false, EPlayerSide.Savage.ToStringNoBox()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
@ -70,7 +70,7 @@ namespace SPT.Custom.Patches
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the client sometimes replaces PMC roles with 'assaultGroup', give PMCs their original role back (sptBear/sptUsec)
|
/// the client sometimes replaces PMC roles with 'assaultGroup', give PMCs their original role back (pmcBEAR/pmcUSEC)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>WildSpawnType</returns>
|
/// <returns>WildSpawnType</returns>
|
||||||
private static WildSpawnType FixAssaultGroupPmcsRole(BotOwner botOwner)
|
private static WildSpawnType FixAssaultGroupPmcsRole(BotOwner botOwner)
|
||||||
@ -81,8 +81,8 @@ namespace SPT.Custom.Patches
|
|||||||
|
|
||||||
// Its a PMC, figure out what the bot originally was and return it
|
// Its a PMC, figure out what the bot originally was and return it
|
||||||
return botOwner.Profile.Info.Side == EPlayerSide.Bear
|
return botOwner.Profile.Info.Side == EPlayerSide.Bear
|
||||||
? (WildSpawnType)SPTPrePatcher.sptBearValue
|
? WildSpawnType.pmcBEAR
|
||||||
: (WildSpawnType)SPTPrePatcher.sptUsecValue;
|
: WildSpawnType.pmcUSEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not broken pmc, return original role
|
// Not broken pmc, return original role
|
||||||
@ -99,7 +99,7 @@ namespace SPT.Custom.Patches
|
|||||||
{
|
{
|
||||||
if (AiHelpers.BotIsSptPmc(__state, ___botOwner_0))
|
if (AiHelpers.BotIsSptPmc(__state, ___botOwner_0))
|
||||||
{
|
{
|
||||||
// Set spt bot bot back to original type
|
// Set spt pmc bot back to original type
|
||||||
___botOwner_0.Profile.Info.Settings.Role = __state;
|
___botOwner_0.Profile.Info.Settings.Role = __state;
|
||||||
}
|
}
|
||||||
else if (AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname))
|
else if (AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname))
|
||||||
|
@ -21,6 +21,7 @@ namespace SPT.Custom.Patches
|
|||||||
return desiredMethod;
|
return desiredMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// method_6
|
||||||
private static bool IsTargetMethod(MethodInfo mi)
|
private static bool IsTargetMethod(MethodInfo mi)
|
||||||
{
|
{
|
||||||
var parameters = mi.GetParameters();
|
var parameters = mi.GetParameters();
|
||||||
|
29
project/SPT.Custom/Patches/PMCSpawnParamPatch.cs
Normal file
29
project/SPT.Custom/Patches/PMCSpawnParamPatch.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using EFT;
|
||||||
|
using HarmonyLib;
|
||||||
|
using SPT.Reflection.Patching;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace SPT.Custom.Patches
|
||||||
|
{
|
||||||
|
public class PMCSpawnParamPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(BotSpawner), nameof(BotSpawner.GetGroupAndSetEnemies));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
private static void PatchPrefix(BotOwner bot)
|
||||||
|
{
|
||||||
|
if (bot.SpawnProfileData.SpawnParams != null
|
||||||
|
&& (bot.Profile.Info.Settings.Role != WildSpawnType.pmcBEAR || bot.Profile.Info.Settings.Role != WildSpawnType.pmcUSEC))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add SpawnParams to PMC bots that are missing them
|
||||||
|
bot.SpawnProfileData.SpawnParams = new BotSpawnParams();
|
||||||
|
bot.SpawnProfileData.SpawnParams.ShallBeGroup = new ShallBeGroupParams(false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -43,7 +43,7 @@ namespace SPT.Custom.Patches
|
|||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static bool PatchPrefix(BotOwner ___botOwner_0)
|
private static bool PatchPrefix(BotOwner ___botOwner_0)
|
||||||
{
|
{
|
||||||
if (___botOwner_0.IsRole((WildSpawnType)SPTPrePatcher.sptUsecValue) || ___botOwner_0.IsRole((WildSpawnType)SPTPrePatcher.sptBearValue))
|
if (___botOwner_0.IsRole((WildSpawnType.pmcUSEC)) || ___botOwner_0.IsRole(WildSpawnType.pmcBEAR))
|
||||||
{
|
{
|
||||||
var healthController = ___botOwner_0.GetPlayer.ActiveHealthController;
|
var healthController = ___botOwner_0.GetPlayer.ActiveHealthController;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace SPT.Custom
|
|||||||
new AddEnemyToAllGroupsInBotZonePatch().Enable();
|
new AddEnemyToAllGroupsInBotZonePatch().Enable();
|
||||||
new AirdropPatch().Enable();
|
new AirdropPatch().Enable();
|
||||||
new AirdropFlarePatch().Enable();
|
new AirdropFlarePatch().Enable();
|
||||||
new AddSptBotSettingsPatch().Enable();
|
//new AddSptBotSettingsPatch().Enable();
|
||||||
new CustomAiPatch().Enable();
|
new CustomAiPatch().Enable();
|
||||||
new AddTraitorScavsPatch().Enable();
|
new AddTraitorScavsPatch().Enable();
|
||||||
new ExitWhileLootingPatch().Enable();
|
new ExitWhileLootingPatch().Enable();
|
||||||
@ -80,6 +80,7 @@ namespace SPT.Custom
|
|||||||
new DisablePvEPatch().Enable();
|
new DisablePvEPatch().Enable();
|
||||||
new InsurancePlaceItem().Enable();
|
new InsurancePlaceItem().Enable();
|
||||||
new FileCachePatch().Enable();
|
new FileCachePatch().Enable();
|
||||||
|
new PMCSpawnParamPatch().Enable();
|
||||||
|
|
||||||
HookObject.AddOrGetComponent<MenuNotificationManager>();
|
HookObject.AddOrGetComponent<MenuNotificationManager>();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ using HarmonyLib;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using EFT.Game.Spawning;
|
using EFT.Game.Spawning;
|
||||||
using System;
|
using System;
|
||||||
using SPT.PrePatch;
|
|
||||||
|
|
||||||
namespace SPT.Debugging.Patches
|
namespace SPT.Debugging.Patches
|
||||||
{
|
{
|
||||||
@ -17,7 +16,7 @@ namespace SPT.Debugging.Patches
|
|||||||
{
|
{
|
||||||
private readonly List<ISpawnPoint> playerSpawnPoints;
|
private readonly List<ISpawnPoint> playerSpawnPoints;
|
||||||
private readonly Random _rnd = new Random();
|
private readonly Random _rnd = new Random();
|
||||||
private readonly GStruct381 _spawnSettings = new GStruct381();
|
//private readonly GStruct381 _spawnSettings = new GStruct381();
|
||||||
|
|
||||||
public SptSpawnHelper()
|
public SptSpawnHelper()
|
||||||
{
|
{
|
||||||
@ -64,9 +63,8 @@ namespace SPT.Debugging.Patches
|
|||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
public static bool PatchPrefix(GClass1483 __instance, GClass591 data)
|
public static bool PatchPrefix(GClass1483 __instance, GClass591 data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var firstBotRole = data.Profiles[0].Info.Settings.Role;
|
var firstBotRole = data.Profiles[0].Info.Settings.Role;
|
||||||
if ((int)firstBotRole != SPTPrePatcher.sptBearValue || (int)firstBotRole != SPTPrePatcher.sptUsecValue)
|
if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC)
|
||||||
{
|
{
|
||||||
ConsoleScreen.Log("[SPT PMC Bot spawn] Spawning a set of Scavs. Skipping...");
|
ConsoleScreen.Log("[SPT PMC Bot spawn] Spawning a set of Scavs. Skipping...");
|
||||||
return true;
|
return true;
|
||||||
|
@ -11,16 +11,11 @@ namespace SPT.PrePatch
|
|||||||
public static class SPTPrePatcher
|
public static class SPTPrePatcher
|
||||||
{
|
{
|
||||||
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
|
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
|
||||||
|
private static readonly string _sptPluginFolder = "plugins/spt";
|
||||||
public static int sptUsecValue = 100;
|
|
||||||
public static int sptBearValue = 101;
|
|
||||||
|
|
||||||
private static string _sptPluginFolder = "plugins/spt";
|
|
||||||
|
|
||||||
public static void Patch(ref AssemblyDefinition assembly)
|
public static void Patch(ref AssemblyDefinition assembly)
|
||||||
{
|
{
|
||||||
PerformPreValidation();
|
PerformPreValidation();
|
||||||
AddCustomBotTypes(assembly);
|
|
||||||
ChangeAppDataPath(assembly);
|
ChangeAppDataPath(assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,25 +39,6 @@ namespace SPT.PrePatch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddCustomBotTypes(AssemblyDefinition assembly)
|
|
||||||
{
|
|
||||||
// Add custom EFT.WildSpawnTypes
|
|
||||||
var botEnums = assembly.MainModule.GetType("EFT.WildSpawnType");
|
|
||||||
|
|
||||||
var sptUsec = new FieldDefinition("sptUsec",
|
|
||||||
FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault,
|
|
||||||
botEnums)
|
|
||||||
{ Constant = sptUsecValue };
|
|
||||||
|
|
||||||
var sptBear = new FieldDefinition("sptBear",
|
|
||||||
FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault,
|
|
||||||
botEnums)
|
|
||||||
{ Constant = sptBearValue };
|
|
||||||
|
|
||||||
botEnums.Fields.Add(sptUsec);
|
|
||||||
botEnums.Fields.Add(sptBear);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<Instruction> GetCacheInstructions(AssemblyDefinition assembly)
|
private static List<Instruction> GetCacheInstructions(AssemblyDefinition assembly)
|
||||||
{
|
{
|
||||||
return new List<Instruction>
|
return new List<Instruction>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user