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/BotSelfEnemyPatch.cs
chomp 1e238c426e 0.13.5.0 (!33)
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Co-authored-by: CWX <CWX@noreply.dev.sp-tarkov.com>
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-authored-by: RaiRaiTheRaichu <rairaitheraichu@noreply.dev.sp-tarkov.com>
Co-authored-by: CWX <cwx@noreply.dev.sp-tarkov.com>
Co-authored-by: Kaeno <e>
Reviewed-on: SPT-AKI/Modules#33
2023-10-10 10:58:33 +00:00

42 lines
1.1 KiB
C#

using Aki.Reflection.Patching;
using EFT;
using System.Reflection;
namespace Aki.Custom.Patches
{
/// <summary>
/// Goal: patch removes the current bot from its own enemy list - occurs when adding bots type to its enemy array in difficulty settings
/// </summary>
internal class BotSelfEnemyPatch : ModulePatch
{
private static readonly string methodName = "PreActivate";
protected override MethodBase GetTargetMethod()
{
return typeof(BotOwner).GetMethod(methodName);
}
[PatchPrefix]
private static bool PatchPrefix(BotOwner __instance, BotsGroup group)
{
IPlayer selfToRemove = null;
foreach (var enemy in group.Enemies)
{
if (enemy.Key.Id == __instance.Id)
{
selfToRemove = enemy.Key;
break;
}
}
if (selfToRemove != null)
{
group.Enemies.Remove(selfToRemove);
}
return true;
}
}
}