mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Fix patch
This commit is contained in:
parent
e6eeedf007
commit
7a0f4d2227
@ -2,7 +2,6 @@
|
||||
using Aki.Reflection.Utils;
|
||||
using EFT;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
@ -11,10 +10,6 @@ namespace Aki.Custom.Patches
|
||||
public class CheckAndAddEnemyPatch : ModulePatch
|
||||
{
|
||||
private static Type _targetType;
|
||||
private static FieldInfo _sideField;
|
||||
private static FieldInfo _enemiesField;
|
||||
private static FieldInfo _spawnTypeField;
|
||||
private static MethodInfo _addEnemy;
|
||||
private readonly string _targetMethodName = "CheckAndAddEnemy";
|
||||
|
||||
/// <summary>
|
||||
@ -23,10 +18,6 @@ namespace Aki.Custom.Patches
|
||||
public CheckAndAddEnemyPatch()
|
||||
{
|
||||
_targetType = PatchConstants.EftTypes.Single(IsTargetType);
|
||||
_sideField = _targetType.GetField("Side");
|
||||
_enemiesField = _targetType.GetField("Enemies");
|
||||
_spawnTypeField = _targetType.GetField("wildSpawnType_0", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
_addEnemy = _targetType.GetMethod("AddEnemy");
|
||||
}
|
||||
|
||||
private bool IsTargetType(Type type)
|
||||
@ -50,27 +41,28 @@ namespace Aki.Custom.Patches
|
||||
/// removes the !player.AIData.IsAI check
|
||||
/// </summary>
|
||||
[PatchPrefix]
|
||||
private static bool PatchPrefix(BotGroupClass __instance, IAIDetails player, ref bool ignoreAI, Dictionary<IAIDetails, BotSettingsClass> ___Enemies)
|
||||
private static bool PatchPrefix(BotGroupClass __instance, IAIDetails player, ref bool ignoreAI)
|
||||
{
|
||||
//var side = (EPlayerSide)_sideField.GetValue(__instance);
|
||||
//var botType = (WildSpawnType)_spawnTypeField.GetValue(__instance);
|
||||
|
||||
if (!player.HealthController.IsAlive)
|
||||
// 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)
|
||||
{
|
||||
return false; // do nothing and skip
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!___Enemies.ContainsKey(player))
|
||||
if (!player.HealthController.IsAlive)
|
||||
{
|
||||
return false; // Skip original
|
||||
}
|
||||
|
||||
if (!__instance.Enemies.ContainsKey(player))
|
||||
{
|
||||
__instance.AddEnemy(player);
|
||||
}
|
||||
|
||||
// Add enemy to list
|
||||
//if (!enemies.ContainsKey(player) && (!playerIsAi || ignoreAI))
|
||||
//_addEnemy.Invoke(__instance, new IAIDetails[] { player });
|
||||
|
||||
|
||||
return false;
|
||||
return false; // Skip original
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user