diff --git a/project/assets/configs/location.json b/project/assets/configs/location.json index da95d927..6c00e2ea 100644 --- a/project/assets/configs/location.json +++ b/project/assets/configs/location.json @@ -890,6 +890,7 @@ "minFillStaticMagazinePercent": 50, "makeWishingTreeAlwaysGiveGift": true, "allowDuplicateItemsInStaticContainers": true, + "magazineLootHasAmmoChancePercent": 50, "looseLootBlacklist": {}, "scavRaidTimeSettings": { "settings": { diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 2c2f4455..1045b9b9 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -850,15 +850,21 @@ export class LocationGenerator } else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE)) { - // Create array with just magazine + randomised amount of cartridges + // Create array with just magazine const magazineItem: Item[] = [{ _id: this.objectId.generate(), _tpl: chosenTpl }]; - this.itemHelper.fillMagazineWithRandomCartridge( - magazineItem, - itemTemplate, // Magazine template - staticAmmoDist, - null, - this.locationConfig.minFillLooseMagazinePercent / 100, - ); + + if (this.randomUtil.getChance100(this.locationConfig.magazineLootHasAmmoChancePercent)) + { + // Add randomised amount of cartridges + this.itemHelper.fillMagazineWithRandomCartridge( + magazineItem, + itemTemplate, // Magazine template + staticAmmoDist, + null, + this.locationConfig.minFillLooseMagazinePercent / 100, + ); + } + itemWithMods.push(...magazineItem); } else if (this.itemHelper.armorItemCanHoldMods(chosenTpl)) @@ -1058,18 +1064,21 @@ export class LocationGenerator } else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE)) { - // Create array with just magazine - const magazineWithCartridges = [items[0]]; - this.itemHelper.fillMagazineWithRandomCartridge( - magazineWithCartridges, - itemTemplate, - staticAmmoDist, - null, - this.locationConfig.minFillStaticMagazinePercent / 100, - ); + if (this.randomUtil.getChance100(this.locationConfig.magazineLootHasAmmoChancePercent)) + { + // Create array with just magazine + const magazineWithCartridges = [items[0]]; + this.itemHelper.fillMagazineWithRandomCartridge( + magazineWithCartridges, + itemTemplate, + staticAmmoDist, + null, + this.locationConfig.minFillStaticMagazinePercent / 100, + ); - // Replace existing magazine with above array - items.splice(items.indexOf(items[0]), 1, ...magazineWithCartridges); + // Replace existing magazine with above array + items.splice(items.indexOf(items[0]), 1, ...magazineWithCartridges); + } } else if (this.itemHelper.armorItemCanHoldMods(chosenTpl)) { diff --git a/project/src/models/spt/config/ILocationConfig.ts b/project/src/models/spt/config/ILocationConfig.ts index eb47d266..f237f4ff 100644 --- a/project/src/models/spt/config/ILocationConfig.ts +++ b/project/src/models/spt/config/ILocationConfig.ts @@ -36,6 +36,8 @@ export interface ILocationConfig extends IBaseConfig /** How full must a random static magazine be %*/ minFillStaticMagazinePercent: number; allowDuplicateItemsInStaticContainers: boolean; + /** Chance loose/static magazines have ammo in them */ + magazineLootHasAmmoChancePercent: number; /** Key: map, value: loose loot ids to ignore */ looseLootBlacklist: Record; /** Key: map, value: settings to control how long scav raids are*/