diff --git a/project/assets/configs/bot.json b/project/assets/configs/bot.json index 72343e1d..ab705282 100644 --- a/project/assets/configs/bot.json +++ b/project/assets/configs/bot.json @@ -1223,7 +1223,7 @@ "mod_equipment_000": 10, "mod_equipment_001": 10, "mod_equipment_002": 5, - "mod_nvg": 15 + "mod_nvg": 0 }, "weaponMods": { "mod_barrel": 50, @@ -1260,7 +1260,12 @@ "mod_tactical_002": 30, "mod_tactical_003": 30, "mod_tactical_2": 15 - } + }, + "nighttimeChanges": { + "equipmentModsModifiers": { + "mod_nvg": 30 + } + } }, { "levelRange": { @@ -1271,6 +1276,9 @@ "SecondPrimaryWeapon": 10, "FaceCover": 50 }, + "equipmentMods": { + "mod_nvg": 0 + }, "randomisedArmorSlots": ["Headwear", "TacticalVest", "ArmorVest"], "randomisedWeaponModSlots": [ "mod_scope", @@ -1314,7 +1322,12 @@ "mod_tactical_003", "mod_tactical001", "mod_tactical002" - ] + ], + "nighttimeChanges": { + "equipmentModsModifiers": { + "mod_nvg": 50 + } + } }, { "levelRange": { @@ -1332,7 +1345,7 @@ "mod_equipment_000": 80, "mod_equipment_001": 75, "mod_equipment_002": 90, - "mod_nvg": 60 + "mod_nvg": 5 }, "weaponMods": { "mod_scope": 95, @@ -1383,7 +1396,12 @@ "mod_tactical_003", "mod_tactical001", "mod_tactical002" - ] + ], + "nighttimeChanges": { + "equipmentModsModifiers": { + "mod_nvg": 90 + } + } } ], "blacklist": [ diff --git a/project/assets/database/bots/types/bear.json b/project/assets/database/bots/types/bear.json index 57054079..510754a7 100644 --- a/project/assets/database/bots/types/bear.json +++ b/project/assets/database/bots/types/bear.json @@ -6187,6 +6187,18 @@ "5a16b8a9fcdbcb00165aa6ca" ] }, + "5a16b8a9fcdbcb00165aa6ca": { + "mod_nvg": [ + "5c0695860db834001b735461", + "5a16b93dfcdbcbcae6687261", + "5c11046cd174af02a012e42b" + ] + }, + "5a16b93dfcdbcbcae6687261": { + "mod_nvg": [ + "57235b6f24597759bf5a30f1" + ] + }, "5a16badafcdbcb001865f72d": { "mod_equipment": [ "5a16ba61fcdbcb098008728a" @@ -9720,6 +9732,11 @@ "5c0d56a986f774449d5de529" ] }, + "5c0695860db834001b735461": { + "mod_nvg": [ + "5c0696830db834001d23f5da" + ] + }, "5c06c6a80db834001b735491": { "Helmet_back": [ "657119d49eb8c145180dbb95" @@ -10405,6 +10422,11 @@ "638612b607dfed1ccb7206ba" ] }, + "5c11046cd174af02a012e42b": { + "mod_nvg": [ + "5c110624d174af029e69734c" + ] + }, "5c17664f2e2216398b5a7e3c": { "mod_mount_000": [ "59e0bed186f774156f04ce84" diff --git a/project/assets/database/bots/types/usec.json b/project/assets/database/bots/types/usec.json index ed2b075a..6f862a00 100644 --- a/project/assets/database/bots/types/usec.json +++ b/project/assets/database/bots/types/usec.json @@ -13518,6 +13518,22 @@ "5a16b8a9fcdbcb00165aa6ca" ] }, + "5a16b8a9fcdbcb00165aa6ca": { + "mod_nvg": [ + "5c0695860db834001b735461", + "5a16b93dfcdbcbcae6687261", + "5c11046cd174af02a012e42b" + ] + }, + "5c0695860db834001b735461": { + "mod_nvg": ["5c0696830db834001d23f5da"] + }, + "5a16b93dfcdbcbcae6687261": { + "mod_nvg": ["57235b6f24597759bf5a30f1"] + }, + "5c11046cd174af02a012e42b": { + "mod_nvg": ["5c110624d174af029e69734c"] + }, "5f60c74e3b85f6263c145586": { "Helmet_back": [ "657bc2c5a1c61ee0c3036333" diff --git a/project/src/generators/BotInventoryGenerator.ts b/project/src/generators/BotInventoryGenerator.ts index 3567087d..2b631033 100644 --- a/project/src/generators/BotInventoryGenerator.ts +++ b/project/src/generators/BotInventoryGenerator.ts @@ -1,13 +1,17 @@ +import { ApplicationContext } from "@spt/context/ApplicationContext"; +import { ContextVariableType } from "@spt/context/ContextVariableType"; import { BotEquipmentModGenerator } from "@spt/generators/BotEquipmentModGenerator"; import { BotLootGenerator } from "@spt/generators/BotLootGenerator"; import { BotWeaponGenerator } from "@spt/generators/BotWeaponGenerator"; import { BotGeneratorHelper } from "@spt/helpers/BotGeneratorHelper"; import { BotHelper } from "@spt/helpers/BotHelper"; import { ItemHelper } from "@spt/helpers/ItemHelper"; +import { WeatherHelper } from "@spt/helpers/WeatherHelper"; import { WeightedRandomHelper } from "@spt/helpers/WeightedRandomHelper"; import { IInventory as PmcInventory } from "@spt/models/eft/common/tables/IBotBase"; import { IBotType, IChances, IEquipment, IGeneration, IInventory } from "@spt/models/eft/common/tables/IBotType"; import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem"; +import { IGetRaidConfigurationRequestData } from "@spt/models/eft/match/IGetRaidConfigurationRequestData"; import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; import { EquipmentSlots } from "@spt/models/enums/EquipmentSlots"; import { GameEditions } from "@spt/models/enums/GameEditions"; @@ -32,12 +36,14 @@ export class BotInventoryGenerator { @inject("HashUtil") protected hashUtil: HashUtil, @inject("RandomUtil") protected randomUtil: RandomUtil, @inject("DatabaseService") protected databaseService: DatabaseService, + @inject("ApplicationContext") protected applicationContext: ApplicationContext, @inject("BotWeaponGenerator") protected botWeaponGenerator: BotWeaponGenerator, @inject("BotLootGenerator") protected botLootGenerator: BotLootGenerator, @inject("BotGeneratorHelper") protected botGeneratorHelper: BotGeneratorHelper, @inject("BotHelper") protected botHelper: BotHelper, @inject("WeightedRandomHelper") protected weightedRandomHelper: WeightedRandomHelper, @inject("ItemHelper") protected itemHelper: ItemHelper, + @inject("WeatherHelper") protected weatherHelper: WeatherHelper, @inject("LocalisationService") protected localisationService: LocalisationService, @inject("BotEquipmentModPoolService") protected botEquipmentModPoolService: BotEquipmentModPoolService, @inject("BotEquipmentModGenerator") protected botEquipmentModGenerator: BotEquipmentModGenerator, @@ -71,6 +77,11 @@ export class BotInventoryGenerator { // Generate base inventory with no items const botInventory = this.generateInventoryBase(); + // Get generated raid details bot will be spawned in + const raidConfig = this.applicationContext + .getLatestValue(ContextVariableType.RAID_CONFIGURATION) + ?.getValue(); + this.generateAndAddEquipmentToBot( templateInventory, wornItemChances, @@ -78,6 +89,7 @@ export class BotInventoryGenerator { botInventory, botLevel, chosenGameVersion, + raidConfig, ); // Roll weapon spawns (primary/secondary/holster) and generate a weapon for each roll that passed @@ -144,6 +156,7 @@ export class BotInventoryGenerator { botInventory: PmcInventory, botLevel: number, chosenGameVersion: string, + raidConfig: IGetRaidConfigurationRequestData, ): void { // These will be handled later const excludedSlots: string[] = [ @@ -160,6 +173,26 @@ export class BotInventoryGenerator { const botEquipConfig = this.botConfig.equipment[this.botGeneratorHelper.getBotEquipmentRole(botRole)]; const randomistionDetails = this.botHelper.getBotRandomizationDetails(botLevel, botEquipConfig); + + // Apply nighttime changes if its nighttime + there's changes to make + if ( + randomistionDetails?.nighttimeChanges && + raidConfig && + this.weatherHelper.isNightTime(raidConfig.timeVariant) + ) { + for (const equipmentSlotKey of Object.keys(randomistionDetails.nighttimeChanges.equipmentModsModifiers)) { + // Never let mod chance go outside of 0 - 100 + randomistionDetails.equipmentMods[equipmentSlotKey] = Math.min( + Math.max( + (randomistionDetails.equipmentMods[equipmentSlotKey] ?? 0) + + randomistionDetails.nighttimeChanges.equipmentModsModifiers[equipmentSlotKey], + 0, + ), + 100, + ); + } + } + for (const equipmentSlot in templateInventory.equipment) { // Weapons have special generation and will be generated separately; ArmorVest should be generated after TactivalVest if (excludedSlots.includes(equipmentSlot)) { diff --git a/project/src/helpers/BotHelper.ts b/project/src/helpers/BotHelper.ts index 3e0dc0cc..be75c47d 100644 --- a/project/src/helpers/BotHelper.ts +++ b/project/src/helpers/BotHelper.ts @@ -131,7 +131,9 @@ export class BotHelper { return undefined; } - return botEquipConfig.randomisation.find((x) => botLevel >= x.levelRange.min && botLevel <= x.levelRange.max); + return botEquipConfig.randomisation.find( + (randDetails) => botLevel >= randDetails.levelRange.min && botLevel <= randDetails.levelRange.max, + ); } /** diff --git a/project/src/models/spt/config/IBotConfig.ts b/project/src/models/spt/config/IBotConfig.ts index 8d913b2c..2ba9367a 100644 --- a/project/src/models/spt/config/IBotConfig.ts +++ b/project/src/models/spt/config/IBotConfig.ts @@ -162,6 +162,13 @@ export interface RandomisationDetails { weaponMods?: Record; /** Equipment mod chances */ equipmentMods?: Record; + nighttimeChanges?: INighttimeChanges; +} + +export interface INighttimeChanges { + /** Applies changes to values stored in equipmentMods */ + equipmentModsModifiers: Record; + //weaponModsModifiers: Record; //TODO } export interface EquipmentFilterDetails {