diff options
| author | ModoX <moardox@gmail.com> | 2021-10-23 13:10:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-23 13:10:32 +0200 |
| commit | 437fb2aaba8850dd81a15d661c82403be9170c4e (patch) | |
| tree | c0859c3e0e3c8badfd088876bd7a819028c3868a /src/server/game | |
| parent | 8b171d7c019f0010ec05af92466261d4be78bfff (diff) | |
Core/CreatureTexts: Added new field SoundPlayType to enable usage of ObjectSounds within creature_text (#27136)
* Also adjusted Vigilant Quoram texts to use ObjectSounds
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Battlefield/Zones/BattlefieldWG.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/Texts/CreatureTextMgr.cpp | 36 | ||||
| -rw-r--r-- | src/server/game/Texts/CreatureTextMgr.h | 12 |
4 files changed, 42 insertions, 12 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index b019d6816e5..3ee4d97aa03 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -303,7 +303,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u else if (IsPlayer(target) && me) { Unit* templastInvoker = GetLastInvoker(); - sCreatureTextMgr->SendChat(me, uint8(e.action.talk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker : nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, target->ToPlayer()); + sCreatureTextMgr->SendChat(me, uint8(e.action.talk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker : nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, SoundKitPlayType::Normal, TEAM_OTHER, false, target->ToPlayer()); } TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: %s (%s), textGroupId: %u", target->GetName().c_str(), target->GetGUID().ToString().c_str(), uint8(e.action.talk.textGroupID)); diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index c4ee56d41f5..16a579a868b 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -1016,7 +1016,7 @@ void BattlefieldWG::PromotePlayer(Player* killer) killer->RemoveAura(SPELL_RECRUIT); killer->CastSpell(killer, SPELL_CORPORAL, true); if (Creature* stalker = GetCreature(StalkerGuid)) - sCreatureTextMgr->SendChat(stalker, BATTLEFIELD_WG_TEXT_RANK_CORPORAL, killer, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, killer); + sCreatureTextMgr->SendChat(stalker, BATTLEFIELD_WG_TEXT_RANK_CORPORAL, killer, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, SoundKitPlayType::Normal, TEAM_OTHER, false, killer); } else killer->CastSpell(killer, SPELL_RECRUIT, true); @@ -1028,7 +1028,7 @@ void BattlefieldWG::PromotePlayer(Player* killer) killer->RemoveAura(SPELL_CORPORAL); killer->CastSpell(killer, SPELL_LIEUTENANT, true); if (Creature* stalker = GetCreature(StalkerGuid)) - sCreatureTextMgr->SendChat(stalker, BATTLEFIELD_WG_TEXT_RANK_FIRST_LIEUTENANT, killer, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, killer); + sCreatureTextMgr->SendChat(stalker, BATTLEFIELD_WG_TEXT_RANK_FIRST_LIEUTENANT, killer, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, SoundKitPlayType::Normal, TEAM_OTHER, false, killer); } else killer->CastSpell(killer, SPELL_CORPORAL, true); diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 86a6aae3306..754b66f45d1 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -70,8 +70,9 @@ void CreatureTextMgr::LoadCreatureTexts() temp.emote = Emote(fields[7].GetUInt32()); temp.duration = fields[8].GetUInt32(); temp.sound = fields[9].GetUInt32(); - temp.BroadcastTextId = fields[10].GetUInt32(); - temp.TextRange = CreatureTextRange(fields[11].GetUInt8()); + temp.SoundPlayType = SoundKitPlayType(fields[10].GetUInt8()); + temp.BroadcastTextId = fields[11].GetUInt32(); + temp.TextRange = CreatureTextRange(fields[12].GetUInt8()); if (temp.sound) { @@ -82,6 +83,12 @@ void CreatureTextMgr::LoadCreatureTexts() } } + if (temp.SoundPlayType >= SoundKitPlayType::Max) + { + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has PlayType %u but does not exist.", temp.creatureId, temp.groupId, uint32(temp.SoundPlayType)); + temp.SoundPlayType = SoundKitPlayType::Normal; + } + if (temp.lang != LANG_UNIVERSAL && !sLanguageMgr->IsLanguageExist(temp.lang)) { TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` using Language %u but Language does not exist.", temp.creatureId, temp.groupId, uint32(temp.lang)); @@ -159,7 +166,7 @@ void CreatureTextMgr::LoadCreatureTextLocales() TC_LOG_INFO("server.loading", ">> Loaded %u creature localized texts in %u ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime)); } -uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget /*= nullptr*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= nullptr*/) +uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget /*= nullptr*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, SoundKitPlayType playType /*= SoundKitPlayType::Normal*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= nullptr*/) { if (!source) return 0; @@ -201,8 +208,12 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject ChatMsg finalType = (msgType == CHAT_MSG_ADDON) ? iter->type : msgType; Language finalLang = (language == LANG_ADDON) ? iter->lang : language; uint32 finalSound = iter->sound; + SoundKitPlayType finalPlayType = iter->SoundPlayType; if (sound) + { finalSound = sound; + finalPlayType = playType; + } else if (BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(iter->BroadcastTextId)) if (uint32 broadcastTextSoundId = bct->SoundEntriesID[source->getGender() == GENDER_FEMALE ? 1 : 0]) finalSound = broadcastTextSoundId; @@ -211,7 +222,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject range = iter->TextRange; if (finalSound) - SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly, iter->BroadcastTextId); + SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly, iter->BroadcastTextId, finalPlayType); Unit* finalSource = source; if (srcPlr) @@ -255,12 +266,23 @@ float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) } 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*/) + Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, uint32 keyBroadcastTextId /*= 0*/, SoundKitPlayType playType /*= SoundKitPlayType::Normal*/) { if (!sound || !source) return; - SendNonChatPacket(source, WorldPackets::Misc::PlaySound(source->GetGUID(), sound, keyBroadcastTextId).Write(), msgType, whisperTarget, range, team, gmOnly); + if (playType == SoundKitPlayType::ObjectSound) + { + WorldPackets::Misc::PlayObjectSound pkt; + pkt.TargetObjectGUID = whisperTarget->GetGUID(); + pkt.SourceObjectGUID = source->GetGUID(); + pkt.SoundKitID = sound; + pkt.Position = whisperTarget->GetWorldLocation(); + pkt.BroadcastTextID = keyBroadcastTextId; + SendNonChatPacket(source, pkt.Write(), msgType, whisperTarget, range, team, gmOnly); + } + else if (playType == SoundKitPlayType::Normal) + 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) @@ -336,7 +358,7 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* case TEXT_RANGE_PERSONAL: if (!whisperTarget || !whisperTarget->IsPlayer()) return; - + whisperTarget->ToPlayer()->SendDirectMessage(data); return; case TEXT_RANGE_NORMAL: diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index 72f3e99cf62..084d9b40f1e 100644 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -40,6 +40,13 @@ enum CreatureTextRange TEXT_RANGE_PERSONAL = 5 }; +enum class SoundKitPlayType : uint8 +{ + Normal = 0, + ObjectSound = 1, + Max = 2, +}; + struct CreatureTextEntry { uint32 creatureId; @@ -52,6 +59,7 @@ struct CreatureTextEntry Emote emote; uint32 duration; uint32 sound; + SoundKitPlayType SoundPlayType; uint32 BroadcastTextId; CreatureTextRange TextRange; }; @@ -94,11 +102,11 @@ 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, uint32 keyBroadcastTextId = 0); + 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, SoundKitPlayType playType = SoundKitPlayType::Normal); static void SendEmote(Unit* source, uint32 emote); //if sent, returns the 'duration' of the text else 0 if error - uint32 SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget = nullptr, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, CreatureTextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = nullptr); + uint32 SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget = nullptr, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, CreatureTextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, SoundKitPlayType playType = SoundKitPlayType::Normal, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = nullptr); bool TextExist(uint32 sourceEntry, uint8 textGroup) const; std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const; |
