From 7211c6e51d7471cef6c2de6bf1b1bf3711887835 Mon Sep 17 00:00:00 2001 From: ForesterDev Date: Fri, 26 May 2017 10:52:56 +0400 Subject: Scripts/Command: implement .debug play music command Closes #19809 (cherry picked from commit dd4ff1fe5458c89fc1d988fcc6ba5792ee482dcf) --- src/server/scripts/Commands/cs_debug.cpp | 66 +++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 18 deletions(-) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 11417b305a5..81bc3e533e1 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -61,6 +61,7 @@ public: { "cinematic", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_CINEMATIC, false, &HandleDebugPlayCinematicCommand, "" }, { "movie", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_MOVIE, false, &HandleDebugPlayMovieCommand, "" }, { "sound", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_SOUND, false, &HandleDebugPlaySoundCommand, "" }, + { "music", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_MUSIC, false, &HandleDebugPlayMusicCommand, "" }, }; static std::vector debugSendCommandTable = { @@ -117,8 +118,8 @@ public: static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, char const* args) { - // USAGE: .debug play cinematic #cinematicid - // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) + // USAGE: .debug play cinematic #cinematicId + // #cinematicId - ID decimal number from CinemaicSequences.dbc (1st column) if (!*args) { handler->SendSysMessage(LANG_BAD_VALUE); @@ -126,12 +127,12 @@ public: return false; } - uint32 id = atoul(args); + uint32 cinematicId = atoul(args); - CinematicSequencesEntry const* cineSeq = sCinematicSequencesStore.LookupEntry(id); + CinematicSequencesEntry const* cineSeq = sCinematicSequencesStore.LookupEntry(cinematicId); if (!cineSeq) { - handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, id); + handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, cinematicId); handler->SetSentErrorMessage(true); return false; } @@ -139,7 +140,7 @@ public: // Dump camera locations if (std::vector const* flyByCameras = GetFlyByCameras(cineSeq->Camera[0])) { - handler->PSendSysMessage("Waypoints for sequence %u, camera %u", id, cineSeq->Camera[0]); + handler->PSendSysMessage("Waypoints for sequence %u, camera %u", cinematicId, cineSeq->Camera[0]); uint32 count = 1; for (FlyByCamera const& cam : *flyByCameras) { @@ -149,14 +150,14 @@ public: handler->PSendSysMessage(SZFMTD " waypoints dumped", flyByCameras->size()); } - handler->GetSession()->GetPlayer()->SendCinematicStart(id); + handler->GetSession()->GetPlayer()->SendCinematicStart(cinematicId); return true; } static bool HandleDebugPlayMovieCommand(ChatHandler* handler, char const* args) { - // USAGE: .debug play movie #movieid - // #movieid - ID decimal number from Movie.dbc (1st column) + // USAGE: .debug play movie #movieId + // #movieId - ID decimal number from Movie.dbc (1st column) if (!*args) { handler->SendSysMessage(LANG_BAD_VALUE); @@ -164,24 +165,24 @@ public: return false; } - uint32 id = atoul(args); + uint32 movieId = atoul(args); - if (!sMovieStore.LookupEntry(id)) + if (!sMovieStore.LookupEntry(movieId)) { - handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, id); + handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, movieId); handler->SetSentErrorMessage(true); return false; } - handler->GetSession()->GetPlayer()->SendMovieStart(id); + handler->GetSession()->GetPlayer()->SendMovieStart(movieId); return true; } //Play sound static bool HandleDebugPlaySoundCommand(ChatHandler* handler, char const* args) { - // USAGE: .debug playsound #soundid - // #soundid - ID decimal number from SoundEntries.dbc (1st column) + // USAGE: .debug playsound #soundId + // #soundId - ID decimal number from SoundEntries.dbc (1st column) if (!*args) { handler->SendSysMessage(LANG_BAD_VALUE); @@ -198,6 +199,8 @@ public: return false; } + Player* player = handler->GetSession()->GetPlayer(); + Unit* unit = handler->getSelectedUnit(); if (!unit) { @@ -206,15 +209,42 @@ public: return false; } - if (!handler->GetSession()->GetPlayer()->GetTarget().IsEmpty()) - unit->PlayDistanceSound(soundId, handler->GetSession()->GetPlayer()); + if (player->GetTarget().IsEmpty()) + unit->PlayDistanceSound(soundId, player); else - unit->PlayDirectSound(soundId, handler->GetSession()->GetPlayer()); + unit->PlayDirectSound(soundId, player); handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, soundId); return true; } + static bool HandleDebugPlayMusicCommand(ChatHandler* handler, char const* args) + { + // USAGE: .debug play music #musicId + // #musicId - ID decimal number from SoundEntries.dbc (1st column) + if (!*args) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + + uint32 musicId = atoul(args); + if (!sSoundKitStore.LookupEntry(musicId)) + { + handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, musicId); + handler->SetSentErrorMessage(true); + return false; + } + + Player* player = handler->GetSession()->GetPlayer(); + + player->PlayDirectMusic(musicId, player); + + handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, musicId); + return true; + } + static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, char const* args) { if (!*args) -- cgit v1.2.3