refactor(Core/Unit): clean MonsterText methods (#6957)

This commit is contained in:
Kitzunu
2021-10-15 10:25:29 +02:00
committed by GitHub
parent 3c42a7d72d
commit bc82f36f1f
75 changed files with 750 additions and 672 deletions

View File

@@ -1936,16 +1936,6 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
return true;
}
void WorldObject::SendPlaySound(uint32 Sound, bool OnlySelf)
{
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << Sound;
if (OnlySelf && GetTypeId() == TYPEID_PLAYER)
this->ToPlayer()->GetSession()->SendPacket(&data);
else
SendMessageToSet(&data, true); // ToSelf ignored in this case
}
void WorldObject::SendPlayMusic(uint32 Music, bool OnlySelf)
{
WorldPacket data(SMSG_PLAY_MUSIC, 4);
@@ -1962,165 +1952,6 @@ void Object::ForceValuesUpdateAtIndex(uint32 i)
AddToObjectUpdateIfNeeded();
}
namespace Acore
{
class MonsterChatBuilder
{
public:
MonsterChatBuilder(WorldObject const* obj, ChatMsg msgtype, int32 textId, uint32 language, WorldObject const* target)
: i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(Language(language)), i_target(target) { }
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
if (BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(i_textId))
{
uint8 gender = GENDER_MALE;
if (Unit const* unit = i_object->ToUnit())
gender = unit->getGender();
std::string text = broadcastText->GetText(loc_idx, gender);
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, text, 0, "", loc_idx);
}
else
LOG_ERROR("entities.object", "MonsterChatBuilder: `broadcast_text` id %i missing", i_textId);
}
private:
WorldObject const* i_object;
ChatMsg i_msgtype;
int32 i_textId;
Language i_language;
WorldObject const* i_target;
};
class MonsterCustomChatBuilder
{
public:
MonsterCustomChatBuilder(WorldObject const* obj, ChatMsg msgtype, const char* text, uint32 language, WorldObject const* target)
: i_object(obj), i_msgtype(msgtype), i_text(text), i_language(Language(language)), i_target(target)
{}
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, i_text, 0, "", loc_idx);
}
private:
WorldObject const* i_object;
ChatMsg i_msgtype;
const char* i_text;
Language i_language;
WorldObject const* i_target;
};
} // namespace Acore
void WorldObject::MonsterSay(const char* text, uint32 language, WorldObject const* target)
{
CellCoord p = Acore::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
cell.SetNoCreate();
Acore::MonsterCustomChatBuilder say_build(this, CHAT_MSG_MONSTER_SAY, text, language, target);
Acore::LocalizedPacketDo<Acore::MonsterCustomChatBuilder> say_do(say_build);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterCustomChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do);
TypeContainerVisitor<Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterCustomChatBuilder> >, WorldTypeMapContainer > message(say_worker);
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY));
}
void WorldObject::MonsterSay(int32 textId, uint32 language, WorldObject const* target)
{
CellCoord p = Acore::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
cell.SetNoCreate();
Acore::MonsterChatBuilder say_build(this, CHAT_MSG_MONSTER_SAY, textId, language, target);
Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> say_do(say_build);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do);
TypeContainerVisitor<Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker);
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY));
}
void WorldObject::MonsterYell(const char* text, uint32 language, WorldObject const* target)
{
CellCoord p = Acore::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
cell.SetNoCreate();
Acore::MonsterCustomChatBuilder say_build(this, CHAT_MSG_MONSTER_YELL, text, language, target);
Acore::LocalizedPacketDo<Acore::MonsterCustomChatBuilder> say_do(say_build);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterCustomChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), say_do);
TypeContainerVisitor<Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterCustomChatBuilder> >, WorldTypeMapContainer > message(say_worker);
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL));
}
void WorldObject::MonsterYell(int32 textId, uint32 language, WorldObject const* target)
{
CellCoord p = Acore::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
cell.SetNoCreate();
Acore::MonsterChatBuilder say_build(this, CHAT_MSG_MONSTER_YELL, textId, language, target);
Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> say_do(say_build);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), say_do);
TypeContainerVisitor<Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker);
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL));
}
void WorldObject::MonsterTextEmote(const char* text, WorldObject const* target, bool IsBossEmote)
{
WorldPacket data;
ChatHandler::BuildChatPacket(data, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, LANG_UNIVERSAL,
this, target, text);
SendMessageToSetInRange(&data, (IsBossEmote ? 200.0f : sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)), true);
}
void WorldObject::MonsterTextEmote(int32 textId, WorldObject const* target, bool IsBossEmote)
{
CellCoord p = Acore::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
cell.SetNoCreate();
Acore::MonsterChatBuilder say_build(this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, target);
Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> say_do(say_build);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> > say_worker(this, (IsBossEmote ? 200.0f : sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)), say_do);
TypeContainerVisitor<Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker);
cell.Visit(p, message, *GetMap(), *this, (IsBossEmote ? 200.0f : sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)));
}
void WorldObject::MonsterWhisper(const char* text, Player const* target, bool IsBossWhisper)
{
if (!target)
return;
LocaleConstant loc_idx = target->GetSession()->GetSessionDbLocaleIndex();
WorldPacket data;
ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, text, 0, "", loc_idx);
target->GetSession()->SendPacket(&data);
}
void WorldObject::MonsterWhisper(int32 textId, Player const* target, bool IsBossWhisper)
{
if (!target)
return;
uint8 gender = GENDER_MALE;
if (Unit const* unit = ToUnit())
gender = unit->getGender();
LocaleConstant loc_idx = target->GetSession()->GetSessionDbLocaleIndex();
BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(textId);
std::string text = broadcastText->GetText(loc_idx, gender);
WorldPacket data;
ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, text.c_str(), 0, "", loc_idx);
target->GetSession()->SendPacket(&data);
}
void Unit::BuildHeartBeatMsg(WorldPacket* data) const
{
data->Initialize(MSG_MOVE_HEARTBEAT, 32);

View File

@@ -937,15 +937,6 @@ public:
virtual uint8 getLevelForTarget(WorldObject const* /*target*/) const { return 1; }
void MonsterSay(const char* text, uint32 language, WorldObject const* target);
void MonsterYell(const char* text, uint32 language, WorldObject const* target);
void MonsterTextEmote(const char* text, WorldObject const* target, bool IsBossEmote = false);
void MonsterWhisper(const char* text, Player const* target, bool IsBossWhisper = false);
void MonsterSay(int32 textId, uint32 language, WorldObject const* target);
void MonsterYell(int32 textId, uint32 language, WorldObject const* target);
void MonsterTextEmote(int32 textId, WorldObject const* target, bool IsBossEmote = false);
void MonsterWhisper(int32 textId, Player const* target, bool IsBossWhisper = false);
void PlayDistanceSound(uint32 sound_id, Player* target = nullptr);
void PlayDirectSound(uint32 sound_id, Player* target = nullptr);
void PlayDirectMusic(uint32 music_id, Player* target = nullptr);
@@ -971,7 +962,6 @@ public:
FlaggedValuesArray32<int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES> m_serverSideVisibilityDetect;
// Low Level Packets
void SendPlaySound(uint32 Sound, bool OnlySelf);
void SendPlayMusic(uint32 Music, bool OnlySelf);
virtual void SetMap(Map* map);

View File

@@ -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()

View File

@@ -1159,10 +1159,18 @@ public:
void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
[[nodiscard]] uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
void Say(std::string const& text, const uint32 language);
void Yell(std::string const& text, const uint32 language);
void TextEmote(std::string const& text);
void Whisper(std::string const& text, const uint32 language, ObjectGuid receiver);
/// Handles said message in regular chat based on declared language and in config pre-defined Range.
void Say(std::string_view text, Language language, WorldObject const* = nullptr) override;
void Say(uint32 textId, WorldObject const* target = nullptr) override;
/// Handles yelled message in regular chat based on declared language and in config pre-defined Range.
void Yell(std::string_view text, Language language, WorldObject const* = nullptr) override;
void Yell(uint32 textId, WorldObject const* target = nullptr) override;
/// Outputs an universal text which is supposed to be an action.
void TextEmote(std::string_view text, WorldObject const* = nullptr, bool = false) override;
void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false) override;
/// Handles whispers from Addons and players based on sender, receiver's guid and language.
void Whisper(std::string_view text, Language language, Player* receiver, bool = false) override;
void Whisper(uint32 textId, Player* target, bool isBossWhisper = false) override;
/*********************************************************/
/*** STORAGE SYSTEM ***/

View File

@@ -21,6 +21,8 @@
#include "BattlefieldMgr.h"
#include "Battleground.h"
#include "CellImpl.h"
#include "Chat.h"
#include "ChatTextBuilder.h"
#include "Common.h"
#include "ConditionMgr.h"
#include "Creature.h"
@@ -8788,7 +8790,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
if (triggerEntry == nullptr)
{
// Don't cast unknown spell
// LOG_ERROR("entities.unit", "Unit::HandleProcTriggerSpell: Spell %u has 0 in EffectTriggered[%d]. Unhandled custom case?", auraSpellInfo->Id, triggeredByAura->GetEffIndex());
LOG_ERROR("entities.unit", "Unit::HandleProcTriggerSpell: Spell %u (effIndex: %u) has unknown TriggerSpell %u. Unhandled custom case?", auraSpellInfo->Id, triggeredByAura->GetEffIndex(), trigger_spell_id);
return false;
}
@@ -20083,3 +20085,88 @@ float Unit::GetCollisionHeight() const
return collisionHeight == 0.0f ? defaultHeight : collisionHeight;
}
void Unit::Talk(std::string_view text, ChatMsg msgType, Language language, float textRange, WorldObject const* target)
{
Acore::CustomChatTextBuilder builder(this, msgType, text, language, target);
Acore::LocalizedPacketDo<Acore::CustomChatTextBuilder> localizer(builder);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::CustomChatTextBuilder> > worker(this, textRange, localizer);
Cell::VisitWorldObjects(this, worker, textRange);
}
void Unit::Say(std::string_view text, Language language, WorldObject const* target /*= nullptr*/)
{
Talk(text, CHAT_MSG_MONSTER_SAY, language, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), target);
}
void Unit::Yell(std::string_view text, Language language, WorldObject const* target /*= nullptr*/)
{
Talk(text, CHAT_MSG_MONSTER_YELL, language, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), target);
}
void Unit::TextEmote(std::string_view text, WorldObject const* target /*= nullptr*/, bool isBossEmote /*= false*/)
{
Talk(text, isBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, LANG_UNIVERSAL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
}
void Unit::Whisper(std::string_view text, Language language, Player* target, bool isBossWhisper /*= false*/)
{
if (!target)
{
return;
}
LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
WorldPacket data;
ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, language, this, target, text, 0, "", locale);
target->SendDirectMessage(&data);
}
void Unit::Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target)
{
if (!sObjectMgr->GetBroadcastText(textId))
{
LOG_ERROR("entities.unit", "Unit::Talk: `broadcast_text` (ID: %u) was not found", textId);
return;
}
Acore::BroadcastTextBuilder builder(this, msgType, textId, getGender(), target);
Acore::LocalizedPacketDo<Acore::BroadcastTextBuilder> localizer(builder);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::BroadcastTextBuilder> > worker(this, textRange, localizer);
Cell::VisitWorldObjects(this, worker, textRange);
}
void Unit::Say(uint32 textId, WorldObject const* target /*= nullptr*/)
{
Talk(textId, CHAT_MSG_MONSTER_SAY, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), target);
}
void Unit::Yell(uint32 textId, WorldObject const* target /*= nullptr*/)
{
Talk(textId, CHAT_MSG_MONSTER_YELL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), target);
}
void Unit::TextEmote(uint32 textId, WorldObject const* target /*= nullptr*/, bool isBossEmote /*= false*/)
{
Talk(textId, isBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
}
void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/)
{
if (!target)
{
return;
}
BroadcastText const* bct = sObjectMgr->GetBroadcastText(textId);
if (!bct)
{
LOG_ERROR("entities.unit", "Unit::Whisper: `broadcast_text` was not %u found", textId);
return;
}
LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
WorldPacket data;
ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale);
target->SendDirectMessage(&data);
}

View File

@@ -2502,6 +2502,17 @@ public:
// Movement info
Movement::MoveSpline* movespline;
virtual void Talk(std::string_view text, ChatMsg msgType, Language language, float textRange, WorldObject const* target);
virtual void Say(std::string_view text, Language language, WorldObject const* target = nullptr);
virtual void Yell(std::string_view text, Language language, WorldObject const* target = nullptr);
virtual void TextEmote(std::string_view text, WorldObject const* target = nullptr, bool isBossEmote = false);
virtual void Whisper(std::string_view text, Language language, Player* target, bool isBossWhisper = false);
virtual void Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target);
virtual void Say(uint32 textId, WorldObject const* target = nullptr);
virtual void Yell(uint32 textId, WorldObject const* target = nullptr);
virtual void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false);
virtual void Whisper(uint32 textId, Player* target, bool isBossWhisper = false);
[[nodiscard]] float GetCollisionHeight() const override;
[[nodiscard]] float GetCollisionWidth() const override;
[[nodiscard]] float GetCollisionRadius() const override;