mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
refactor(Core/Unit): clean MonsterText methods (#6957)
This commit is contained in:
@@ -8728,7 +8728,7 @@ void Player::StopCastingCharm()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::Say(const std::string& text, const uint32 language)
|
||||
void Player::Say(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
|
||||
{
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
|
||||
@@ -8738,11 +8738,16 @@ void Player::Say(const std::string& text, const uint32 language)
|
||||
#endif
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, Language(language), this, this, _text);
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, language, this, this, _text);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
|
||||
}
|
||||
|
||||
void Player::Yell(const std::string& text, const uint32 language)
|
||||
void Player::Say(uint32 textId, WorldObject const* target /*= nullptr*/)
|
||||
{
|
||||
Talk(textId, CHAT_MSG_SAY, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), target);
|
||||
}
|
||||
|
||||
void Player::Yell(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
|
||||
{
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
|
||||
@@ -8752,11 +8757,16 @@ void Player::Yell(const std::string& text, const uint32 language)
|
||||
#endif
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, Language(language), this, this, _text);
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, language, this, this, _text);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), true);
|
||||
}
|
||||
|
||||
void Player::TextEmote(const std::string& text)
|
||||
void Player::Yell(uint32 textId, WorldObject const* target /*= nullptr*/)
|
||||
{
|
||||
Talk(textId, CHAT_MSG_YELL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), target);
|
||||
}
|
||||
|
||||
void Player::TextEmote(std::string_view text, WorldObject const* /*= nullptr*/, bool /*= false*/)
|
||||
{
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
|
||||
@@ -8766,68 +8776,79 @@ void Player::TextEmote(const std::string& text)
|
||||
#endif
|
||||
|
||||
WorldPacket data;
|
||||
std::list<Player*> players;
|
||||
Acore::AnyPlayerInObjectRangeCheck checker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
|
||||
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, players, checker);
|
||||
Cell::VisitWorldObjects(this, searcher, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
|
||||
|
||||
for (auto const& itr : players)
|
||||
{
|
||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_EMOTE) && this->GetTeamId() != itr->GetTeamId())
|
||||
{
|
||||
LocaleConstant loc_idx = itr->GetSession()->GetSessionDbLocaleIndex();
|
||||
if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(EMOTE_BROADCAST_TEXT_ID_STRANGE_GESTURES))
|
||||
{
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, bct->GetText(loc_idx, this->getGender()));
|
||||
itr->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text);
|
||||
itr->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
|
||||
}
|
||||
|
||||
void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiver)
|
||||
void Player::TextEmote(uint32 textId, WorldObject const* target /*= nullptr*/, bool /*isBossEmote = false*/)
|
||||
{
|
||||
Talk(textId, CHAT_MSG_EMOTE, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
|
||||
}
|
||||
|
||||
void Player::Whisper(std::string_view text, Language language, Player* target, bool /*= false*/)
|
||||
{
|
||||
ASSERT(target);
|
||||
|
||||
bool isAddonMessage = language == LANG_ADDON;
|
||||
|
||||
if (!isAddonMessage) // if not addon data
|
||||
language = LANG_UNIVERSAL; // whispers should always be readable
|
||||
|
||||
Player* rPlayer = ObjectAccessor::FindConnectedPlayer(receiver);
|
||||
|
||||
std::string _text(text);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer);
|
||||
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, target);
|
||||
#ifdef ELUNA
|
||||
if (!sEluna->OnChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer))
|
||||
if (!sEluna->OnChat(this, CHAT_MSG_WHISPER, language, _text, target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, Language(language), this, this, _text);
|
||||
rPlayer->GetSession()->SendPacket(&data);
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, language, this, this, _text);
|
||||
target->GetSession()->SendPacket(&data);
|
||||
|
||||
// rest stuff shouldn't happen in case of addon message
|
||||
if (isAddonMessage)
|
||||
return;
|
||||
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER_INFORM, Language(language), rPlayer, rPlayer, _text);
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER_INFORM, Language(language), target, target, _text);
|
||||
GetSession()->SendPacket(&data);
|
||||
|
||||
if (!isAcceptWhispers() && !IsGameMaster() && !rPlayer->IsGameMaster())
|
||||
if (!isAcceptWhispers() && !IsGameMaster() && !target->IsGameMaster())
|
||||
{
|
||||
SetAcceptWhispers(true);
|
||||
ChatHandler(GetSession()).SendSysMessage(LANG_COMMAND_WHISPERON);
|
||||
}
|
||||
|
||||
// announce afk or dnd message
|
||||
if (rPlayer->isAFK())
|
||||
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->autoReplyMsg.c_str());
|
||||
else if (rPlayer->isDND())
|
||||
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->autoReplyMsg.c_str());
|
||||
if (target->isAFK())
|
||||
{
|
||||
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, target->GetName().c_str(), target->autoReplyMsg.c_str());
|
||||
}
|
||||
else if (target->isDND())
|
||||
{
|
||||
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, target->GetName().c_str(), target->autoReplyMsg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Player::Whisper(uint32 textId, Player* target, bool /*isBossWhisper = false*/)
|
||||
{
|
||||
if (!target)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BroadcastText const* bct = sObjectMgr->GetBroadcastText(textId);
|
||||
if (!bct)
|
||||
{
|
||||
LOG_ERROR("entities.unit", "Player::Whisper: `broadcast_text` was not %u found", textId);
|
||||
return;
|
||||
}
|
||||
|
||||
LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale);
|
||||
target->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void Player::PetSpellInitialize()
|
||||
|
||||
Reference in New Issue
Block a user