From a80d159545514061397e1ebb33d149c616ce7b73 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 19 Jul 2025 21:16:42 +0100 Subject: [PATCH] Fixed prestiging not working after prestige 2 Fixed issues with receiving clothing --- .../Helpers/PrestigeHelper.cs | 21 ++++++++++++------- .../Helpers/ProfileHelper.cs | 3 +++ .../Eft/Common/Tables/CustomisationStorage.cs | 3 ++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs index ebde91fa..84a6c71b 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs @@ -37,7 +37,7 @@ public class PrestigeHelper( foreach (var skillToCopy in commonSKillsToCopy) { // Set progress 5% of what it was - skillToCopy.Progress = skillToCopy.Progress * 0.05; + skillToCopy.Progress *= 0.05; var existingSkill = newProfile.CharacterData.PmcData.Skills.Common.FirstOrDefault( skill => skill.Id == skillToCopy.Id ); @@ -55,7 +55,7 @@ public class PrestigeHelper( foreach (var skillToCopy in masteringSkillsToCopy) { // Set progress 5% of what it was - skillToCopy.Progress = skillToCopy.Progress * 0.05; + skillToCopy.Progress *= 0.05; var existingSkill = newProfile.CharacterData.PmcData.Skills.Mastering.FirstOrDefault(skill => skill.Id == skillToCopy.Id @@ -71,18 +71,22 @@ public class PrestigeHelper( } } - var indexOfPrestigeObtained = Math.Min((prestige.PrestigeLevel ?? 1) - 1, 1); // Index starts at 0 + // Index of desired prestige is (prestige level - 1) + var indexOfPrestigeObtained = Math.Clamp((prestige.PrestigeLevel ?? 1) - 1, 0, 4); // Add "Prestigious" achievement - if (!newProfile.CharacterData.PmcData.Achievements.ContainsKey("676091c0f457869a94017a23")) + var prestigiousAchievement = new MongoId("676091c0f457869a94017a23"); + if (!newProfile.CharacterData.PmcData.Achievements.ContainsKey(prestigiousAchievement)) { - rewardHelper.AddAchievementToProfile(newProfile, "676091c0f457869a94017a23"); + rewardHelper.AddAchievementToProfile(newProfile, prestigiousAchievement); } // Assumes Prestige data is in descending order var currentPrestigeData = databaseService.GetTemplates().Prestige.Elements[ indexOfPrestigeObtained ]; + + // Get all prestige rewards from prestige 1 up to desired prestige var prestigeRewards = databaseService .GetTemplates() .Prestige.Elements.Slice(0, indexOfPrestigeObtained + 1) @@ -91,7 +95,10 @@ public class PrestigeHelper( AddPrestigeRewardsToProfile(sessionId.Value, newProfile, prestigeRewards); // Flag profile as having achieved this prestige level - newProfile.CharacterData.PmcData.Prestige[currentPrestigeData.Id] = timeUtil.GetTimeStamp(); + newProfile.CharacterData.PmcData.Prestige.TryAdd( + currentPrestigeData.Id, + timeUtil.GetTimeStamp() + ); var itemsToTransfer = new List(); @@ -118,7 +125,7 @@ public class PrestigeHelper( sessionId.Value, "", itemsToTransfer, - 31536000 + timeUtil.GetHoursAsSeconds(8760) // Year ); } diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs index f35521a9..dd16b3a7 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs @@ -719,6 +719,9 @@ public class ProfileHelper( case CustomisationTypeId.LIGHT: rewardToStore.Type = CustomisationType.LIGHT; break; + case CustomisationTypeId.UPPER: + rewardToStore.Type = CustomisationType.UPPER; + break; default: logger.Error( $"Unhandled customisation unlock type: {matchingCustomisation.Parent} not added to profile" diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/CustomisationStorage.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/CustomisationStorage.cs index 51ea2635..d1f2c56f 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/CustomisationStorage.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/CustomisationStorage.cs @@ -16,7 +16,7 @@ public record CustomisationStorage public string Source { get; set; } [JsonPropertyName("type")] - public string Type { get; set; } + public string? Type { get; set; } } public record CustomisationType @@ -37,6 +37,7 @@ public record CustomisationType public const string SHOOTING_RANGE_MARK = "shootingRangeMark"; public const string CAT = "cat"; public const string MANNEQUIN_POSE = "mannequinPose"; + public static string UPPER = "Upper"; } public record CustomisationTypeId