0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-12 20:30:43 -05:00

Reduced patch complexity and rename

This commit is contained in:
Dev 2024-07-11 10:48:25 +01:00
parent b4c699bd40
commit 60ccc54220
3 changed files with 31 additions and 30 deletions

View File

@ -0,0 +1,30 @@
using SPT.Reflection.Patching;
using System.Reflection;
using HarmonyLib;
namespace SPT.Custom.Patches
{
public class BotsGroupLetBossesShootPmcsPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.CheckAndAddEnemy));
}
/// <summary>
/// CheckAndAddEnemy()
/// Goal: This patch lets bosses shoot back once a PMC has shot them
/// Force method to always run the code
/// </summary>
[PatchPrefix]
private static bool PatchPrefix(ref bool ignoreAI)
{
// original
// return player.HealthController.IsAlive && (!player.AIData.IsAI || ignoreAI) && !this.Enemies.ContainsKey(player) && this.AddEnemy(player, EBotEnemyCause.checkAddTODO);
ignoreAI = true;
return true; // Do Original
}
}
}

View File

@ -1,29 +0,0 @@
using SPT.Reflection.Patching;
using EFT;
using System.Reflection;
using HarmonyLib;
namespace SPT.Custom.Patches
{
public class CheckAndAddEnemyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BotsGroup), nameof(BotsGroup.CheckAndAddEnemy));
}
/// <summary>
/// CheckAndAddEnemy()
/// Goal: This patch lets bosses shoot back once a PMC has shot them
/// Removes the !player.AIData.IsAI check
/// BSG changed the way CheckAndAddEnemy Works in 14.0 Returns a bool now
/// </summary>
[PatchPrefix]
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
}
}
}

View File

@ -26,7 +26,7 @@ namespace SPT.Custom
new BotCalledDataTryCallPatch().Enable();
new BotCallForHelpCallBotPatch().Enable();
new BotOwnerDisposePatch().Enable();
new CheckAndAddEnemyPatch().Enable();
new BotsGroupLetBossesShootPmcsPatch().Enable();
new AddEnemyToAllGroupsInBotZonePatch().Enable();
new CustomAiPatch().Enable();
new AddTraitorScavsPatch().Enable();