mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 08:30:45 -05:00
![Lacyway](/assets/img/avatar_default.png)
Was missing checks that now exist in the client, works as intended now from my testing. Please test and confirm as well. **Note**: I strongly believe that this patch is now redundant and can be removed, I am still testing to see if this is the case. Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com> Reviewed-on: SPT/Modules#153 Co-authored-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com> Co-committed-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com> (cherry picked from commit de7e762211aa6a9fe26fc80eb449f85db6464117)
66 lines
2.5 KiB
C#
66 lines
2.5 KiB
C#
using SPT.Reflection.Patching;
|
|
using EFT;
|
|
using System.Reflection;
|
|
using HarmonyLib;
|
|
|
|
namespace SPT.Custom.Patches
|
|
{
|
|
public class AllScavsHostileHostileToPlayerScavPatch : ModulePatch
|
|
{
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return AccessTools.Method(typeof(BotsController), nameof(BotsController.AddEnemyToAllGroupsInBotZone));
|
|
}
|
|
|
|
/// <summary>
|
|
/// AddEnemyToAllGroupsInBotZone()
|
|
/// Goal: by default, AddEnemyToAllGroupsInBotZone doesn't check if the bot group is on the same side as the player.
|
|
/// The effect of this is that when you are a Scav and kill a Usec, every bot group in the zone will aggro you including other Scavs.
|
|
/// This should fix that.
|
|
/// </summary>
|
|
[PatchPrefix]
|
|
private static bool PatchPrefix(BotsController __instance, IPlayer aggressor, IPlayer groupOwner, IPlayer target)
|
|
{
|
|
if (!groupOwner.IsAI)
|
|
{
|
|
return false; // Skip original
|
|
}
|
|
|
|
// If you damage yourself exit early as we dont want to try add ourself to our own enemy list
|
|
if (aggressor.IsYourPlayer && target.IsYourPlayer)
|
|
{
|
|
return false; // Skip original
|
|
}
|
|
|
|
BotZone botZone = groupOwner.AIData.BotOwner.BotsGroup.BotZone;
|
|
foreach (var item in __instance.Groups())
|
|
{
|
|
if (item.Key != botZone)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
foreach (var group in item.Value.GetGroups(notNull: true))
|
|
{
|
|
bool differentSide = aggressor.Side != group.Side;
|
|
bool sameSide = aggressor.Side == target.Side;
|
|
|
|
if (!group.HaveFollowTarget(aggressor)
|
|
&& !group.Enemies.ContainsKey(aggressor)
|
|
&& (differentSide || !sameSide)
|
|
&& !group.HaveMemberWithRole(WildSpawnType.gifter)
|
|
&& !group.HaveMemberWithRole(WildSpawnType.sectantWarrior)
|
|
&& !group.HaveMemberWithRole(WildSpawnType.sectantPriest)
|
|
&& !group.InitialFileSettings.Boss.NOT_ADD_TO_ENEMY_ON_KILLS
|
|
&& group.ShallRevengeFor(target))
|
|
{
|
|
group.AddEnemy(aggressor, EBotEnemyCause.AddEnemyToAllGroupsInBotZone);
|
|
}
|
|
}
|
|
}
|
|
|
|
return false; // Skip original
|
|
}
|
|
}
|
|
}
|