Mimic live behaviour for ammo box locarion values

This commit is contained in:
Dev 2024-02-11 12:12:27 +00:00
parent b5639f481f
commit 9819ac3737
3 changed files with 17 additions and 11 deletions

View File

@ -414,7 +414,7 @@ export class BotLootGenerator
// Fill ammo box
if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.AMMO_BOX))
{
this.itemHelper.addSingleStackCartridgesToAmmoBox(itemToAddChildrenTo, itemToAddTemplate);
this.itemHelper.addCartridgesToAmmoBox(itemToAddChildrenTo, itemToAddTemplate);
}
// Make money a stack
else if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.MONEY))

View File

@ -847,7 +847,7 @@ export class LocationGenerator
{
// Fill with cartridges
const ammoBoxItem: Item[] = [{ _id: this.objectId.generate(), _tpl: chosenTpl }];
this.itemHelper.addSingleStackCartridgesToAmmoBox(ammoBoxItem, itemTemplate);
this.itemHelper.addCartridgesToAmmoBox(ammoBoxItem, itemTemplate);
itemWithMods.push(...ammoBoxItem);
}
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE))
@ -1057,7 +1057,7 @@ export class LocationGenerator
// No spawnpoint to fall back on, generate manually
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.AMMO_BOX))
{
this.itemHelper.addSingleStackCartridgesToAmmoBox(items, itemTemplate);
this.itemHelper.addCartridgesToAmmoBox(items, itemTemplate);
}
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE))
{

View File

@ -1049,16 +1049,22 @@ export class ItemHelper
const cartridgeCountToAdd = (remainingSpace < maxPerStack) ? remainingSpace : maxPerStack;
// Add cartridge item into items array
ammoBox.push(
this.createCartridges(
const cartridgeItemToAdd = this.createCartridges(
ammoBox[0]._id,
cartridgeTpl,
cartridgeCountToAdd,
location,
ammoBox[0].upd?.SpawnedInSession,
),
);
// In live no ammo box has the first cartridge item with a location
if (location === 0)
{
delete cartridgeItemToAdd.location;
}
ammoBox.push(cartridgeItemToAdd);
currentStoredCartridgeCount += cartridgeCountToAdd;
location++;
}