From 55b819e1ecba1d66e86e6c530e12b0193cae8a91 Mon Sep 17 00:00:00 2001 From: Chomp Date: Thu, 18 Sep 2025 23:35:27 +0100 Subject: [PATCH] Removed `GetItemRarityMultiplier`, the values in `items.json` are garbage and should not be used Added system to add multiplier to items that are used to craft in the hideout --- .../SPT_Data/configs/ragfair.json | 4 +- .../Models/Spt/Config/RagfairConfig.cs | 6 ++ .../Services/RagfairPriceService.cs | 67 +++++++++++++------ 3 files changed, 55 insertions(+), 22 deletions(-) diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/ragfair.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/ragfair.json index 9cfb6819..c35113de 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/ragfair.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/ragfair.json @@ -353,7 +353,9 @@ "itemTypeMultiplierOverride": { "5c164d2286f774194c5e69fa": 2.5 }, - "preventPriceBeingBelowTraderBuyPrice": true + "preventPriceBeingBelowTraderBuyPrice": true, + "useHideoutCraftMultiplier": true, + "hideoutCraftMultiplier": 0.5 } }, "runIntervalSeconds": 8, diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/RagfairConfig.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/RagfairConfig.cs index d53888da..9c4d7dc9 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/RagfairConfig.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/RagfairConfig.cs @@ -257,6 +257,12 @@ public record GenerateFleaPrices [JsonPropertyName("itemTypeMultiplierOverride")] public Dictionary ItemTypeMultiplierOverride { get; set; } + + [JsonPropertyName("useHideoutCraftMultiplier")] + public bool UseHideoutCraftMultiplier { get; set; } + + [JsonPropertyName("hideoutCraftMultiplier")] + public double HideoutCraftMultiplier { get; set; } } public record PriceRanges diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs index 64da2b5a..659f6edb 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs @@ -72,17 +72,22 @@ public class RagfairPriceService( /// public void ReplaceFleaBasePrices() { + var config = RagfairConfig.Dynamic.GenerateBaseFleaPrices; var pricePool = databaseServer.GetTables().Templates.Prices; + var hideoutCraftItems = GetHideoutCraftItemTpls(); + foreach (var (itemTpl, handbookPrice) in StaticPrices) { // Get new price to use - var newBasePrice = handbookPrice * (GetFleaBasePriceMultiplier(itemTpl) + GetItemRarityMultiplier(itemTpl)); + var newBasePrice = + handbookPrice + * (GetFleaBasePriceMultiplier(itemTpl, config) + GetHideoutCraftMultiplier(itemTpl, config, hideoutCraftItems)); if (newBasePrice == 0) { continue; } - if (RagfairConfig.Dynamic.GenerateBaseFleaPrices.PreventPriceBeingBelowTraderBuyPrice) + if (config.PreventPriceBeingBelowTraderBuyPrice) { // Check if item can be sold to trader for a higher price than what we're going to set var highestSellToTraderPrice = traderHelper.GetHighestSellToTraderPrice(itemTpl); @@ -97,12 +102,50 @@ public class RagfairPriceService( } } + /// + /// Get the multiplier to apply to items used in hideout crafts + /// If not hideout craft item, return 0 + /// + /// Item to get multiplier for + /// Ragfair config + /// Craft item tpls + /// Multiplier + protected double GetHideoutCraftMultiplier(MongoId itemTpl, GenerateFleaPrices config, HashSet hideoutCraftItems) + { + if (!config.UseHideoutCraftMultiplier || !hideoutCraftItems.Contains(itemTpl)) + { + return 0; + } + + return config.HideoutCraftMultiplier; + } + + /// + /// Get a set of item tpls used by hideout crafts as requirements + /// + /// Set + protected HashSet GetHideoutCraftItemTpls() + { + var results = new HashSet(); + foreach ( + var itemRequirements in databaseService + .GetHideout() + .Production.Recipes.Select(recipe => recipe.Requirements.Where(x => x.Type == "Item").Select(x => x.TemplateId)) + ) + { + results.UnionWith(itemRequirements); + } + + return results; + } + /// /// Get the multiplier to apply to a handbook price to create the base flea price of an item /// /// Item to look up multiplier of + /// /// Multiplier value - protected double GetFleaBasePriceMultiplier(MongoId itemTpl) + protected double GetFleaBasePriceMultiplier(MongoId itemTpl, GenerateFleaPrices config) { // Specific item multiplier may exist, check for it if (RagfairConfig.Dynamic.GenerateBaseFleaPrices.ItemTplMultiplierOverride.TryGetValue(itemTpl, out var specificItemMultiplier)) @@ -122,24 +165,6 @@ public class RagfairPriceService( return RagfairConfig.Dynamic.GenerateBaseFleaPrices.PriceMultiplier; } - protected double GetItemRarityMultiplier(MongoId itemTpl) - { - var itemDetails = itemHelper.GetItem(itemTpl); - switch (itemDetails.Value?.Properties?.RarityPvE ?? string.Empty) - { - case "Common": - return 0; - case "Rare": - return 0.2; - case "Superrare": - return 0.5; - case "Not_exist": - return 1; - default: - return 0; - } - } - /// /// Get the dynamic price for an item. If value doesn't exist, use static (handbook) value. /// if no static value, return 1