From bf60fb7ea92748c8406855b6485947f974d80f67 Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Tue, 13 Feb 2024 08:34:55 +0000 Subject: [PATCH] Fix flea armor not having proper random durability (!223) Clone flea items prior to passing them off to the createSingleOfferForItem method This change results in more armor on the flea having 100% durability, and less having identical non-max durability values Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/447 Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/223 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- project/src/generators/RagfairOfferGenerator.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/project/src/generators/RagfairOfferGenerator.ts b/project/src/generators/RagfairOfferGenerator.ts index e9df073d..fbacd1d1 100644 --- a/project/src/generators/RagfairOfferGenerator.ts +++ b/project/src/generators/RagfairOfferGenerator.ts @@ -376,17 +376,16 @@ export class RagfairOfferGenerator const assortSingleOfferProcesses = []; for (let index = 0; index < offerCount; index++) { - if (!isPreset) - { - // Presets get unique id generated during getPresetItems() earlier + would require regenerating all children to match - assortItemWithChildren[0]._id = this.hashUtil.generate(); - } + // Clone the item so we don't have shared references and generate new item IDs + const clonedAssort = this.jsonUtil.clone(assortItemWithChildren); + this.itemHelper.reparentItemAndChildren(clonedAssort[0], clonedAssort); - delete assortItemWithChildren[0].parentId; - delete assortItemWithChildren[0].slotId; + // Clear unnecessary properties + delete clonedAssort[0].parentId; + delete clonedAssort[0].slotId; assortSingleOfferProcesses.push( - this.createSingleOfferForItem(assortItemWithChildren, isPreset, itemDetails), + this.createSingleOfferForItem(clonedAssort, isPreset, itemDetails), ); }