From e1a8f26507a3e03914b7d6c129300e066fa4a60e Mon Sep 17 00:00:00 2001 From: Spoony Date: Tue, 16 Jan 2024 10:26:48 +0000 Subject: [PATCH] Generate ammo box Ragfair offers with cartridges (!198) #### TL;DR Previously, Ragfair offers involving ammo boxes weren't generated with cartridges inside of them. This copies a lot of the logic from `InventoryHelper.hydrateAmmoBoxWithAmmo()` to add ammo to offers when they are generated. Made to fix #312. #### Testing Purchased various ammo boxes from Flea: ![image](/attachments/340fb349-2589-4b1a-81fa-f8d63f6f1a36) Purchased ammo boxes are listed as full: ![image](/attachments/f52057d3-efe0-40e7-b64e-8d257a818fa5) Unloading them produces correct ammunition: ![image](/attachments/33c71f7b-d452-473e-9705-cbad1ecc3f7d) Co-authored-by: Spoony Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/198 Co-authored-by: Spoony Co-committed-by: Spoony --- project/src/generators/RagfairOfferGenerator.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/project/src/generators/RagfairOfferGenerator.ts b/project/src/generators/RagfairOfferGenerator.ts index f3c0a60b..1d8bbc8f 100644 --- a/project/src/generators/RagfairOfferGenerator.ts +++ b/project/src/generators/RagfairOfferGenerator.ts @@ -119,6 +119,14 @@ export class RagfairOfferGenerator offerRequirements.push(requirement); } + const itemsClone = this.jsonUtil.clone(items); + + // Add cartridges to offers for ammo boxes + if (this.itemHelper.isOfBaseclass(itemsClone[0]._tpl, BaseClasses.AMMO_BOX)) + { + this.itemHelper.addCartridgesToAmmoBox(itemsClone, this.itemHelper.getItem(items[0]._tpl)[1]); + } + const itemCount = items.filter((x) => x.slotId === "hideout").length; const roublePrice = Math.round(this.convertOfferRequirementsIntoRoubles(offerRequirements)); @@ -136,7 +144,7 @@ export class RagfairOfferGenerator avatar: this.getAvatarUrl(isTrader, userID), }, root: items[0]._id, - items: this.jsonUtil.clone(items), + items: itemsClone, requirements: offerRequirements, requirementsCost: roublePrice, itemsCost: Math.round(this.handbookHelper.getTemplatePrice(items[0]._tpl)), // Handbook price