From 9819ac37371c0bc8330e86bbcb3f800173af4866 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 11 Feb 2024 12:12:27 +0000 Subject: [PATCH] Mimic live behaviour for ammo box locarion values --- project/src/generators/BotLootGenerator.ts | 2 +- project/src/generators/LocationGenerator.ts | 4 ++-- project/src/helpers/ItemHelper.ts | 22 +++++++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 7f5620ea..4f8469d6 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -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)) diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 695e1f13..ddd3b017 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -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)) { diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index 17741cce..63217c96 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -1049,16 +1049,22 @@ export class ItemHelper const cartridgeCountToAdd = (remainingSpace < maxPerStack) ? remainingSpace : maxPerStack; // Add cartridge item into items array - ammoBox.push( - this.createCartridges( - ammoBox[0]._id, - cartridgeTpl, - cartridgeCountToAdd, - location, - ammoBox[0].upd?.SpawnedInSession, - ), + 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++; }