mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:30:46 -05:00
Small patch clean up - fixed issue with pmc spawn location patch not working as intended
This commit is contained in:
parent
990b6edf0b
commit
4a187bef22
@ -19,6 +19,7 @@ namespace SPT.Core.Patches
|
|||||||
private static bool PatchPrefix(ref object __result)
|
private static bool PatchPrefix(ref object __result)
|
||||||
{
|
{
|
||||||
__result = Task.FromResult<ICheckResult>(new FakeFileCheckerResult());
|
__result = Task.FromResult<ICheckResult>(new FakeFileCheckerResult());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace SPT.Custom.CustomAI
|
|||||||
{
|
{
|
||||||
if (___botOwner_0.Profile.Info.IsStreamerModeAvailable)
|
if (___botOwner_0.Profile.Info.IsStreamerModeAvailable)
|
||||||
{
|
{
|
||||||
// PMCs can sometimes have thier role changed to 'assaultGroup' by the client, we need a alternate way to figure out if they're a spt pmc
|
// PMCs can sometimes have their role changed to 'assaultGroup' by the client, we need an alternate way to figure out if they're a spt pmc
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace SPT.Custom.Patches
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class AddTraitorScavsPatch : ModulePatch
|
public class AddTraitorScavsPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static int? TraitorChancePercent;
|
private static int? _traitorChancePercent;
|
||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
@ -28,14 +28,14 @@ namespace SPT.Custom.Patches
|
|||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
public static bool PatchPrefix(ref BotsGroup __result, IBotGame ____game, DeadBodiesController ____deadBodiesController, BotOwner bot, BotZone zone)
|
public static bool PatchPrefix(ref BotsGroup __result, IBotGame ____game, DeadBodiesController ____deadBodiesController, BotOwner bot, BotZone zone)
|
||||||
{
|
{
|
||||||
if (!TraitorChancePercent.HasValue)
|
if (!_traitorChancePercent.HasValue)
|
||||||
{
|
{
|
||||||
string json = RequestHandler.GetJson("/singleplayer/scav/traitorscavhostile");
|
string json = RequestHandler.GetJson("/singleplayer/scav/traitorscavhostile");
|
||||||
TraitorChancePercent = JsonConvert.DeserializeObject<int>(json);
|
_traitorChancePercent = JsonConvert.DeserializeObject<int>(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
WildSpawnType role = bot.Profile.Info.Settings.Role;
|
WildSpawnType role = bot.Profile.Info.Settings.Role;
|
||||||
if (AiHelpers.BotIsPlayerScav(role, bot.Profile.Info.Nickname) && new Random().Next(1, 100) < TraitorChancePercent)
|
if (AiHelpers.BotIsPlayerScav(role, bot.Profile.Info.Nickname) && new Random().Next(1, 100) < _traitorChancePercent)
|
||||||
{
|
{
|
||||||
Logger.LogInfo($"Making {bot.name} ({bot.Profile.Nickname}) hostile to player");
|
Logger.LogInfo($"Making {bot.name} ({bot.Profile.Nickname}) hostile to player");
|
||||||
|
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
using SPT.Reflection.Patching;
|
|
||||||
using SPT.Reflection.Utils;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace SPT.Custom.Patches
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Boss spawn chance is 100%, all the time, this patch adjusts the chance to the maps boss wave value
|
|
||||||
/// </summary>
|
|
||||||
public class BossSpawnChancePatch : ModulePatch
|
|
||||||
{
|
|
||||||
private static float[] _bossSpawnPercent;
|
|
||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
|
||||||
{
|
|
||||||
var desiredType = PatchConstants.LocalGameType;
|
|
||||||
var desiredMethod = desiredType
|
|
||||||
.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly)
|
|
||||||
.SingleOrDefault(IsTargetMethod);
|
|
||||||
|
|
||||||
Logger.LogDebug($"{this.GetType().Name} Type: {desiredType.Name}");
|
|
||||||
Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name ?? "NOT FOUND"}");
|
|
||||||
|
|
||||||
return desiredMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsTargetMethod(MethodInfo mi)
|
|
||||||
{
|
|
||||||
var parameters = mi.GetParameters();
|
|
||||||
return (parameters.Length == 3
|
|
||||||
&& parameters[0].Name == "isPVEOffline"
|
|
||||||
&& parameters[1].Name == "wavesSettings"
|
|
||||||
&& parameters[2].Name == "bossLocationSpawn");
|
|
||||||
}
|
|
||||||
|
|
||||||
[PatchPrefix]
|
|
||||||
public static void PatchPrefix(BossLocationSpawn[] bossLocationSpawn)
|
|
||||||
{
|
|
||||||
_bossSpawnPercent = bossLocationSpawn.Select(s => s.BossChance).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
[PatchPostfix]
|
|
||||||
public static void PatchPostfix(ref BossLocationSpawn[] __result)
|
|
||||||
{
|
|
||||||
if (__result.Length != _bossSpawnPercent.Length)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < _bossSpawnPercent.Length; i++)
|
|
||||||
{
|
|
||||||
__result[i].BossChance = _bossSpawnPercent[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,8 +28,8 @@ namespace SPT.Custom.Patches
|
|||||||
// Iterate over all quests on pmc that are flagged as being for scavs
|
// Iterate over all quests on pmc that are flagged as being for scavs
|
||||||
foreach (var quest in pmcProfile.QuestsData.Where(x => x.Template?.PlayerGroup == EFT.EPlayerGroup.Scav))
|
foreach (var quest in pmcProfile.QuestsData.Where(x => x.Template?.PlayerGroup == EFT.EPlayerGroup.Scav))
|
||||||
{
|
{
|
||||||
// If quest doesn't exist in scav, add it
|
// If quest doesn't exist in scav but does in pmc, add it
|
||||||
bool any = false;
|
var any = false;
|
||||||
foreach (var questInProfile in scavProfile.QuestsData)
|
foreach (var questInProfile in scavProfile.QuestsData)
|
||||||
{
|
{
|
||||||
if (questInProfile.Id == quest.Id)
|
if (questInProfile.Id == quest.Id)
|
||||||
|
@ -21,7 +21,7 @@ namespace SPT.Custom.Patches
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is a boss and follower and a pmc
|
// Is a boss and follower and a pmc - nullguard SpawnParams property
|
||||||
if (bot.SpawnProfileData.SpawnParams == null)
|
if (bot.SpawnProfileData.SpawnParams == null)
|
||||||
{
|
{
|
||||||
bot.SpawnProfileData.SpawnParams = new BotSpawnParams();
|
bot.SpawnProfileData.SpawnParams = new BotSpawnParams();
|
||||||
|
@ -1,132 +0,0 @@
|
|||||||
using SPT.Reflection.Patching;
|
|
||||||
using EFT;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace SPT.Custom.Patches
|
|
||||||
{
|
|
||||||
public class IsEnemyPatch : ModulePatch
|
|
||||||
{
|
|
||||||
protected override MethodBase GetTargetMethod()
|
|
||||||
{
|
|
||||||
return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.IsEnemy));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// IsEnemy()
|
|
||||||
/// Goal: Make bots take Side into account when deciding if another player/bot is an enemy
|
|
||||||
/// Check enemy cache list first, if not found, check side, if they differ, add to enemy list and return true
|
|
||||||
/// Needed to ensure bot checks the enemy side, not just its botType
|
|
||||||
/// </summary>
|
|
||||||
[PatchPrefix]
|
|
||||||
public static bool PatchPrefix(ref bool __result, BotsGroup __instance, IPlayer player)
|
|
||||||
{
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
__result = false;
|
|
||||||
|
|
||||||
return false; // Skip original
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__instance.InitialBotType == WildSpawnType.peacefullZryachiyEvent
|
|
||||||
|| __instance.InitialBotType == WildSpawnType.shooterBTR
|
|
||||||
|| __instance.InitialBotType == WildSpawnType.gifter
|
|
||||||
|| __instance.InitialBotType == WildSpawnType.sectantWarrior
|
|
||||||
|| __instance.InitialBotType == WildSpawnType.sectantPriest
|
|
||||||
|| __instance.InitialBotType == WildSpawnType.sectactPriestEvent
|
|
||||||
|| __instance.InitialBotType == WildSpawnType.ravangeZryachiyEvent)
|
|
||||||
{
|
|
||||||
return true; // Do original code
|
|
||||||
}
|
|
||||||
|
|
||||||
var isEnemy = false; // default not an enemy
|
|
||||||
|
|
||||||
// Check existing enemies list
|
|
||||||
// Could also check x.Value.Player?.Id - BSG do it this way
|
|
||||||
if (!__instance.Enemies.IsNullOrEmpty() && __instance.Enemies.Any(x => x.Key.Id == player.Id))
|
|
||||||
{
|
|
||||||
__result = true;
|
|
||||||
return false; // Skip original
|
|
||||||
}
|
|
||||||
|
|
||||||
// Weird edge case - without this you get spammed with key already in enemy list error when you move around on lighthouse
|
|
||||||
// Make zryachiy use existing isEnemy() code
|
|
||||||
if (__instance.InitialBotType == WildSpawnType.bossZryachiy)
|
|
||||||
{
|
|
||||||
return false; // Skip original
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__instance.Side == EPlayerSide.Usec)
|
|
||||||
{
|
|
||||||
if (player.Side == EPlayerSide.Bear || player.Side == EPlayerSide.Savage ||
|
|
||||||
ShouldAttackUsec(player))
|
|
||||||
{
|
|
||||||
isEnemy = true;
|
|
||||||
__instance.AddEnemy(player, EBotEnemyCause.checkAddTODO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (__instance.Side == EPlayerSide.Bear)
|
|
||||||
{
|
|
||||||
if (player.Side == EPlayerSide.Usec || player.Side == EPlayerSide.Savage ||
|
|
||||||
ShouldAttackBear(player))
|
|
||||||
{
|
|
||||||
isEnemy = true;
|
|
||||||
__instance.AddEnemy(player, EBotEnemyCause.checkAddTODO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (__instance.Side == EPlayerSide.Savage)
|
|
||||||
{
|
|
||||||
if (player.Side != EPlayerSide.Savage)
|
|
||||||
{
|
|
||||||
//Lets exUsec warn Usecs and fire at will at Bears
|
|
||||||
if (__instance.InitialBotType == WildSpawnType.exUsec)
|
|
||||||
{
|
|
||||||
return true; // Do original method
|
|
||||||
}
|
|
||||||
// everyone else is an enemy to savage (scavs)
|
|
||||||
isEnemy = true;
|
|
||||||
__instance.AddEnemy(player, EBotEnemyCause.checkAddTODO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
__result = isEnemy;
|
|
||||||
|
|
||||||
return false; // Skip original
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return True when usec default behavior is attack + bot is usec
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requester"></param>
|
|
||||||
/// <returns>bool</returns>
|
|
||||||
private static bool ShouldAttackUsec(IPlayer requester)
|
|
||||||
{
|
|
||||||
var requesterMind = requester?.AIData?.BotOwner?.Settings?.FileSettings?.Mind;
|
|
||||||
|
|
||||||
if (requesterMind == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return requester.IsAI && requesterMind.DEFAULT_USEC_BEHAVIOUR == EWarnBehaviour.AlwaysEnemies && requester.Side == EPlayerSide.Usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return True when bear default behavior is attack + bot is bear
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requester"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static bool ShouldAttackBear(IPlayer requester)
|
|
||||||
{
|
|
||||||
var requesterMind = requester.AIData?.BotOwner?.Settings?.FileSettings?.Mind;
|
|
||||||
|
|
||||||
if (requesterMind == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return requester.IsAI && requesterMind.DEFAULT_BEAR_BEHAVIOUR == EWarnBehaviour.AlwaysEnemies && requester.Side == EPlayerSide.Bear;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -45,7 +45,7 @@ namespace SPT.Debugging.Patches
|
|||||||
// TODO: Fine-grained spawn selection
|
// TODO: Fine-grained spawn selection
|
||||||
if (count > this._playerSpawnPoints.Count())
|
if (count > this._playerSpawnPoints.Count())
|
||||||
{
|
{
|
||||||
ConsoleScreen.Log($"[SPT PMC Bot spawn] Wanted ${count} but only {this._playerSpawnPoints.Count()} found, returning all");
|
ConsoleScreen.Log($"[SPT PMC Bot spawn] Wanted: ${count} but only {this._playerSpawnPoints.Count()} spawn points found, returning all");
|
||||||
return this._playerSpawnPoints;
|
return this._playerSpawnPoints;
|
||||||
}
|
}
|
||||||
return this._playerSpawnPoints.OrderBy(x => _rnd.Next()).Take(count).ToList();
|
return this._playerSpawnPoints.OrderBy(x => _rnd.Next()).Take(count).ToList();
|
||||||
@ -64,7 +64,7 @@ namespace SPT.Debugging.Patches
|
|||||||
public static bool PatchPrefix(GClass1575 __instance, BotCreationDataClass data)
|
public static bool PatchPrefix(GClass1575 __instance, BotCreationDataClass data)
|
||||||
{
|
{
|
||||||
var firstBotRole = data.Profiles[0].Info.Settings.Role;
|
var firstBotRole = data.Profiles[0].Info.Settings.Role;
|
||||||
if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC)
|
if (firstBotRole is not (WildSpawnType.pmcBEAR or 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; // Do original method
|
return true; // Do original method
|
||||||
|
@ -17,7 +17,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu
|
|||||||
if (variable == "pve_first_time")
|
if (variable == "pve_first_time")
|
||||||
{
|
{
|
||||||
__result = true;
|
__result = true;
|
||||||
return false;
|
return false; // Skip original method
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; // Do original method
|
return true; // Do original method
|
||||||
|
@ -5,7 +5,7 @@ using System.Reflection;
|
|||||||
namespace SPT.SinglePlayer.Patches.MainMenu
|
namespace SPT.SinglePlayer.Patches.MainMenu
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove the label shown on some of ragmans clothing options to "buy from website"
|
/// Remove the label shown on some of Ragmans clothing options to "buy from website"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class RemoveClothingItemExternalObtainLabelPatch : ModulePatch
|
internal class RemoveClothingItemExternalObtainLabelPatch : ModulePatch
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ using HarmonyLib;
|
|||||||
namespace SPT.SinglePlayer.Patches.Progression
|
namespace SPT.SinglePlayer.Patches.Progression
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fix xp gained value being 0 after a scav raid
|
/// Fix XP gained value being 0 after a scav raid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScavExperienceGainPatch : ModulePatch
|
public class ScavExperienceGainPatch : ModulePatch
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user