Added extra guard against adding cartridges to box sold by fence
Skip adding cartridges to ammo box inside `addCartridgesToAmmoBox()` if cartridge already exists
This commit is contained in:
parent
995d50dba4
commit
a1070f941c
@ -105,9 +105,13 @@ export class FenceBaseAssortGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.itemHelper.isOfBaseclass(rootItemDb._id, BaseClasses.AMMO_BOX))
|
if (this.itemHelper.isOfBaseclass(rootItemDb._id, BaseClasses.AMMO_BOX))
|
||||||
|
{
|
||||||
|
// Only add cartridges to box if box has no children
|
||||||
|
if (itemWithChildrenToAdd.length === 1)
|
||||||
{
|
{
|
||||||
this.itemHelper.addCartridgesToAmmoBox(itemWithChildrenToAdd, rootItemDb);
|
this.itemHelper.addCartridgesToAmmoBox(itemWithChildrenToAdd, rootItemDb);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure IDs are unique
|
// Ensure IDs are unique
|
||||||
this.itemHelper.remapRootItemId(itemWithChildrenToAdd);
|
this.itemHelper.remapRootItemId(itemWithChildrenToAdd);
|
||||||
|
@ -1090,6 +1090,12 @@ export class ItemHelper
|
|||||||
const cartridgeDetails = this.getItem(cartridgeTpl);
|
const cartridgeDetails = this.getItem(cartridgeTpl);
|
||||||
const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize;
|
const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize;
|
||||||
|
|
||||||
|
// Exit if ammo already exists in box
|
||||||
|
if (ammoBox.find((item) => item._tpl === cartridgeTpl))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Add new stack-size-correct items to ammo box
|
// Add new stack-size-correct items to ammo box
|
||||||
let currentStoredCartridgeCount = 0;
|
let currentStoredCartridgeCount = 0;
|
||||||
const maxPerStack = Math.min(ammoBoxMaxCartridgeCount, cartridgeMaxStackSize);
|
const maxPerStack = Math.min(ammoBoxMaxCartridgeCount, cartridgeMaxStackSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user