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

30 lines
1014 B
C#
Raw Normal View History

2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching;
2023-03-03 18:52:31 +00:00
using EFT;
using System.Reflection;
using HarmonyLib;
2023-03-03 18:52:31 +00:00
2024-05-21 19:10:17 +01:00
namespace SPT.Custom.Patches
2023-03-03 18:52:31 +00:00
{
public class CheckAndAddEnemyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.CheckAndAddEnemy));
2023-03-03 18:52:31 +00:00
}
/// <summary>
/// CheckAndAddEnemy()
/// Goal: This patch lets bosses shoot back once a PMC has shot them
/// Removes the !player.AIData.IsAI check
/// BSG changed the way CheckAndAddEnemy Works in 14.0 Returns a bool now
2023-03-03 18:52:31 +00:00
/// </summary>
[PatchPrefix]
private static bool PatchPrefix(BotsGroup __instance, IPlayer player, ref bool __result)
{
// Set result to not include !player.AIData.IsAI checks
__result = player.HealthController.IsAlive && !__instance.Enemies.ContainsKey(player) && __instance.AddEnemy(player, EBotEnemyCause.checkAddTODO);
return false; // Skip Original
2023-03-03 18:52:31 +00:00
}
}
}