From 6010e42a93579da8f191141685d6edbba6127413 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 1 Apr 2025 12:06:15 +0100 Subject: [PATCH 1/4] Fixed `getRaidAdjustments` not sending all the required fields --- .../Controllers/GameController.cs | 3 +- .../Services/RaidTimeAdjustmentService.cs | 40 +++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs index ddee907d..a8f45e44 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs @@ -15,6 +15,7 @@ using SPTarkov.Server.Core.Utils.Json; using SPTarkov.Server; using SPTarkov.Common.Annotations; using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel; +using SPTarkov.Server.Core.Models.Spt.Location; namespace SPTarkov.Server.Core.Controllers; @@ -290,7 +291,7 @@ public class GameController( /// Session/Player id /// /// - public GetRaidTimeResponse GetRaidTime(string sessionId, GetRaidTimeRequest request) + public RaidChanges GetRaidTime(string sessionId, GetRaidTimeRequest request) { return _raidTimeAdjustmentService.GetRaidAdjustments(sessionId, request); } diff --git a/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs b/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs index cab8f65b..113ff3a1 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs @@ -115,7 +115,7 @@ public class RaidTimeAdjustmentService( var startSeconds = raidAdjustments.SimulatedRaidStartSeconds.GetValueOrDefault(1); foreach (var wave in mapBase.Waves) { - // Dont let time fall below 0 + // Don't let time fall below 0 wave.TimeMin -= (int) Math.Max(startSeconds, 0); wave.TimeMax -= (int) Math.Max(startSeconds, 0); } @@ -131,17 +131,22 @@ public class RaidTimeAdjustmentService( /// Session id /// Raid adjustment request /// Response to send to client - public GetRaidTimeResponse GetRaidAdjustments(string sessionId, GetRaidTimeRequest request) + public RaidChanges GetRaidAdjustments(string sessionId, GetRaidTimeRequest request) { var globals = _databaseService.GetGlobals(); var mapBase = _databaseService.GetLocation(request.Location.ToLower()).Base; var baseEscapeTimeMinutes = mapBase.EscapeTimeLimit; // Prep result object to return - var result = new GetRaidTimeResponse + var result = new RaidChanges { - NewSurviveTimeSeconds = null, - OriginalSurvivalTimeSeconds = globals.Configuration.Exp.MatchEnd.SurvivedSecondsRequirement + NewSurviveTimeSeconds = globals.Configuration.Exp.MatchEnd.SurvivedSecondsRequirement, + OriginalSurvivalTimeSeconds = globals.Configuration.Exp.MatchEnd.SurvivedSecondsRequirement, + DynamicLootPercent = 100, + StaticLootPercent = 100, + SimulatedRaidStartSeconds = 0, + RaidTimeMinutes = baseEscapeTimeMinutes, + ExitChanges = [] }; // Pmc raid, send default @@ -150,7 +155,7 @@ public class RaidTimeAdjustmentService( return result; } - // We're scav adjust values + // We're scav, adjust values var mapSettings = GetMapSettings(request.Location); // Chance of reducing raid time for scav, not guaranteed @@ -173,25 +178,16 @@ public class RaidTimeAdjustmentService( // Time player spawns into the raid if it was online var simulatedRaidStartTimeMinutes = baseEscapeTimeMinutes - newRaidTimeMinutes; + result.SimulatedRaidStartSeconds = simulatedRaidStartTimeMinutes * 60; + result.RaidTimeMinutes = newRaidTimeMinutes; // Calculate how long player needs to be in raid to get a `survived` extract status result.NewSurviveTimeSeconds = Math.Max(result.OriginalSurvivalTimeSeconds.Value - (baseEscapeTimeMinutes.Value - newRaidTimeMinutes) * 60, 0); - // State that we'll pass to loot generation - var raidChanges = new RaidChanges { - DynamicLootPercent = 100, - StaticLootPercent = 100, - RaidTimeMinutes = newRaidTimeMinutes, - OriginalSurvivalTimeSeconds = result.OriginalSurvivalTimeSeconds, - ExitChanges = [], - NewSurviveTimeSeconds = result.NewSurviveTimeSeconds, - SimulatedRaidStartSeconds = 0 }; - if (mapSettings.ReduceLootByPercent) { - raidChanges.DynamicLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinDynamicLootPercent); - raidChanges.StaticLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinStaticLootPercent); - raidChanges.SimulatedRaidStartSeconds = simulatedRaidStartTimeMinutes * 60; + result.DynamicLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinDynamicLootPercent); + result.StaticLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinStaticLootPercent); } _logger.Debug($"Reduced: {request.Location} raid time by: {chosenRaidReductionPercent}% to {newRaidTimeMinutes} minutes"); @@ -203,13 +199,13 @@ public class RaidTimeAdjustmentService( ); var exitAdjustments = GetExitAdjustments(mapBase, newRaidTimeMinutes); - if (exitAdjustments is not null) + if (exitAdjustments.Any()) { - raidChanges.ExitChanges.AddRange(exitAdjustments); + result.ExitChanges.AddRange(exitAdjustments); } // Store state to use in loot generation - _applicationContext.AddValue(ContextVariableType.RAID_ADJUSTMENTS, raidChanges); + _applicationContext.AddValue(ContextVariableType.RAID_ADJUSTMENTS, result); return result; } From b5dafb59e2b1ce37629e2e04e0cd14ca66a51c6d Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 1 Apr 2025 12:09:24 +0100 Subject: [PATCH 2/4] Enabled IgnoreMaxBots for gifter bots --- .../SPTarkov.Server.Core/Services/SeasonalEventService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index 919155a9..f1aa3b2e 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -1050,7 +1050,8 @@ public class SeasonalEventService( TriggerId = "", TriggerName = "", Delay = 0, - IsRandomTimeSpawn = false + IsRandomTimeSpawn = false, + IgnoreMaxBots = true } ); } From 6c101de93038e754f0c55ead47f2bdf9c3293567 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 1 Apr 2025 12:19:06 +0100 Subject: [PATCH 3/4] Fixed `addGifterBotToMaps` not adjusting existing gifter spawns --- .../SPTarkov.Server.Core/Services/SeasonalEventService.cs | 8 ++++++-- server-csharp.sln.DotSettings | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index f1aa3b2e..72a73eab 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -1024,12 +1024,16 @@ public class SeasonalEventService( if (!maps.TryGetValue(gifterMapSettings.Map, out var mapData)) { _logger.Warning($"AddGifterBotToMaps() Map not found {gifterMapSettings.Map}"); + continue; } - // Dont add gifter to map twice - if (mapData.Base.BossLocationSpawn.Any(boss => boss.BossName == "gifter")) + // Don't add gifter to map twice + var existingGifter = mapData.Base.BossLocationSpawn.FirstOrDefault(boss => boss.BossName == "gifter"); + if (existingGifter is not null) { + existingGifter.BossChance = gifterMapSettings.SpawnChance; + continue; } diff --git a/server-csharp.sln.DotSettings b/server-csharp.sln.DotSettings index a05aa8f3..a2a24c46 100644 --- a/server-csharp.sln.DotSettings +++ b/server-csharp.sln.DotSettings @@ -1,4 +1,5 @@  + True True True True From 09082e54489fa526da300a89939a423508a98f4a Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 1 Apr 2025 12:19:42 +0100 Subject: [PATCH 4/4] Fixed Halloween related error in console --- Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index 72a73eab..efc57392 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -458,7 +458,7 @@ public class SeasonalEventService( AddEventGearToBots(SeasonalEventType.Halloween); AddEventGearToBots(SeasonalEventType.Christmas); AddEventLootToBots(SeasonalEventType.Christmas); - AddEventBossesToMaps(SeasonalEventType.Halloween.ToString()); + AddEventBossesToMaps("halloweensummon"); EnableHalloweenSummonEvent(); AddPumpkinsToScavBackpacks(); RenameBitcoin();