diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index ea07eeafcfb..fa05118537c 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -297,7 +297,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsUnit(target)) { - target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr); + target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr, e.action.sound.keyBroadcastTextId); TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (%s), sound: %u, onlyself: %u", target->GetName().c_str(), target->GetGUID().ToString().c_str(), e.action.sound.sound, e.action.sound.onlySelf); } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 26563797b1c..3039afd29bf 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -625,6 +625,8 @@ struct SmartAction { uint32 sound; uint32 onlySelf; + uint32 distance; // NYI: awaiting cherry-pick + uint32 keyBroadcastTextId; } sound; struct diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 778e8132484..42f376f5080 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -359,7 +359,7 @@ void Battlefield::EndBattle(bool endByTimer) void Battlefield::DoPlaySoundToAll(uint32 soundID) { - BroadcastPacketToWar(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write()); + BroadcastPacketToWar(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID, 0).Write()); } bool Battlefield::HasPlayer(Player* player) const diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index fbf3a370ca0..4a50c20179c 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -619,12 +619,12 @@ void Battleground::SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject con void Battleground::PlaySoundToAll(uint32 soundID) { - SendPacketToAll(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write()); + SendPacketToAll(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID, 0).Write()); } void Battleground::PlaySoundToTeam(uint32 soundID, uint32 teamID) { - SendPacketToTeam(teamID, WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write()); + SendPacketToTeam(teamID, WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID, 0).Write()); } void Battleground::CastSpellOnTeam(uint32 SpellID, uint32 TeamID) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 477a0fa984b..96992a698a5 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2212,12 +2212,12 @@ void WorldObject::PlayDistanceSound(uint32 soundId, Player* target /*= nullptr*/ SendMessageToSet(WorldPackets::Misc::PlaySpeakerbotSound(GetGUID(), soundId).Write(), true); } -void WorldObject::PlayDirectSound(uint32 soundId, Player* target /*= nullptr*/) +void WorldObject::PlayDirectSound(uint32 soundId, Player* target /*= nullptr*/, uint32 broadcastTextId /*= 0*/) { if (target) - target->SendDirectMessage(WorldPackets::Misc::PlaySound(GetGUID(), soundId).Write()); + target->SendDirectMessage(WorldPackets::Misc::PlaySound(GetGUID(), soundId, broadcastTextId).Write()); else - SendMessageToSet(WorldPackets::Misc::PlaySound(GetGUID(), soundId).Write(), true); + SendMessageToSet(WorldPackets::Misc::PlaySound(GetGUID(), soundId, broadcastTextId).Write(), true); } void WorldObject::PlayDirectMusic(uint32 musicId, Player* target /*= nullptr*/) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 3a5f06062ee..5efc9825bc7 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -472,7 +472,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation virtual uint8 GetLevelForTarget(WorldObject const* /*target*/) const { return 1; } void PlayDistanceSound(uint32 soundId, Player* target = nullptr); - void PlayDirectSound(uint32 soundId, Player* target = nullptr); + void PlayDirectSound(uint32 soundId, Player* target = nullptr, uint32 broadcastTextId = 0); void PlayDirectMusic(uint32 musicId, Player* target = nullptr); virtual void SaveRespawnTime(uint32 /*forceDelay*/ = 0, bool /*saveToDB*/ = true) { } diff --git a/src/server/game/Server/Packets/MiscPackets.h b/src/server/game/Server/Packets/MiscPackets.h index 78ea4fb997e..566e85ab16d 100644 --- a/src/server/game/Server/Packets/MiscPackets.h +++ b/src/server/game/Server/Packets/MiscPackets.h @@ -640,7 +640,8 @@ namespace WorldPackets { public: PlaySound() : ServerPacket(SMSG_PLAY_SOUND, 20) { } - PlaySound(ObjectGuid sourceObjectGuid, int32 soundKitID) : ServerPacket(SMSG_PLAY_SOUND, 20), SourceObjectGuid(sourceObjectGuid), SoundKitID(soundKitID) { } + PlaySound(ObjectGuid sourceObjectGuid, int32 soundKitID, int32 broadcastTextId) : ServerPacket(SMSG_PLAY_SOUND, 20), + SourceObjectGuid(sourceObjectGuid), SoundKitID(soundKitID), BroadcastTextID(broadcastTextId) { } WorldPacket const* Write() override; diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 9e27747c60a..e388e5f80a0 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -259,7 +259,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject range = iter->TextRange; if (finalSound) - SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly); + SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly, iter->BroadcastTextId); Unit* finalSource = source; if (srcPlr) @@ -302,12 +302,13 @@ float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) return dist; } -void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/) +void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, + Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, uint32 keyBroadcastTextId /*= 0*/) { if (!sound || !source) return; - SendNonChatPacket(source, WorldPackets::Misc::PlaySound(source->GetGUID(), sound).Write(), msgType, whisperTarget, range, team, gmOnly); + SendNonChatPacket(source, WorldPackets::Misc::PlaySound(source->GetGUID(), sound, keyBroadcastTextId).Write(), msgType, whisperTarget, range, team, gmOnly); } void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index cc76ae1588b..9c15000cd42 100644 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -93,7 +93,7 @@ class TC_GAME_API CreatureTextMgr void LoadCreatureTextLocales(); CreatureTextMap const& GetTextMap() const { return mTextMap; } - static void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false); + static void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false, uint32 keyBroadcastTextId = 0); static void SendEmote(Unit* source, uint32 emote); //if sent, returns the 'duration' of the text else 0 if error diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 086b72be892..c7563bf298d 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -2686,7 +2686,9 @@ class misc_commandscript : public CommandScript if (!*args) return false; - uint32 soundId = atoul(args); + char const* soundIdToken = strtok((char*)args, " "); + + uint32 soundId = atoul(soundIdToken); if (!sSoundKitStore.LookupEntry(soundId)) { @@ -2695,7 +2697,12 @@ class misc_commandscript : public CommandScript return false; } - sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(handler->GetSession()->GetPlayer()->GetGUID(), soundId).Write()); + uint32 broadcastTextId = 0; + char const* broadcastTextIdToken = strtok(nullptr, " "); + if (broadcastTextIdToken) + broadcastTextId = atoul(broadcastTextIdToken); + + sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(handler->GetSession()->GetPlayer()->GetGUID(), soundId, broadcastTextId).Write()); handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); return true;