From 421ab55c23e0d75c29d3785ffd14a5d729e5e093 Mon Sep 17 00:00:00 2001 From: Chomp Date: Fri, 31 Oct 2025 16:29:55 +0000 Subject: [PATCH] Post raid effect fixes: When exiting raid with severe muscle pain, prevent client instructing server to add mild muscle pain When exiting a raid with effect that has a timer, decrease timer value by amount of time spent in raid --- .../Helpers/HealthHelper.cs | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs index f14b4341..8b31adb2 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs @@ -3,7 +3,6 @@ using SPTarkov.Server.Core.Exceptions.Helpers; using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Common; using SPTarkov.Server.Core.Models.Eft.Common.Tables; -using SPTarkov.Server.Core.Models.Eft.Health; using SPTarkov.Server.Core.Models.Spt.Config; using SPTarkov.Server.Core.Models.Utils; using SPTarkov.Server.Core.Servers; @@ -158,18 +157,39 @@ public class HealthHelper(ISptLogger logger, TimeUtil timeUtil, Co // Process each effect for each part foreach (var (key, effectDetails) in partProperties.Effects ?? []) { - // Null guard - matchingProfilePart.Effects ??= new Dictionary(); + // Have effects we need to add, init effect array + matchingProfilePart.Effects ??= []; - // Effect already exists on limb in server profile, skip + if ( + key.Equals("MildMusclePain", StringComparison.OrdinalIgnoreCase) + && matchingProfilePart.Effects.ContainsKey("SevereMusclePain") + ) + { + // Edge case - client is trying to add mild pain when server already has severe, don't allow this + continue; + } + + // Effect on limb already exists in server profile, handle differently if (matchingProfilePart.Effects.ContainsKey(key)) { - // Edge case - effect already exists at destination, but we don't want to overwrite details + matchingProfilePart.Effects.TryGetValue(key, out var matchingEffectOnServer); + + // Edge case - effect already exists at destination, but we don't want to overwrite details e.g. Exhaustion if (effectsToSkip is not null && effectsToSkip.Contains(key)) { matchingProfilePart.Effects[key] = null; } + // Effect time has decreased while in raid, persist this reduction into profile + if ( + effectDetails?.Time is not null + && matchingEffectOnServer?.Time is not null + && effectDetails.Time < matchingEffectOnServer.Time + ) + { + matchingEffectOnServer.Time = effectDetails.Time; + } + continue; }