diff --git a/project/assets/configs/seasonalevents.json b/project/assets/configs/seasonalevents.json index 2fb06bf0..f10cac88 100644 --- a/project/assets/configs/seasonalevents.json +++ b/project/assets/configs/seasonalevents.json @@ -231,6 +231,28 @@ } } }, + "eventLoot": { + "christmas": { + "assault": { + "Pockets": { + "5df8a6a186f77412640e2e80": 3000, + "5df8a72c86f77412640e2e83": 3000, + "5df8a77486f77412672a1e3f": 3000 + }, + "Backpack": { + "5df8a6a186f77412640e2e80": 3000, + "5df8a72c86f77412640e2e83": 3000, + "5df8a77486f77412672a1e3f": 3000, + "63a8970d7108f713591149f5": 250 + }, + "TacticalVest": { + "5df8a6a186f77412640e2e80": 3000, + "5df8a72c86f77412640e2e83": 3000, + "5df8a77486f77412672a1e3f": 3000 + } + } + } + }, "eventBotMapping": { "peacefullZryachiyEvent": "bossZryachiy", "sectactPriestEvent": "sectantPriest", diff --git a/project/src/models/spt/config/ISeasonalEventConfig.ts b/project/src/models/spt/config/ISeasonalEventConfig.ts index 9c40362a..ddd815f1 100644 --- a/project/src/models/spt/config/ISeasonalEventConfig.ts +++ b/project/src/models/spt/config/ISeasonalEventConfig.ts @@ -7,6 +7,8 @@ export interface ISeasonalEventConfig extends IBaseConfig { enableSeasonalEventDetection: boolean; /** event / botType / equipSlot / itemid */ eventGear: Record>>>; + /** event / bot type / equipSlot / itemid */ + eventLoot: Record>>>; events: ISeasonalEvent[]; eventBotMapping: Record; eventBossSpawns: Record>; diff --git a/project/src/services/SeasonalEventService.ts b/project/src/services/SeasonalEventService.ts index d905a3b0..f5792fcf 100644 --- a/project/src/services/SeasonalEventService.ts +++ b/project/src/services/SeasonalEventService.ts @@ -178,6 +178,15 @@ export class SeasonalEventService { return this.seasonalEventConfig.eventGear[eventType.toLowerCase()]; } + /** + * Get a dictionary of loot changes to apply to bots for a specific event e.g. Christmas/Halloween + * @param eventName Name of event to get gear changes for + * @returns bots with loot changes + */ + protected getEventBotLoot(eventType: SeasonalEventType): Record>> { + return this.seasonalEventConfig.eventLoot[eventType.toLowerCase()]; + } + /** * Get the dates each seasonal event starts and ends at * @returns Record with event name + start/end date @@ -385,6 +394,7 @@ export class SeasonalEventService { globalConfig.EventType = globalConfig.EventType.filter((x) => x !== "None"); globalConfig.EventType.push("Christmas"); this.addEventGearToBots(event.type); + this.addEventLootToBots(event.type); if (event.settings?.enableSanta) { this.addGifterBotToMaps(); this.addLootItemsToGifterDropItemsList(); @@ -398,6 +408,7 @@ export class SeasonalEventService { this.addLootItemsToGifterDropItemsList(); this.addEventGearToBots(SeasonalEventType.HALLOWEEN); this.addEventGearToBots(SeasonalEventType.CHRISTMAS); + this.addEventLootToBots(SeasonalEventType.CHRISTMAS); this.addEventBossesToMaps(SeasonalEventType.HALLOWEEN); this.enableHalloweenSummonEvent(); this.addPumpkinsToScavBackpacks(); @@ -663,8 +674,8 @@ export class SeasonalEventService { } // Iterate over each equipment slot change - const gearAmendments = botGearChanges[bot]; - for (const equipmentSlot in gearAmendments) { + const gearAmendmentsBySlot = botGearChanges[bot]; + for (const equipmentSlot in gearAmendmentsBySlot) { // Adjust slots spawn chance to be at least 75% botToUpdate.chances.equipment[equipmentSlot] = Math.max( botToUpdate.chances.equipment[equipmentSlot], @@ -672,7 +683,7 @@ export class SeasonalEventService { ); // Grab gear to add and loop over it - const itemsToAdd = gearAmendments[equipmentSlot]; + const itemsToAdd = gearAmendmentsBySlot[equipmentSlot]; for (const itemTplIdToAdd in itemsToAdd) { botToUpdate.inventory.equipment[equipmentSlot][itemTplIdToAdd] = itemsToAdd[itemTplIdToAdd]; } @@ -680,6 +691,38 @@ export class SeasonalEventService { } } + /** + * Read in data from seasonalEvents.json and add found loot items to bots + * @param eventName Name of the event to read loot in from config + */ + protected addEventLootToBots(eventType: SeasonalEventType): void { + const botLootChanges = this.getEventBotLoot(eventType); + if (!botLootChanges) { + this.logger.warning(this.localisationService.getText("gameevent-no_gear_data", eventType)); + + return; + } + + // Iterate over bots with changes to apply + for (const bot in botLootChanges) { + const botToUpdate = this.databaseService.getBots().types[bot.toLowerCase()]; + if (!botToUpdate) { + this.logger.warning(this.localisationService.getText("gameevent-bot_not_found", bot)); + continue; + } + + // Iterate over each loot slot change + const lootAmendmentsBySlot = botLootChanges[bot]; + for (const slotKey in lootAmendmentsBySlot) { + // Grab loot to add and loop over it + const itemTplsToAdd = lootAmendmentsBySlot[slotKey]; + for (const tpl in itemTplsToAdd) { + botToUpdate.inventory.items[slotKey][tpl] = itemTplsToAdd[tpl]; + } + } + } + } + /** * Add pumpkin loot boxes to scavs */