From 07e99490e94f5dbd8d8310920f7efbc0ecb13b3a Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 23 May 2024 16:56:47 +0200 Subject: [PATCH] Only use max AI if enforced is enabled --- Fika.Core/Coop/GameMode/CoopGame.cs | 41 ++++++++++++++++------------- Fika.Core/FikaPlugin.cs | 20 +++++++------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 26351d76..47f27e43 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -323,7 +323,7 @@ private async Task CreateBot(Profile profile, Vector3 position) if (!CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler)) { - Logger.LogDebug($"{nameof(CreateBot)}:Unable to find {nameof(CoopHandler)}"); + Logger.LogError($"{nameof(CreateBot)}:Unable to find {nameof(CoopHandler)}"); return null; } @@ -1142,25 +1142,28 @@ public override IEnumerator vmethod_4(float startDelay, BotControllerSettings co botsController_0.SetSettings(numberOfBots, BackEndSession.BackEndConfig.BotPresets, BackEndSession.BackEndConfig.BotWeaponScatterings); botsController_0.AddActivePLayer(PlayerOwner.Player); - int limits = Location_0.Id.ToLower() switch - { - "factory4_day" => FikaPlugin.MaxBotsFactory.Value, - "factory4_night" => FikaPlugin.MaxBotsFactory.Value, - "bigmap" => FikaPlugin.MaxBotsCustoms.Value, - "interchange" => FikaPlugin.MaxBotsInterchange.Value, - "rezervbase" => FikaPlugin.MaxBotsReserve.Value, - "woods" => FikaPlugin.MaxBotsWoods.Value, - "shoreline" => FikaPlugin.MaxBotsShoreline.Value, - "tarkovstreets" => FikaPlugin.MaxBotsStreets.Value, - "sandbox" => FikaPlugin.MaxBotsGroundZero.Value, - "laboratory" => FikaPlugin.MaxBotsLabs.Value, - "lighthouse" => FikaPlugin.MaxBotsLighthouse.Value, - _ => 0 - }; - - if (limits > 0) + if (FikaPlugin.EnforcedSpawnLimits.Value) { - botsController_0.BotSpawner.SetMaxBots(limits); + int limits = Location_0.Id.ToLower() switch + { + "factory4_day" => FikaPlugin.MaxBotsFactory.Value, + "factory4_night" => FikaPlugin.MaxBotsFactory.Value, + "bigmap" => FikaPlugin.MaxBotsCustoms.Value, + "interchange" => FikaPlugin.MaxBotsInterchange.Value, + "rezervbase" => FikaPlugin.MaxBotsReserve.Value, + "woods" => FikaPlugin.MaxBotsWoods.Value, + "shoreline" => FikaPlugin.MaxBotsShoreline.Value, + "tarkovstreets" => FikaPlugin.MaxBotsStreets.Value, + "sandbox" => FikaPlugin.MaxBotsGroundZero.Value, + "laboratory" => FikaPlugin.MaxBotsLabs.Value, + "lighthouse" => FikaPlugin.MaxBotsLighthouse.Value, + _ => 0 + }; + + if (limits > 0) + { + botsController_0.BotSpawner.SetMaxBots(limits); + } } DynamicAI = gameObject.AddComponent(); diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index 954b3ca5..d351c479 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -350,25 +350,25 @@ private void SetupConfig() DespawnMinimumDistance = Config.Bind("Performance | Max Bots", "Despawn Minimum Distance", 200.0f, new ConfigDescription("Don't despawn bots within this distance.", new AcceptableValueRange(50f, 3000f), new ConfigurationManagerAttributes() { Order = 12 })); - MaxBotsFactory = Config.Bind("Performance | Max Bots", "Max Bots Factory", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Factory. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 11 })); + MaxBotsFactory = Config.Bind("Performance | Max Bots", "Max Bots Factory", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Factory. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 11 })); - MaxBotsCustoms = Config.Bind("Performance | Max Bots", "Max Bots Customs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Customs. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 10 })); + MaxBotsCustoms = Config.Bind("Performance | Max Bots", "Max Bots Customs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Customs. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 10 })); - MaxBotsInterchange = Config.Bind("Performance | Max Bots", "Max Bots Interchange", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Interchange. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 8 })); + MaxBotsInterchange = Config.Bind("Performance | Max Bots", "Max Bots Interchange", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Interchange. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 8 })); - MaxBotsReserve = Config.Bind("Performance | Max Bots", "Max Bots Reserve", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Reserve. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 7 })); + MaxBotsReserve = Config.Bind("Performance | Max Bots", "Max Bots Reserve", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Reserve. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 7 })); - MaxBotsWoods = Config.Bind("Performance | Max Bots", "Max Bots Woods", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Woods. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 6 })); + MaxBotsWoods = Config.Bind("Performance | Max Bots", "Max Bots Woods", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Woods. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 6 })); - MaxBotsShoreline = Config.Bind("Performance | Max Bots", "Max Bots Shoreline", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Shoreline. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 5 })); + MaxBotsShoreline = Config.Bind("Performance | Max Bots", "Max Bots Shoreline", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Shoreline. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 5 })); - MaxBotsStreets = Config.Bind("Performance | Max Bots", "Max Bots Streets", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Streets of Tarkov. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 4 })); + MaxBotsStreets = Config.Bind("Performance | Max Bots", "Max Bots Streets", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Streets of Tarkov. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 4 })); - MaxBotsGroundZero = Config.Bind("Performance | Max Bots", "Max Bots Ground Zero", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Ground Zero. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 3 })); + MaxBotsGroundZero = Config.Bind("Performance | Max Bots", "Max Bots Ground Zero", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Ground Zero. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 3 })); - MaxBotsLabs = Config.Bind("Performance | Max Bots", "Max Bots Labs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Labs. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 2 })); + MaxBotsLabs = Config.Bind("Performance | Max Bots", "Max Bots Labs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Labs. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 2 })); - MaxBotsLighthouse = Config.Bind("Performance | Max Bots", "Max Bots Lighthouse", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Lighthouse. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 1 })); + MaxBotsLighthouse = Config.Bind("Performance | Max Bots", "Max Bots Lighthouse", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Lighthouse. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 1 })); // Network