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

30 lines
1014 B
C#

using Aki.Reflection.Patching;
using EFT;
using System.Reflection;
using HarmonyLib;
namespace Aki.Custom.Patches
{
public class CheckAndAddEnemyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.CheckAndAddEnemy));
}
/// <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
/// </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
}
}
}