diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index b9a6aa66..36e0d038 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -455,16 +455,11 @@ export class BotEquipmentModGenerator { } // If stock mod can take a sub stock mod, force spawn chance to be 100% to ensure sub-stock gets added - // Or if mod_stock is configured to be forced on - if ( - modSlot === "mod_stock" && - modToAddTemplate._props.Slots.some( - (slot) => slot._name.includes("mod_stock") || botEquipConfig.forceStock, - ) - ) { + // Or if bot has stock force enabled + if (this.shouldForceSubStockSlots(modSlot, botEquipConfig, modToAddTemplate)) { // Stock mod can take additional stocks, could be a locking device, force 100% chance - const stockSlots = ["mod_stock", "mod_stock_000", "mod_stock_akms"]; - this.adjustSlotSpawnChances(request.modSpawnChances, stockSlots, 100); + const subStockSlots = ["mod_stock", "mod_stock_000", "mod_stock_001", "mod_stock_akms"]; + this.adjustSlotSpawnChances(request.modSpawnChances, subStockSlots, 100); } // Gather stats on mods being added to weapon @@ -538,6 +533,27 @@ export class BotEquipmentModGenerator { return request.weapon; } + /** + * Should the provided bot have its stock chance values altered to 100% + * @param modSlot Slot to check + * @param botEquipConfig Bots equipment config/chance values + * @param modToAddTemplate Mod being added to bots weapon + * @returns True if it should + */ + protected shouldForceSubStockSlots( + modSlot: string, + botEquipConfig: EquipmentFilters, + modToAddTemplate: ITemplateItem, + ): boolean { + // Slots a weapon can store its stock in + const stockSlots = ["mod_stock", "mod_stock_000", "mod_stock_001", "mod_stock_akms"]; + + // Can the stock hold child items + const hasSubSlots = modToAddTemplate._props.Slots?.length > 0; + + return (stockSlots.includes(modSlot) && hasSubSlots) || botEquipConfig.forceStock; + } + /** * Is this modslot a front or rear sight * @param modSlot Slot to check