diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 2515f441..d8bfac83 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -528,10 +528,11 @@ export class BotLootGenerator // only add if no upd or stack objects exist - preserves existing stack count if (!ammoItem.upd?.StackObjectsCount) { - const minStackSize = itemTemplate._props.StackMinRandom; - const maxStackSize = itemTemplate._props.StackMaxSize; + const randomSize = itemTemplate._props.StackMaxSize === 1 + ? 1 + : this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom); - ammoItem.upd = { "StackObjectsCount": this.randomUtil.getInt(minStackSize, maxStackSize) }; + ammoItem.upd = { StackObjectsCount: randomSize }; } } diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 652f5065..8dfab184 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -660,12 +660,16 @@ export class LocationGenerator // Item array to return const itemWithMods: Item[] = []; - + // Money/Ammo - don't rely on items in spawnPoint.template.Items so we can randomise it ourselves if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MONEY) || this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.AMMO)) { const itemTemplate = this.itemHelper.getItem(chosenTpl)[1]; - const stackCount = this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom); + + const stackCount = itemTemplate._props.StackMaxSize === 1 + ? 1 + : this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom); + itemWithMods.push( { _id: this.objectId.generate(), @@ -777,7 +781,10 @@ export class LocationGenerator if (this.itemHelper.isOfBaseclass(tpl, BaseClasses.MONEY) || this.itemHelper.isOfBaseclass(tpl, BaseClasses.AMMO)) { - const stackCount = this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom); + // Edge case - some ammos e.g. flares or M406 grenades shouldn't be stacked + const stackCount = itemTemplate._props.StackMaxSize === 1 + ? 1 + : this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom); items[0].upd = { StackObjectsCount: stackCount }; } // No spawn point, use default template diff --git a/project/src/services/FenceService.ts b/project/src/services/FenceService.ts index 0a7556e9..33ee7f7c 100644 --- a/project/src/services/FenceService.ts +++ b/project/src/services/FenceService.ts @@ -465,7 +465,7 @@ export class FenceService } /** - * Get stack size ofr a singular item (no mods) + * Get stack size of a singular item (no mods) * @param itemDbDetails item being added to fence * @returns Stack size */ @@ -478,11 +478,12 @@ export class FenceService return this.randomUtil.getInt(overrideValues.min, overrideValues.max); } - // Fence doesn't sell ammo by default, but handle it as players mod fence if (this.itemHelper.isOfBaseclass(itemDbDetails._id, BaseClasses.AMMO)) { // No override, use stack max size from item db - return this.randomUtil.getInt(1, itemDbDetails._props.StackMaxSize); + return itemDbDetails._props.StackMaxSize === 1 + ? 1 + : this.randomUtil.getInt(itemDbDetails._props.StackMinRandom, itemDbDetails._props.StackMaxRandom); } return 1;