2023-03-03 18:52:31 +00:00
|
|
|
|
using Aki.Reflection.Patching;
|
|
|
|
|
using EFT;
|
|
|
|
|
using System.Reflection;
|
2024-01-13 22:08:29 +00:00
|
|
|
|
using HarmonyLib;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
|
|
|
|
namespace Aki.Custom.Patches
|
|
|
|
|
{
|
|
|
|
|
public class CheckAndAddEnemyPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
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]
|
2023-10-10 10:58:33 +00:00
|
|
|
|
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))
|
|
|
|
|
{
|
2023-10-10 10:58:33 +00:00
|
|
|
|
__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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|