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
@ -106,7 +106,11 @@ export class FenceBaseAssortGenerator
|
||||
|
||||
if (this.itemHelper.isOfBaseclass(rootItemDb._id, BaseClasses.AMMO_BOX))
|
||||
{
|
||||
this.itemHelper.addCartridgesToAmmoBox(itemWithChildrenToAdd, rootItemDb);
|
||||
// Only add cartridges to box if box has no children
|
||||
if (itemWithChildrenToAdd.length === 1)
|
||||
{
|
||||
this.itemHelper.addCartridgesToAmmoBox(itemWithChildrenToAdd, rootItemDb);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure IDs are unique
|
||||
|
@ -1090,6 +1090,12 @@ export class ItemHelper
|
||||
const cartridgeDetails = this.getItem(cartridgeTpl);
|
||||
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
|
||||
let currentStoredCartridgeCount = 0;
|
||||
const maxPerStack = Math.min(ammoBoxMaxCartridgeCount, cartridgeMaxStackSize);
|
||||
|
Loading…
x
Reference in New Issue
Block a user