Added ability to programmatically blacklist specific bot gear tpls by level
This commit is contained in:
parent
e853be5f09
commit
30db370423
@ -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<string, number> = 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;
|
||||
|
@ -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++;
|
||||
|
@ -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<string, string[]>;
|
||||
equipment?: Record<string, string[]>;
|
||||
/** Key: equipment slot name e.g. FirstPrimaryWeapon, value: item tpls */
|
||||
gear?: Record<string, string[]>;
|
||||
/** Key: cartridge type e.g. Caliber23x75, value: item tpls */
|
||||
cartridge: Record<string, string[]>;
|
||||
cartridge?: Record<string, string[]>;
|
||||
}
|
||||
|
||||
export interface IWeightingAdjustmentDetails {
|
||||
|
Loading…
Reference in New Issue
Block a user