From bc3ac3d3e6a1f040f1541d37addaeccea7600c75 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 27 Oct 2024 15:37:18 +0000 Subject: [PATCH] Added ability to enable/disable certain sub-events during seasonal events --- project/assets/configs/seasonalevents.json | 10 ++++-- .../models/spt/config/ISeasonalEventConfig.ts | 1 + project/src/services/SeasonalEventService.ts | 33 +++++++++++-------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/project/assets/configs/seasonalevents.json b/project/assets/configs/seasonalevents.json index f8106a7e..9d12927c 100644 --- a/project/assets/configs/seasonalevents.json +++ b/project/assets/configs/seasonalevents.json @@ -695,7 +695,10 @@ "startDay": "24", "startMonth": "10", "endDay": "4", - "endMonth": "11" + "endMonth": "11", + "settings": { + "enableSummoning": true + } }, { "enabled": true, @@ -704,7 +707,10 @@ "startDay": "7", "startMonth": "12", "endDay": "31", - "endMonth": "12" + "endMonth": "12", + "settings": { + "enableSanta": true + } }, { "enabled": true, diff --git a/project/src/models/spt/config/ISeasonalEventConfig.ts b/project/src/models/spt/config/ISeasonalEventConfig.ts index 2af89972..466e9d10 100644 --- a/project/src/models/spt/config/ISeasonalEventConfig.ts +++ b/project/src/models/spt/config/ISeasonalEventConfig.ts @@ -21,6 +21,7 @@ export interface ISeasonalEvent { startMonth: number; endDay: number; endMonth: number; + settings?: Record; } export interface IGifterSetting { diff --git a/project/src/services/SeasonalEventService.ts b/project/src/services/SeasonalEventService.ts index 531efd1d..e4b3d354 100644 --- a/project/src/services/SeasonalEventService.ts +++ b/project/src/services/SeasonalEventService.ts @@ -31,7 +31,7 @@ export class SeasonalEventService { protected christmasEventActive?: boolean = undefined; /** All events active at this point in time */ - protected currentlyActiveEvents: SeasonalEventType[] = []; + protected currentlyActiveEvents: ISeasonalEvent[] = []; constructor( @inject("PrimaryLogger") protected logger: ILogger, @@ -223,7 +223,7 @@ export class SeasonalEventService { if (!event.enabled) { continue; } - this.currentlyActiveEvents.push(SeasonalEventType[event.type]); + this.currentlyActiveEvents.push(event); if (SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS) { this.christmasEventActive = true; @@ -337,28 +337,33 @@ export class SeasonalEventService { * @param globalConfig globals.json * @param eventName Name of the event to enable. e.g. Christmas */ - protected updateGlobalEvents(globalConfig: IConfig, eventType: SeasonalEventType): void { - this.logger.success(`${eventType} event is active`); + protected updateGlobalEvents(globalConfig: IConfig, event: ISeasonalEvent): void { + this.logger.success(`event: ${event.type} is active`); - switch (eventType.toLowerCase()) { + switch (event.type.toLowerCase()) { case SeasonalEventType.HALLOWEEN.toLowerCase(): globalConfig.EventType = globalConfig.EventType.filter((x) => x !== "None"); globalConfig.EventType.push("Halloween"); globalConfig.EventType.push("HalloweenIllumination"); globalConfig.Health.ProfileHealthSettings.DefaultStimulatorBuff = "Buffs_Halloween"; - this.addEventGearToBots(eventType); + this.addEventGearToBots(event.type); this.adjustZryachiyMeleeChance(); - this.enableHalloweenSummonEvent(); - this.addEventBossesToMaps(eventType); + if (event.settings?.enableSummoning) { + this.enableHalloweenSummonEvent(); + this.addEventBossesToMaps(event.type); + } this.addPumpkinsToScavBackpacks(); - this.adjustTraderIcons(eventType); + this.adjustTraderIcons(event.type); break; case SeasonalEventType.CHRISTMAS.toLowerCase(): globalConfig.EventType = globalConfig.EventType.filter((x) => x !== "None"); globalConfig.EventType.push("Christmas"); - this.addEventGearToBots(eventType); - this.addGifterBotToMaps(); - this.addLootItemsToGifterDropItemsList(); + this.addEventGearToBots(event.type); + if (event.settings?.enableSanta) { + this.addGifterBotToMaps(); + this.addLootItemsToGifterDropItemsList(); + } + this.enableDancingTree(); break; case SeasonalEventType.NEW_YEARS.toLowerCase(): @@ -375,7 +380,7 @@ export class SeasonalEventService { break; default: // Likely a mod event - this.addEventGearToBots(eventType); + this.addEventGearToBots(event.type); break; } } @@ -384,7 +389,7 @@ export class SeasonalEventService { if (this.currentlyActiveEvents) { const globalConfig = this.databaseService.getGlobals().config; for (const event of this.currentlyActiveEvents) { - switch (event.toLowerCase()) { + switch (event.type.toLowerCase()) { case SeasonalEventType.CHRISTMAS.toLowerCase(): this.giveGift(sessionId, "Christmas2022"); break;