aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobmaps <spambot42@yandex.ru>2011-05-30 20:47:33 +0700
committertobmaps <spambot42@yandex.ru>2011-05-30 20:47:33 +0700
commitfd08b0060c1ef954f1fa4437b48e628e96c7626e (patch)
treeeac115762a3a17a4ba4511e06f884f898982dcf2
parentee794c5b1c042182c0647811a60a9cfac3a29662 (diff)
Core/Commands: Localized npc name for commands .npc say, .npc yell, .npc whisper
-rw-r--r--sql/updates/world/2011_05_30_01_world_creature.sql2
-rwxr-xr-xsrc/server/game/Entities/Object/Object.cpp103
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp2
3 files changed, 72 insertions, 35 deletions
diff --git a/sql/updates/world/2011_05_30_01_world_creature.sql b/sql/updates/world/2011_05_30_01_world_creature.sql
index b3a485d188e..898c7609909 100644
--- a/sql/updates/world/2011_05_30_01_world_creature.sql
+++ b/sql/updates/world/2011_05_30_01_world_creature.sql
@@ -10,4 +10,4 @@ INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`pr
-- Baltharus the Warborn Clone
UPDATE `creature_template` SET `AIName`= '',`ScriptName`= 'npc_baltarhus_the_warborn_clone' WHERE `entry`=39899;
-DELETE FROM `smart_scripts` WHERE `entryorguid`=39899; \ No newline at end of file
+DELETE FROM `smart_scripts` WHERE `entryorguid`=39899;
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 58620cd9cd5..ce937cdedfd 100755
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -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);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index e1672cc958c..b5411a661c4 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -1330,7 +1330,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
return;
// Hmmmm dont like this emotes client must by self do all animations
- if (damageInfo->HitInfo&HITINFO_CRITICALHIT)
+ if (damageInfo->HitInfo & HITINFO_CRITICALHIT)
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL);
if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS)
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD);