diff options
author | Kittnz <frederik156@hotmail.com> | 2016-10-08 15:49:18 +0200 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-09-05 11:10:56 +0200 |
commit | bd938d643d981f6e0c43b4cbcf1fc7ea1c0771b1 (patch) | |
tree | 9700712dd28df360fd8002f8f3aa6fad3e1b16b1 | |
parent | 8fb07040acb59825797d19881f91eed2b1364474 (diff) |
Core/Event: Pirate Day Music during the event
(cherry picked from commit 963278459a1d9df5aa3c2e1c8b5f5f112f6a370c)
-rw-r--r-- | sql/updates/world/master/2017_09_05_04_world_2016_10_08_03_world_335.sql | 2 | ||||
-rw-r--r-- | src/server/scripts/World/go_scripts.cpp | 57 |
2 files changed, 59 insertions, 0 deletions
diff --git a/sql/updates/world/master/2017_09_05_04_world_2016_10_08_03_world_335.sql b/sql/updates/world/master/2017_09_05_04_world_2016_10_08_03_world_335.sql new file mode 100644 index 00000000000..a0aa0e659bc --- /dev/null +++ b/sql/updates/world/master/2017_09_05_04_world_2016_10_08_03_world_335.sql @@ -0,0 +1,2 @@ +-- Update Pirate Day Music Doodad script +UPDATE `gameobject_template` SET `ScriptName`='go_pirate_day_music' WHERE `entry`=190363; diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 92a840de7e5..d354eb46d51 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -1453,6 +1453,62 @@ public: } }; +/*#### +## go_pirate_day_music +####*/ + +enum PirateDayMusic +{ + MUSIC_PIRATE_DAY_MUSIC = 12845 +}; + +enum PirateDayMusicEvents +{ + EVENT_PDM_START_MUSIC = 1 +}; + +class go_pirate_day_music : public GameObjectScript +{ +public: + go_pirate_day_music() : GameObjectScript("go_pirate_day_music") { } + + struct go_pirate_day_musicAI : public GameObjectAI + { + uint32 rnd; + + go_pirate_day_musicAI(GameObject* go) : GameObjectAI(go) + { + _events.ScheduleEvent(EVENT_PDM_START_MUSIC, 1000); + } + + void UpdateAI(uint32 diff) override + { + _events.Update(diff); + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_PDM_START_MUSIC: + if (!IsHolidayActive(HOLIDAY_PIRATES_DAY)) + break; + go->PlayDirectMusic(MUSIC_PIRATE_DAY_MUSIC); + _events.ScheduleEvent(EVENT_PDM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client (sniffed value) + break; + default: + break; + } + } + } + private: + EventMap _events; + }; + + GameObjectAI* GetAI(GameObject* go) const override + { + return new go_pirate_day_musicAI(go); + } +}; + void AddSC_go_scripts() { new go_cat_figurine(); @@ -1493,4 +1549,5 @@ void AddSC_go_scripts() new go_brewfest_music(); new go_midsummer_music(); new go_darkmoon_faire_music(); + new go_pirate_day_music(); } |