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

43 lines
1.3 KiB
C#
Raw Normal View History

2023-03-03 18:52:31 +00:00
using Aki.Reflection.Patching;
using EFT;
using System.Reflection;
using HarmonyLib;
2023-03-03 18:52:31 +00:00
namespace Aki.Custom.Patches
{
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
/// </summary>
[PatchPrefix]
private static bool PatchPrefix(BotsGroup __instance, IPlayer player, ref bool ignoreAI)
2023-03-03 18:52:31 +00:00
{
2023-07-30 13:15:35 +01:00
// Z already has player as enemy BUT Enemies dict is empty, adding them again causes 'existing key' errors
if (__instance.InitialBotType == WildSpawnType.bossZryachiy || __instance.InitialBotType == WildSpawnType.followerZryachiy)
2023-03-03 18:52:31 +00:00
{
2023-07-30 13:15:35 +01:00
return false;
2023-03-03 18:52:31 +00:00
}
2023-07-30 13:15:35 +01:00
if (!player.HealthController.IsAlive)
2023-03-03 18:52:31 +00:00
{
2023-07-30 13:15:35 +01:00
return false; // Skip original
2023-03-03 18:52:31 +00:00
}
2023-07-30 13:15:35 +01:00
if (!__instance.Enemies.ContainsKey(player))
{
__instance.AddEnemy(player, EBotEnemyCause.checkAddTODO);
2023-07-30 13:15:35 +01:00
}
2023-03-03 18:52:31 +00:00
2023-07-30 13:15:35 +01:00
return false; // Skip original
2023-03-03 18:52:31 +00:00
}
}
}