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;
|
2024-01-13 22:08:29 +00:00
|
|
|
|
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()
|
|
|
|
|
{
|
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
|
2024-02-22 16:57:57 +00:00
|
|
|
|
/// 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]
|
2024-02-22 16:57:57 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|