diff options
-rw-r--r-- | sql/updates/world/master/2017_08_20_03_world_2016_10_05_11_world_335.sql | 9 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.h | 1 | ||||
-rw-r--r-- | src/server/scripts/World/go_scripts.cpp | 133 |
4 files changed, 151 insertions, 0 deletions
diff --git a/sql/updates/world/master/2017_08_20_03_world_2016_10_05_11_world_335.sql b/sql/updates/world/master/2017_08_20_03_world_2016_10_05_11_world_335.sql new file mode 100644 index 00000000000..008cfe049a8 --- /dev/null +++ b/sql/updates/world/master/2017_08_20_03_world_2016_10_05_11_world_335.sql @@ -0,0 +1,9 @@ +-- Update Brewfest Music Doodad script +UPDATE `gameobject_template` SET `ScriptName`='go_brewfest_music' WHERE `entry`=186221; + +-- Add missing Brewfest Music Doodad spawns +SET @OGUID:=6037; +DELETE FROM `gameobject` WHERE `guid` BETWEEN @OGUID+0 AND @OGUID+1; +INSERT INTO `gameobject` (`guid`, `id`, `map`, `spawnMask`, `PhaseId`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES +(@OGUID+0 , 186221, 530, 1, 0, -1897.498, 5560.614, -12.34483, 4.363323, 0, 0, 0, 0, 120, 255, 1), +(@OGUID+1 , 186221, 530, 1, 0, 9325.442, -7276.318, 13.34217, 4.363323, 0, 0, 0, 0, 120, 255, 1); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 8746121ecbc..b2daeff5900 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -3110,6 +3110,14 @@ void WorldObject::PlayDirectSound(uint32 soundId, Player* target /*= nullptr*/) SendMessageToSet(WorldPackets::Misc::PlaySound(GetGUID(), soundId).Write(), true); } +void WorldObject::PlayDirectMusic(uint32 musicId, Player* target /*= nullptr*/) +{ + if (target) + target->SendDirectMessage(WorldPackets::Misc::PlayMusic(musicId).Write()); + else + SendMessageToSet(WorldPackets::Misc::PlayMusic(musicId).Write(), true); +} + void WorldObject::DestroyForNearbyPlayers() { if (!IsInWorld()) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 942c1792367..80fa6b298bc 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -480,6 +480,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation void PlayDistanceSound(uint32 soundId, Player* target = nullptr); void PlayDirectSound(uint32 soundId, Player* target = nullptr); + void PlayDirectMusic(uint32 musicId, Player* target = nullptr); virtual void SaveRespawnTime() { } void AddObjectToRemoveList(); diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 026d213478d..ebebcfb2a19 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -55,6 +55,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "TemporarySummon.h" #include "WorldSession.h" +#include "GameEventMgr.h" /*###### ## go_cat_figurine @@ -1191,6 +1192,137 @@ class go_toy_train_set : public GameObjectScript } }; +/*#### +## go_brewfest_music +####*/ + +enum BrewfestMusic +{ + EVENT_BREWFESTDWARF01 = 11810, // 1.35 min + EVENT_BREWFESTDWARF02 = 11812, // 1.55 min + EVENT_BREWFESTDWARF03 = 11813, // 0.23 min + EVENT_BREWFESTGOBLIN01 = 11811, // 1.08 min + EVENT_BREWFESTGOBLIN02 = 11814, // 1.33 min + EVENT_BREWFESTGOBLIN03 = 11815 // 0.28 min +}; + +// These are in seconds +enum BrewfestMusicTime +{ + EVENT_BREWFESTDWARF01_TIME = 95000, + EVENT_BREWFESTDWARF02_TIME = 155000, + EVENT_BREWFESTDWARF03_TIME = 23000, + EVENT_BREWFESTGOBLIN01_TIME = 68000, + EVENT_BREWFESTGOBLIN02_TIME = 93000, + EVENT_BREWFESTGOBLIN03_TIME = 28000 +}; + +enum BrewfestMusicAreas +{ + SILVERMOON = 3430, // Horde + UNDERCITY = 1497, + ORGRIMMAR_1 = 1296, + ORGRIMMAR_2 = 14, + THUNDERBLUFF = 1638, + IRONFORGE_1 = 809, // Alliance + IRONFORGE_2 = 1, + STORMWIND = 12, + EXODAR = 3557, + DARNASSUS = 1657, + SHATTRATH = 3703 // General +}; + +enum BrewfestMusicEvents +{ + EVENT_BM_SELECT_MUSIC = 1, + EVENT_BM_START_MUSIC = 2 +}; + +class go_brewfest_music : public GameObjectScript +{ +public: + go_brewfest_music() : GameObjectScript("go_brewfest_music") { } + + struct go_brewfest_musicAI : public GameObjectAI + { + go_brewfest_musicAI(GameObject* go) : GameObjectAI(go) + { + _events.ScheduleEvent(EVENT_BM_SELECT_MUSIC, 1000); + _events.ScheduleEvent(EVENT_BM_START_MUSIC, 2000); + } + + void UpdateAI(uint32 diff) override + { + _events.Update(diff); + uint32 rnd; + uint32 musicTime = 1000; + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_BM_SELECT_MUSIC: + if (!IsHolidayActive(HOLIDAY_BREWFEST)) // Check if Brewfest is active + break; + rnd = urand(0, 2); // Select random music sample + _events.ScheduleEvent(EVENT_BM_SELECT_MUSIC, musicTime); // Select new song music after play time is over + break; + case EVENT_BM_START_MUSIC: + if (!IsHolidayActive(HOLIDAY_BREWFEST)) // Check if Brewfest is active + break; + // Check if gob is correct area, play music, set time of music + if (go->GetAreaId() == SILVERMOON || go->GetAreaId() == UNDERCITY || go->GetAreaId() == ORGRIMMAR_1 || go->GetAreaId() == ORGRIMMAR_2 || go->GetAreaId() == THUNDERBLUFF || go->GetAreaId() == SHATTRATH) + { + if (rnd == 0) + { + go->PlayDirectMusic(EVENT_BREWFESTGOBLIN01); + musicTime = EVENT_BREWFESTGOBLIN01_TIME; + } + else if (rnd == 1) + { + go->PlayDirectMusic(EVENT_BREWFESTGOBLIN02); + musicTime = EVENT_BREWFESTGOBLIN02_TIME; + } + else + { + go->PlayDirectMusic(EVENT_BREWFESTGOBLIN03); + musicTime = EVENT_BREWFESTGOBLIN03_TIME; + } + } + if (go->GetAreaId() == IRONFORGE_1 || go->GetAreaId() == IRONFORGE_2 || go->GetAreaId() == STORMWIND || go->GetAreaId() == EXODAR || go->GetAreaId() == DARNASSUS || go->GetAreaId() == SHATTRATH) + { + if (rnd == 0) + { + go->PlayDirectMusic(EVENT_BREWFESTDWARF01); + musicTime = EVENT_BREWFESTDWARF01_TIME; + } + else if (rnd == 1) + { + go->PlayDirectMusic(EVENT_BREWFESTDWARF02); + musicTime = EVENT_BREWFESTDWARF02_TIME; + } + else + { + go->PlayDirectMusic(EVENT_BREWFESTDWARF03); + musicTime = EVENT_BREWFESTDWARF03_TIME; + } + } + _events.ScheduleEvent(EVENT_BM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client + break; + default: + break; + } + } + } + private: + EventMap _events; + }; + + GameObjectAI* GetAI(GameObject* go) const override + { + return new go_brewfest_musicAI(go); + } +}; + void AddSC_go_scripts() { new go_cat_figurine(); @@ -1228,4 +1360,5 @@ void AddSC_go_scripts() new go_midsummer_bonfire(); new go_midsummer_ribbon_pole(); new go_toy_train_set(); + new go_brewfest_music(); } |