Fix ammo packs not showing on fence

This commit is contained in:
Dev 2024-02-15 23:34:04 +00:00
parent d352f678b3
commit 2965709535
2 changed files with 27 additions and 5 deletions

View File

@ -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,

View File

@ -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