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 Aki.Reflection.Utils;
|
||||||
using EFT;
|
using EFT;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
@ -11,10 +10,6 @@ namespace Aki.Custom.Patches
|
|||||||
public class CheckAndAddEnemyPatch : ModulePatch
|
public class CheckAndAddEnemyPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static Type _targetType;
|
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";
|
private readonly string _targetMethodName = "CheckAndAddEnemy";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -23,10 +18,6 @@ namespace Aki.Custom.Patches
|
|||||||
public CheckAndAddEnemyPatch()
|
public CheckAndAddEnemyPatch()
|
||||||
{
|
{
|
||||||
_targetType = PatchConstants.EftTypes.Single(IsTargetType);
|
_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)
|
private bool IsTargetType(Type type)
|
||||||
@ -50,27 +41,28 @@ namespace Aki.Custom.Patches
|
|||||||
/// removes the !player.AIData.IsAI check
|
/// removes the !player.AIData.IsAI check
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PatchPrefix]
|
[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 side = (EPlayerSide)_sideField.GetValue(__instance);
|
||||||
//var botType = (WildSpawnType)_spawnTypeField.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);
|
__instance.AddEnemy(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add enemy to list
|
return false; // Skip original
|
||||||
//if (!enemies.ContainsKey(player) && (!playerIsAi || ignoreAI))
|
|
||||||
//_addEnemy.Invoke(__instance, new IAIDetails[] { player });
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user