From 3b89a7e077bcb328d49e3d34ac95ca991b2aa6e4 Mon Sep 17 00:00:00 2001 From: schell244 Date: Sun, 14 Nov 2021 19:23:01 +0100 Subject: [PATCH] fix(Core/Script): add hourly bell event (#9151) --- .../rev_1636718487600176900.sql | 59 ++++++ src/server/scripts/World/go_scripts.cpp | 185 ++++++++++++++++++ 2 files changed, 244 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1636718487600176900.sql diff --git a/data/sql/updates/pending_db_world/rev_1636718487600176900.sql b/data/sql/updates/pending_db_world/rev_1636718487600176900.sql new file mode 100644 index 000000000..4ef19be99 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1636718487600176900.sql @@ -0,0 +1,59 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1636718487600176900'); + +UPDATE `gameobject_template` SET `ScriptName`='go_bells' WHERE `entry` IN (175885, 176573, 182064); + +DELETE FROM `game_event` WHERE `eventEntry`=73; +INSERT INTO `game_event` (`eventEntry`, `start_time`, `end_time`, `occurence`, `length`, `holiday`,`holidayStage`, `description`, `world_event`, `announce`) VALUES +(73, '2010-01-01 01:00:00', '2030-01-01 01:00:00', 60, 1, 0, 0, 'Hourly Bells', 0, 2); + +DELETE FROM `game_event_gameobject` WHERE `eventEntry`=73; + +-- Horde bells +INSERT INTO `game_event_gameobject` (`eventEntry`, `guid`) VALUES +(73, 12435), -- Orgrimmar +(73, 12436), -- Orgrimmar +(73, 12437), -- Orgrimmar +(73, 12438), -- Orgrimmar +(73, 12439), -- Orgrimmar +(73, 15508), -- Darkshire +(73, 18097), -- Thunder Bluff +(73, 18098), -- Thunder Bluff +(73, 18099), -- Thunder Bluff +(73, 18100), -- Thunder Bluff +(73, 18101), -- Thunder Bluff +(73, 18102), -- Thunder Bluff +(73, 18103), -- Thunder Bluff +(73, 18683), -- Stonebreaker Hold +(73, 20802), -- Tarren Mill +(73, 45022); -- Brill + +-- Alliance bells +INSERT INTO `game_event_gameobject` (`eventEntry`, `guid`) VALUES +(73, 94), -- Ironforge +(73, 619), -- Ironforge +(73, 870), -- Ironforge +(73, 1140), -- Kharanos +(73, 4841), -- Ironforge +(73, 6867), -- Ironforge +(73, 9104), -- Alcaz Island +(73, 9114), -- Theramore +(73, 14562), -- Menethil +(73, 18894), -- Allerian Stronghold +(73, 18901), -- Stormwind +(73, 18896), -- Shattrath +(73, 20801), -- Hillsbrad +(73, 26283), -- Stormwind +(73, 26414), -- Stormwind +(73, 26435), -- Stormwind +(73, 26469), -- Stormwind +(73, 26743), -- Northshire Abbey +(73, 42666), -- Westfall Lighthouse +(73, 42905), -- Stormwind +(73, 42906), -- Stormwind +(73, 42924), -- Stormwind +(73, 48107), -- Astranaar +(73, 49811); -- Darnassus + +-- karazhan bell +INSERT INTO `game_event_gameobject` (`eventEntry`, `guid`) VALUES +(73, 24539); \ No newline at end of file diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 7a58b5ac3..6a8089f2e 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -1625,6 +1625,190 @@ public: } }; +/*#### +## go_bells +####*/ + +enum BellHourlySoundFX +{ + BELLTOLLHORDE = 6595, + BELLTOLLTRIBAL = 6675, + BELLTOLLALLIANCE = 6594, + BELLTOLLNIGHTELF = 6674, + BELLTOLLDWARFGNOME = 7234, + BELLTOLLKHARAZHAN = 9154, + LIGHTHOUSEFOGHORN = 7197 +}; + +enum BellHourlySoundZones +{ + TIRISFAL_ZONE = 85, + UNDERCITY_ZONE = 1497, + DUN_MOROGH_ZONE = 1, + IRONFORGE_ZONE = 1537, + TELDRASSIL_ZONE = 141, + DARNASSUS_ZONE = 1657, + ASHENVALE_ZONE = 331, + HILLSBRAD_FOOTHILLS_ZONE = 267, + DUSKWOOD_ZONE = 10, + WESTFALL_ZONE = 40, + DUSTWALLOW_MARSH_ZONE = 15, + SHATTRATH_ZONE = 3703 +}; + +enum LightHouseAreas +{ + AREA_ALCAZ_ISLAND = 2079, + AREA_WESTFALL_LIGHTHOUSE = 115 +}; + +enum BellHourlyObjects +{ + GO_HORDE_BELL = 175885, + GO_ALLIANCE_BELL = 176573, + GO_KHARAZHAN_BELL = 182064 +}; + +enum BellHourlyMisc +{ + GAME_EVENT_HOURLY_BELLS = 73, + EVENT_RING_BELL = 1, + EVENT_TIME = 2 +}; + +class go_bells : public GameObjectScript +{ +public: + go_bells() : GameObjectScript("go_bells") {} + + struct go_bellsAI : public GameObjectAI + { + go_bellsAI(GameObject* go) : GameObjectAI(go), _soundId(0), once(true) + { + uint32 zoneId = go->GetZoneId(); + + switch (go->GetEntry()) + { + case GO_HORDE_BELL: + { + switch (zoneId) + { + case TIRISFAL_ZONE: + case UNDERCITY_ZONE: + case HILLSBRAD_FOOTHILLS_ZONE: + case DUSKWOOD_ZONE: + _soundId = BELLTOLLHORDE; + break; + default: + _soundId = BELLTOLLTRIBAL; + break; + } + break; + } + case GO_ALLIANCE_BELL: + { + switch (zoneId) + { + case IRONFORGE_ZONE: + case DUN_MOROGH_ZONE: + _soundId = BELLTOLLDWARFGNOME; + break; + case DARNASSUS_ZONE: + case TELDRASSIL_ZONE: + case ASHENVALE_ZONE: + case SHATTRATH_ZONE: + _soundId = BELLTOLLNIGHTELF; + break; + case WESTFALL_ZONE: + if (go->GetAreaId() == AREA_WESTFALL_LIGHTHOUSE) + { + _soundId = LIGHTHOUSEFOGHORN; + } + else + { + _soundId = BELLTOLLALLIANCE; + } + break; + case DUSTWALLOW_MARSH_ZONE: + if (go->GetAreaId() == AREA_ALCAZ_ISLAND) + { + _soundId = LIGHTHOUSEFOGHORN; + } + else + { + _soundId = BELLTOLLALLIANCE; + } + break; + default: + _soundId = BELLTOLLALLIANCE; + break; + } + break; + } + case GO_KHARAZHAN_BELL: + { + _soundId = BELLTOLLKHARAZHAN; + break; + } + break; + } + } + + void UpdateAI(uint32 const diff) override + { + _events.Update(diff); + + if (sGameEventMgr->IsActiveEvent(GAME_EVENT_HOURLY_BELLS) && once) + { + // Reset + once = false; + _events.ScheduleEvent(EVENT_TIME, 1000); + } + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_TIME: + { + // Get how many times it should ring + time_t t = time(nullptr); + tm local_tm; + tzset(); // set timezone for localtime_r() -> fix issues due to daylight time + localtime_r(&t, &local_tm); + uint8 _rings = (local_tm.tm_hour) % 12; + _rings = (_rings == 0) ? 12 : _rings; // 00:00 and 12:00 + + // Schedule ring event + for (auto i = 0; i < _rings; ++i) + { + _events.ScheduleEvent(EVENT_RING_BELL, (i * 4 + 1) * 1000); + } + break; + } + case EVENT_RING_BELL: + { + me->PlayDirectSound(_soundId); + break; + } + default: + break; + } + } + } + + private: + EventMap _events; + uint32 _soundId; + bool once; + }; + + GameObjectAI* GetAI(GameObject* go) const override + { + return new go_bellsAI(go); + } +}; + void AddSC_go_scripts() { // Ours @@ -1667,4 +1851,5 @@ void AddSC_go_scripts() new go_hive_pod(); new go_massive_seaforium_charge(); new go_veil_skith_cage(); + new go_bells(); }