From b7d74f1dec3e870ee52044849f2ca68099efd37a Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 5 Feb 2024 22:02:03 +0000 Subject: [PATCH] Add system to flag weapon slot ids as required. Applies to stocks/recievers for PMCs recievers for exusec/raider --- project/assets/configs/bot.json | 41 +++++++++++++------ .../generators/BotEquipmentModGenerator.ts | 14 +++++-- project/src/models/spt/config/IBotConfig.ts | 8 ++-- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/project/assets/configs/bot.json b/project/assets/configs/bot.json index 751ca301..c86e019a 100644 --- a/project/assets/configs/bot.json +++ b/project/assets/configs/bot.json @@ -459,7 +459,8 @@ "weaponModLimits": { "scopeLimit": 1, "lightLaserLimit": 1 - } + }, + "forceStock": true }, "cursedassault": { "faceShieldIsActiveChancePercent": 90, @@ -473,7 +474,9 @@ "faceShieldIsActiveChancePercent": 100, "lightIsActiveDayChancePercent": 25, "lightIsActiveNightChancePercent": 90, - "laserIsActiveChancePercent": 85 + "laserIsActiveChancePercent": 85, + "forceStock": true, + "weaponSlotIdsToMakeRequired": ["mod_reciever"] }, "bossbully": { "nvgIsActiveChanceDayPercent": 10, @@ -508,13 +511,15 @@ "weaponModLimits": { "scopeLimit": 1, "lightLaserLimit": 1 - } + }, + "forceStock": true }, "bosssanitar": { "faceShieldIsActiveChancePercent": 100, "lightIsActiveDayChancePercent": 25, "lightIsActiveNightChancePercent": 75, - "laserIsActiveChancePercent": 85 + "laserIsActiveChancePercent": 85, + "forceStock": true }, "bosstagilla": { "faceShieldIsActiveChancePercent": 100, @@ -562,19 +567,22 @@ "faceShieldIsActiveChancePercent": 100, "lightIsActiveDayChancePercent": 25, "lightIsActiveNightChancePercent": 75, - "laserIsActiveChancePercent": 75 + "laserIsActiveChancePercent": 75, + "forceStock": true }, "followerkolontaysecurity": { "faceShieldIsActiveChancePercent": 100, "lightIsActiveDayChancePercent": 25, "lightIsActiveNightChancePercent": 75, - "laserIsActiveChancePercent": 75 + "laserIsActiveChancePercent": 75, + "forceStock": true }, "followerbully": { "faceShieldIsActiveChancePercent": 100, "lightIsActiveDayChancePercent": 25, "lightIsActiveNightChancePercent": 75, - "laserIsActiveChancePercent": 75 + "laserIsActiveChancePercent": 75, + "forceStock": true }, "followergluharassault": { "nvgIsActiveChanceDayPercent": 10, @@ -582,7 +590,8 @@ "faceShieldIsActiveChancePercent": 100, "lightIsActiveDayChancePercent": 25, "lightIsActiveNightChancePercent": 75, - "laserIsActiveChancePercent": 75 + "laserIsActiveChancePercent": 75, + "forceStock": true }, "followergluharscout": { "faceShieldIsActiveChancePercent": 100, @@ -656,7 +665,8 @@ "weaponModLimits": { "scopeLimit": 2, "lightLaserLimit": 1 - } + }, + "forceStock": true }, "followerboarclose1": { "nvgIsActiveChanceDayPercent": 20, @@ -668,7 +678,8 @@ "weaponModLimits": { "scopeLimit": 2, "lightLaserLimit": 1 - } + }, + "forceStock": true }, "followerboarclose2": { "nvgIsActiveChanceDayPercent": 20, @@ -680,7 +691,8 @@ "weaponModLimits": { "scopeLimit": 2, "lightLaserLimit": 1 - } + }, + "forceStock": true }, "bossboarsniper": { "nvgIsActiveChanceDayPercent": 20, @@ -737,7 +749,8 @@ "weaponModLimits": { "scopeLimit": 1, "lightLaserLimit": 1 - } + }, + "weaponSlotIdsToMakeRequired": ["mod_reciever"] }, "arenafighterevent": { "nvgIsActiveChanceDayPercent": 10, @@ -773,7 +786,8 @@ "weaponModLimits": { "scopeLimit": 1, "lightLaserLimit": 1 - } + }, + "forceStock": true }, "assaultgroup": {}, "gifter": { @@ -855,6 +869,7 @@ "laserIsActiveChancePercent": 85, "forceOnlyArmoredRigWhenNoArmor": true, "filterPlatesByLevel": true, + "weaponSlotIdsToMakeRequired": ["mod_reciever", "mod_stock"], "randomisation": [ { "levelRange": { diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index 50f7b757..c07c2ce6 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -16,7 +16,7 @@ import { BaseClasses } from "@spt-aki/models/enums/BaseClasses"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { ModSpawn } from "@spt-aki/models/enums/ModSpawn"; import { IChooseRandomCompatibleModResult } from "@spt-aki/models/spt/bots/IChooseRandomCompatibleModResult"; -import { EquipmentFilterDetails, IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; +import { EquipmentFilterDetails, EquipmentFilters, IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; @@ -386,7 +386,7 @@ export class BotEquipmentModGenerator } // Check spawn chance of mod - const modSpawnResult = this.shouldModBeSpawned(modsParentSlot, modSlot, modSpawnChances); + const modSpawnResult = this.shouldModBeSpawned(modsParentSlot, modSlot, modSpawnChances, botEquipConfig); if (modSpawnResult === ModSpawn.SKIP) { continue; @@ -707,9 +707,15 @@ export class BotEquipmentModGenerator * @param itemSlot slot the item sits in * @param modSlot slot the mod sits in * @param modSpawnChances Chances for various mod spawns + * @param botEquipConfig Various config settings for generating this type of bot * @returns ModSpawn.SPAWN when mod should be spawned, ModSpawn.DEFAULT_MOD when default mod should spawn, ModSpawn.SKIP when mod is skipped */ - protected shouldModBeSpawned(itemSlot: Slot, modSlot: string, modSpawnChances: ModsChances): ModSpawn + protected shouldModBeSpawned( + itemSlot: Slot, + modSlot: string, + modSpawnChances: ModsChances, + botEquipConfig: EquipmentFilters, + ): ModSpawn { const slotRequired = itemSlot._required; if (this.getAmmoContainers().includes(modSlot)) @@ -717,7 +723,7 @@ export class BotEquipmentModGenerator return ModSpawn.SPAWN; } const spawnMod = this.probabilityHelper.rollChance(modSpawnChances[modSlot]); - if (!spawnMod && slotRequired) + if (!spawnMod && (slotRequired || botEquipConfig.weaponSlotIdsToMakeRequired.includes(modSlot))) { // Mod is required but spawn chance roll failed, choose default mod spawn for slot return ModSpawn.DEFAULT_MOD; diff --git a/project/src/models/spt/config/IBotConfig.ts b/project/src/models/spt/config/IBotConfig.ts index 7e320a58..0515b34e 100644 --- a/project/src/models/spt/config/IBotConfig.ts +++ b/project/src/models/spt/config/IBotConfig.ts @@ -102,13 +102,15 @@ export interface EquipmentFilters lightIsActiveNightChancePercent?: number; /** Chance gun laser is active during the day */ laserIsActiveChancePercent?: number; - /** Should plates be filtered by level */ - filterPlatesByLevel?: boolean; /** Chance NODS are down/active during the day */ nvgIsActiveChanceDayPercent?: number; /** Chance NODS are down/active during the night */ nvgIsActiveChanceNightPercent?: number; forceOnlyArmoredRigWhenNoArmor?: boolean; + /** Should plates be filtered by level */ + filterPlatesByLevel?: boolean; + /** What additional slot ids should be seen as required when choosing a mod to add to a weapon */ + weaponSlotIdsToMakeRequired?: string[]; /** Adjust weighting/chances of items on bot by level of bot */ randomisation: RandomisationDetails[]; /** Blacklist equipment by level of bot */ @@ -120,7 +122,7 @@ export interface EquipmentFilters /** Same as weightingAdjustments but based on player level instead of bot level */ weightingAdjustmentsByPlayerLevel?: WeightingAdjustmentDetails[]; /** Should the stock mod be forced to spawn on bot */ - forceStock: boolean; + forceStock?: boolean; armorPlateWeighting?: IArmorPlateWeights[]; }