0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.SinglePlayer/Patches/ScavMode/ScavIsPlayerEnemyPatch.cs

30 lines
813 B
C#
Raw Normal View History

using EFT;
using HarmonyLib;
using SPT.Reflection.Patching;
using System.Reflection;
namespace SPT.SinglePlayer.Patches.ScavMode
{
/// <summary>
/// This patch ensures that PMC AI is always hostile towards the player and scavs if the player it checks is a <see cref="EPlayerSide.Savage"/> (scav)
/// </summary>
public class ScavIsPlayerEnemyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.IsPlayerEnemy));
}
[PatchPrefix]
public static bool Prefix(BotsGroup __instance, IPlayer player, ref bool __result)
{
if (player.Side is EPlayerSide.Savage && __instance.InitialBotType is WildSpawnType.pmcBEAR or WildSpawnType.pmcUSEC)
{
__result = true;
return false;
}
return true;
}
}
}