0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 05:50:44 -05:00
modules/project/SPT.Custom/Patches/FixBossesHavingNoFollowersOnMediumAiAmount.cs

51 lines
1.8 KiB
C#

using SPT.Reflection.Patching;
using System.Reflection;
using EFT;
using EFT.Bots;
using HarmonyLib;
namespace SPT.Custom.Patches
{
/// <summary>
/// Fix bosses not spawning with any followers because BSG subtract the escort amount from itself
/// </summary>
public class FixBossesHavingNoFollowersOnMediumAiAmount: ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(LocalGame), nameof(LocalGame.smethod_8));
}
[PatchPrefix]
public static void PatchPrefix(LocalGame __instance, WavesSettings wavesSettings, ref BossLocationSpawn[] bossLocationSpawn)
{
// Not a boss and set to medium, skip
if (wavesSettings is not { IsBosses: true, BotAmount: EBotAmount.Medium })
{
return;
}
foreach (var locationSpawn in bossLocationSpawn)
{
// Only adjust bosses with single escort amount value, skip others
if (locationSpawn.BossEscortAmount.Length != 1)
{
continue;
}
// Only add new value when existing value is > 0
var existingAmount = int.Parse(locationSpawn.BossEscortAmount);
if (existingAmount == 0)
{
// Don't add more data to boss with 0 followers
continue;
}
// Add second value to property, when client does (max - min / 2), it won't be 0
// e.g. reshala has value of "4", we add value "(existing)*3 (=12)", which means the client does "(12 - 4) / 2" giving us 4 escorts - same as high/as online ai amount
locationSpawn.BossEscortAmount += $",{existingAmount * 3}";
}
}
}
}