From 2965709535811442971719b3b3ea1f7c842b84e0 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 15 Feb 2024 23:34:04 +0000 Subject: [PATCH] Fix ammo packs not showing on fence --- project/assets/configs/trader.json | 6 +++-- .../generators/FenceBaseAssortGenerator.ts | 26 ++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/project/assets/configs/trader.json b/project/assets/configs/trader.json index 6a3cae5b..8641f71d 100644 --- a/project/assets/configs/trader.json +++ b/project/assets/configs/trader.json @@ -120,7 +120,8 @@ "5b3f15d486f77432d0509248": 3, "543be6564bdc2df4348b4568": 0, "5448ecbe4bdc2d60728b4568": 0, - "5671435f4bdc2d96058b4569": 0 + "5671435f4bdc2d96058b4569": 0, + "543be5cb4bdc2deb348b4568": 3 }, "weaponDurabilityPercentMinMax": { "current": { @@ -205,7 +206,8 @@ "616eb7aea207f41933308f46": 40000, "5b3f15d486f77432d0509248": 5000, "5448f3ac4bdc2dce718b4569": 42000, - "5448f3a14bdc2d27728b4569": 20000 + "5448f3a14bdc2d27728b4569": 20000, + "543be5cb4bdc2deb348b4568": 15000 }, "presetSlotsToRemoveChancePercent": { "mod_scope": 70, diff --git a/project/src/generators/FenceBaseAssortGenerator.ts b/project/src/generators/FenceBaseAssortGenerator.ts index 530d0c05..1ad5fb76 100644 --- a/project/src/generators/FenceBaseAssortGenerator.ts +++ b/project/src/generators/FenceBaseAssortGenerator.ts @@ -105,13 +105,12 @@ export class FenceBaseAssortGenerator if (itemWithChildrenToAdd.length > 1) { this.itemHelper.reparentItemAndChildren(itemWithChildrenToAdd[0], itemWithChildrenToAdd); + itemWithChildrenToAdd[0].parentId = "hideout"; } // Create barter scheme (price) const barterSchemeToAdd: IBarterScheme = { - count: Math.round( - this.handbookHelper.getTemplatePrice(rootItemDb._id) * this.traderConfig.fence.itemPriceMult, - ), + count: Math.round(this.getItemPrice(rootItemDb._id, itemWithChildrenToAdd)), _tpl: Money.ROUBLES, }; @@ -176,6 +175,27 @@ export class FenceBaseAssortGenerator } } + protected getItemPrice(itemTpl: string, items: Item[]): number + { + return this.itemHelper.isOfBaseclass(itemTpl, BaseClasses.AMMO_BOX) + ? this.getAmmoBoxPrice(items) * this.traderConfig.fence.itemPriceMult + : this.handbookHelper.getTemplatePrice(itemTpl) * this.traderConfig.fence.itemPriceMult; + } + + protected getAmmoBoxPrice(items: Item[]): number + { + let total = 0; + for (const item of items) + { + if (this.itemHelper.isOfBaseclass(item._tpl, BaseClasses.AMMO)) + { + total += this.handbookHelper.getTemplatePrice(item._tpl) * (item.upd.StackObjectsCount ?? 1); + } + } + + return total; + } + /** * Add soft inserts + armor plates to an armor * @param armor Armor item array to add mods into