diff --git a/project/assets/configs/trader.json b/project/assets/configs/trader.json index 64831068..2ce405a4 100644 --- a/project/assets/configs/trader.json +++ b/project/assets/configs/trader.json @@ -123,6 +123,10 @@ "5671435f4bdc2d96058b4569": 0, "543be5cb4bdc2deb348b4568": 3 }, + "preventDuplicateOffersOfCategory": [ + "543be5cb4bdc2deb348b4568", + "5485a8684bdc2da71d8b4567" + ], "weaponDurabilityPercentMinMax": { "current": { "min": 40, diff --git a/project/src/models/spt/config/ITraderConfig.ts b/project/src/models/spt/config/ITraderConfig.ts index 71988b85..9af3fc4d 100644 --- a/project/src/models/spt/config/ITraderConfig.ts +++ b/project/src/models/spt/config/ITraderConfig.ts @@ -36,6 +36,8 @@ export interface FenceConfig /** Key: item tpl */ itemStackSizeOverrideMinMax: Record; itemTypeLimits: Record; + /** Prevent duplicate offers of items of specific categories by parentId*/ + preventDuplicateOffersOfCategory: string[]; regenerateAssortsOnRefresh: boolean; /** Max rouble price before item is not listed on flea */ itemCategoryRoublePriceLimit: Record; diff --git a/project/src/services/FenceService.ts b/project/src/services/FenceService.ts index 550f2503..934709ca 100644 --- a/project/src/services/FenceService.ts +++ b/project/src/services/FenceService.ts @@ -613,6 +613,18 @@ export class FenceService // rootItemBeingAdded.upd.BuyRestrictionCurrent = 0; // rootItemBeingAdded.upd.UnlimitedCount = false; + // Skip items already in the assort if it exists in the prevent duplicate list + if ( + assorts.items.some((item) => item._tpl === rootItemBeingAdded._tpl) + && this.traderConfig.fence.preventDuplicateOffersOfCategory.includes( + this.itemHelper.getItem(rootItemBeingAdded._tpl)[1]._parent, + ) + ) + { + i--; + continue; + } + // Only randomise single items const isSingleStack = rootItemBeingAdded.upd.StackObjectsCount === 1; if (isSingleStack)