diff --git a/conf/mod-cta-switch.conf.dist b/conf/mod-cta-switch.conf.dist index 9096300..8e2e478 100644 --- a/conf/mod-cta-switch.conf.dist +++ b/conf/mod-cta-switch.conf.dist @@ -29,3 +29,4 @@ ModCTASwitch.SwitchAV = 18 ModCTASwitch.SwitchEots = 19 ModCTASwitch.SwitchSota = 20 ModCTASwitch.SwitchIoc = 18 +ModCTASwitch.DailyCTA = 1 diff --git a/src/mod_cta_switch_script.cpp b/src/mod_cta_switch_script.cpp index 7c7fbcf..17624e6 100644 --- a/src/mod_cta_switch_script.cpp +++ b/src/mod_cta_switch_script.cpp @@ -13,6 +13,7 @@ enum EventIds EVENT_CTA_EYE_OF_THE_STORM = 21, EVENT_CTA_STRAND_OF_THE_ANCIENTS = 53, EVENT_CTA_ISLE_OF_CONQUEST = 54, + EVENT_HOURLY_BELLS = 73, }; class cta_switch_event_script : public GameEventScript @@ -110,6 +111,28 @@ class cta_switch_event_script : public GameEventScript sGameEventMgr->StopEvent(eventId, true); sGameEventMgr->StartEvent(sConfigMgr->GetOption("ModCTASwitch.SwitchIoc", EVENT_CTA_ALTERAC_VALLEY), true); + break; + case EVENT_HOURLY_BELLS: + if (!sConfigMgr->GetOption("ModCTASwitch.DailyCTA", false)) + return; + + time_t t = time(nullptr); + tm* now = localtime(&t); + + // Exclude Friday (5), Saturday (6), Sunday (0), and Monday (1) + if (now->tm_wday == 5 || now->tm_wday == 6 || now->tm_wday == 0 || now->tm_wday == 1) + return; + + if (!sGameEventMgr->IsActiveEvent(EVENT_CTA_ALTERAC_VALLEY) && + !sGameEventMgr->IsActiveEvent(EVENT_CTA_ARATHI_BASIN) && + !sGameEventMgr->IsActiveEvent(EVENT_CTA_WARSONG_GULCH) && + !sGameEventMgr->IsActiveEvent(EVENT_CTA_EYE_OF_THE_STORM) && + !sGameEventMgr->IsActiveEvent(EVENT_CTA_ISLE_OF_CONQUEST) && + !sGameEventMgr->IsActiveEvent(EVENT_CTA_STRAND_OF_THE_ANCIENTS)) + { + sGameEventMgr->StartEvent(urand(EVENT_CTA_WARSONG_GULCH, EVENT_CTA_EYE_OF_THE_STORM), true); + } + break; } } @@ -119,6 +142,15 @@ class cta_switch_event_script : public GameEventScript if (!sConfigMgr->GetOption("ModCTASwitch.Enable", 0)) return; + if (sConfigMgr->GetOption("ModCTASwitch.DailyCTA", false)) + return; + + time_t t = time(nullptr); + tm* now = localtime(&t); + + if (now->tm_wday != 2 /* Tuesday */) + return; + std::vector eventIds = { EVENT_CTA_ALTERAC_VALLEY, EVENT_CTA_ARATHI_BASIN, EVENT_CTA_WARSONG_GULCH, EVENT_CTA_EYE_OF_THE_STORM, EVENT_CTA_ISLE_OF_CONQUEST, EVENT_CTA_STRAND_OF_THE_ANCIENTS }; @@ -126,24 +158,18 @@ class cta_switch_event_script : public GameEventScript { if (sGameEventMgr->IsActiveEvent(activeEvent)) { - time_t t = time(nullptr); - tm* now = localtime(&t); + GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); - if (now->tm_wday == 2 /* Tuesday */) + if (std::size_t(activeEvent) >= events.size()) { - GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); - - if (std::size_t(activeEvent) >= events.size()) - { - LOG_ERROR("module", "[CTA-Switch]: Error, tried to stop unexisting event. ID: {}", activeEvent); - return; - } + LOG_ERROR("module", "[CTA-Switch]: Error, tried to stop unexisting event. ID: {}", activeEvent); + return; + } - GameEventData const& eventData = events[activeEvent]; + GameEventData const& eventData = events[activeEvent]; - sGameEventMgr->StopEvent(activeEvent, true); - LOG_INFO("module", "[CTA-Switch]: Stopping {} ({})", eventData.Description, activeEvent); - } + sGameEventMgr->StopEvent(activeEvent, true); + LOG_INFO("module", "[CTA-Switch]: Stopping {} ({})", eventData.Description, activeEvent); } } }