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 // Fill ammo box
if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.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 // Make money a stack
else if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.MONEY)) else if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.MONEY))

View File

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

View File

@ -1049,16 +1049,22 @@ export class ItemHelper
const cartridgeCountToAdd = (remainingSpace < maxPerStack) ? remainingSpace : maxPerStack; const cartridgeCountToAdd = (remainingSpace < maxPerStack) ? remainingSpace : maxPerStack;
// Add cartridge item into items array // Add cartridge item into items array
ammoBox.push( const cartridgeItemToAdd = this.createCartridges(
this.createCartridges( ammoBox[0]._id,
ammoBox[0]._id, cartridgeTpl,
cartridgeTpl, cartridgeCountToAdd,
cartridgeCountToAdd, location,
location, ammoBox[0].upd?.SpawnedInSession,
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; currentStoredCartridgeCount += cartridgeCountToAdd;
location++; location++;
} }