diff --git a/project/src/generators/BotGenerator.ts b/project/src/generators/BotGenerator.ts index 3db4fc25..0a631193 100644 --- a/project/src/generators/BotGenerator.ts +++ b/project/src/generators/BotGenerator.ts @@ -1,5 +1,6 @@ import { BotInventoryGenerator } from "@spt/generators/BotInventoryGenerator"; import { BotLevelGenerator } from "@spt/generators/BotLevelGenerator"; +import { BotGeneratorHelper } from "@spt/helpers/BotGeneratorHelper"; import { BotHelper } from "@spt/helpers/BotHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { WeightedRandomHelper } from "@spt/helpers/WeightedRandomHelper"; @@ -53,6 +54,7 @@ export class BotGenerator { @inject("BotEquipmentFilterService") protected botEquipmentFilterService: BotEquipmentFilterService, @inject("WeightedRandomHelper") protected weightedRandomHelper: WeightedRandomHelper, @inject("BotHelper") protected botHelper: BotHelper, + @inject("BotGeneratorHelper") protected botGeneratorHelper: BotGeneratorHelper, @inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService, @inject("ItemFilterService") protected itemFilterService: ItemFilterService, @inject("BotNameService") protected botNameService: BotNameService, @@ -214,6 +216,9 @@ export class BotGenerator { // Add drip this.setBotAppearance(bot, botJsonTemplate.appearance, botGenerationDetails); + // Filter out blacklisted gear from the base template + this.filterBlacklistedGear(botJsonTemplate, botGenerationDetails); + bot.Inventory = this.botInventoryGenerator.generateInventory( sessionId, botJsonTemplate, @@ -241,6 +246,33 @@ export class BotGenerator { return bot; } + /** + * Set weighting of flagged equipment to 0 + * @param botJsonTemplate Bot data to adjust + * @param botGenerationDetails Generation details of bot + */ + protected filterBlacklistedGear(botJsonTemplate: IBotType, botGenerationDetails: IBotGenerationDetails): void { + const blacklist = this.botEquipmentFilterService.getBotEquipmentBlacklist( + this.botGeneratorHelper.getBotEquipmentRole(botGenerationDetails.role), + botGenerationDetails.playerLevel, + ); + + if (!blacklist?.gear) { + // Nothing to filter by + return; + } + + for (const equipmentKey of Object.keys(blacklist?.gear)) { + const equipmentTpls: Record = botJsonTemplate.inventory.equipment[equipmentKey]; + + const blacklistedTpls = blacklist?.gear[equipmentKey]; + for (const tpl of blacklistedTpls) { + // Set weighting to 0, will never be picked + equipmentTpls[tpl] = 0; + } + } + } + protected addAdditionalPocketLootWeightsForUnheardBot(botJsonTemplate: IBotType): void { // Adjust pocket loot weights to allow for 5 or 6 items const pocketWeights = botJsonTemplate.generation.items.pocketLoot.weights; diff --git a/project/src/generators/BotInventoryGenerator.ts b/project/src/generators/BotInventoryGenerator.ts index abd67431..9ec61557 100644 --- a/project/src/generators/BotInventoryGenerator.ts +++ b/project/src/generators/BotInventoryGenerator.ts @@ -419,7 +419,7 @@ export class BotInventoryGenerator { this.logger.error(this.localisationService.getText("bot-missing_item_template", chosenItemTpl)); this.logger.debug(`EquipmentSlot -> ${settings.rootEquipmentSlot}`); - // remove picked item + // Remove picked item delete settings.rootEquipmentPool[chosenItemTpl]; attempts++; diff --git a/project/src/models/spt/config/IBotConfig.ts b/project/src/models/spt/config/IBotConfig.ts index 00076e1b..dcaa23e2 100644 --- a/project/src/models/spt/config/IBotConfig.ts +++ b/project/src/models/spt/config/IBotConfig.ts @@ -179,9 +179,11 @@ export interface IEquipmentFilterDetails { /** Between what levels do these equipment filter setting apply to */ levelRange: MinMax; /** Key: mod slot name e.g. mod_magazine, value: item tpls */ - equipment: Record; + equipment?: Record; + /** Key: equipment slot name e.g. FirstPrimaryWeapon, value: item tpls */ + gear?: Record; /** Key: cartridge type e.g. Caliber23x75, value: item tpls */ - cartridge: Record; + cartridge?: Record; } export interface IWeightingAdjustmentDetails {