mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-21 23:27:14 -04:00
Core/Commands: Localized npc name for commands .npc say, .npc yell, .npc whisper
This commit is contained in:
@@ -1586,39 +1586,6 @@ bool Position::IsPositionValid() const
|
||||
return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
}
|
||||
|
||||
void WorldObject::MonsterSay(const char* text, uint32 language, uint64 TargetGuid)
|
||||
{
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||
BuildMonsterChat(&data, CHAT_MSG_MONSTER_SAY, text, language, GetName(), TargetGuid);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
|
||||
}
|
||||
|
||||
void WorldObject::MonsterYell(const char* text, uint32 language, uint64 TargetGuid)
|
||||
{
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||
BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, text, language, GetName(), TargetGuid);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), true);
|
||||
}
|
||||
|
||||
void WorldObject::MonsterTextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote)
|
||||
{
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||
BuildMonsterChat(&data, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL, GetName(), TargetGuid);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true);
|
||||
}
|
||||
|
||||
void WorldObject::MonsterWhisper(const char* text, uint64 receiver, bool IsBossWhisper)
|
||||
{
|
||||
Player *player = sObjectMgr->GetPlayer(receiver);
|
||||
if (!player || !player->GetSession())
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||
BuildMonsterChat(&data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetName(), receiver);
|
||||
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
bool WorldObject::isValid() const
|
||||
{
|
||||
if (!IsInWorld())
|
||||
@@ -1897,8 +1864,42 @@ namespace Trinity
|
||||
uint32 i_language;
|
||||
uint64 i_targetGUID;
|
||||
};
|
||||
|
||||
class MonsterCustomChatBuilder
|
||||
{
|
||||
public:
|
||||
MonsterCustomChatBuilder(WorldObject const& obj, ChatMsg msgtype, const char* text, uint32 language, uint64 targetGUID)
|
||||
: i_object(obj), i_msgtype(msgtype), i_text(text), i_language(language), i_targetGUID(targetGUID) {}
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
{
|
||||
// TODO: i_object.GetName() also must be localized?
|
||||
i_object.BuildMonsterChat(&data, i_msgtype, i_text, i_language, i_object.GetNameForLocaleIdx(loc_idx), i_targetGUID);
|
||||
}
|
||||
|
||||
private:
|
||||
WorldObject const& i_object;
|
||||
ChatMsg i_msgtype;
|
||||
const char* i_text;
|
||||
uint32 i_language;
|
||||
uint64 i_targetGUID;
|
||||
};
|
||||
} // namespace Trinity
|
||||
|
||||
void WorldObject::MonsterSay(const char* text, uint32 language, uint64 TargetGuid)
|
||||
{
|
||||
CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, text, language, TargetGuid);
|
||||
Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> say_do(say_build);
|
||||
Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do);
|
||||
TypeContainerVisitor<Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> >, WorldTypeMapContainer > message(say_worker);
|
||||
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY));
|
||||
}
|
||||
|
||||
void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid)
|
||||
{
|
||||
CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
@@ -1914,6 +1915,21 @@ void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid)
|
||||
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY));
|
||||
}
|
||||
|
||||
void WorldObject::MonsterYell(const char* text, uint32 language, uint64 TargetGuid)
|
||||
{
|
||||
CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, text, language, TargetGuid);
|
||||
Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> say_do(say_build);
|
||||
Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), say_do);
|
||||
TypeContainerVisitor<Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> >, WorldTypeMapContainer > message(say_worker);
|
||||
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL));
|
||||
}
|
||||
|
||||
void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid)
|
||||
{
|
||||
CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
@@ -1942,6 +1958,13 @@ void WorldObject::MonsterYellToZone(int32 textId, uint32 language, uint64 Target
|
||||
say_do(itr->getSource());
|
||||
}
|
||||
|
||||
void WorldObject::MonsterTextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote)
|
||||
{
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||
BuildMonsterChat(&data, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL, GetName(), TargetGuid);
|
||||
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true);
|
||||
}
|
||||
|
||||
void WorldObject::MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote)
|
||||
{
|
||||
CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
@@ -1957,6 +1980,20 @@ void WorldObject::MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossE
|
||||
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
|
||||
}
|
||||
|
||||
void WorldObject::MonsterWhisper(const char* text, uint64 receiver, bool IsBossWhisper)
|
||||
{
|
||||
Player *player = sObjectMgr->GetPlayer(receiver);
|
||||
if (!player || !player->GetSession())
|
||||
return;
|
||||
|
||||
LocaleConstant loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
|
||||
|
||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||
BuildMonsterChat(&data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetNameForLocaleIdx(loc_idx), receiver);
|
||||
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper)
|
||||
{
|
||||
Player *player = sObjectMgr->GetPlayer(receiver);
|
||||
|
||||
Reference in New Issue
Block a user