mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-15 04:32:35 -04:00
Core/CreatureTextMgr: Added support for creature_text localization
This commit is contained in:
@@ -34,6 +34,46 @@
|
||||
#include "Vehicle.h"
|
||||
#include "ScriptedGossip.h"
|
||||
|
||||
class TrinityStringTextBuilder
|
||||
{
|
||||
public:
|
||||
TrinityStringTextBuilder(WorldObject* obj, ChatMsg msgtype, int32 id, uint32 language, uint64 targetGUID)
|
||||
: _source(obj), _msgType(msgtype), _textId(id), _language(language), _targetGUID(targetGUID)
|
||||
{
|
||||
}
|
||||
|
||||
size_t operator()(WorldPacket* data, LocaleConstant locale) const
|
||||
{
|
||||
std::string text = sObjectMgr->GetTrinityString(_textId, locale);
|
||||
char const* localizedName = _source->GetNameForLocaleIdx(locale);
|
||||
|
||||
*data << uint8(_msgType);
|
||||
*data << uint32(_language);
|
||||
*data << uint64(_source->GetGUID());
|
||||
*data << uint32(1); // 2.1.0
|
||||
*data << uint32(strlen(localizedName)+1);
|
||||
*data << localizedName;
|
||||
size_t whisperGUIDpos = data->wpos();
|
||||
*data << uint64(_targetGUID); // Unit Target
|
||||
if (_targetGUID && !IS_PLAYER_GUID(_targetGUID))
|
||||
{
|
||||
*data << uint32(1); // target name length
|
||||
*data << uint8(0); // target name
|
||||
}
|
||||
*data << uint32(text.length() + 1);
|
||||
*data << text;
|
||||
*data << uint8(0); // ChatTag
|
||||
|
||||
return whisperGUIDpos;
|
||||
}
|
||||
|
||||
WorldObject* _source;
|
||||
ChatMsg _msgType;
|
||||
int32 _textId;
|
||||
uint32 _language;
|
||||
uint64 _targetGUID;
|
||||
};
|
||||
|
||||
SmartScript::SmartScript()
|
||||
{
|
||||
go = NULL;
|
||||
@@ -695,7 +735,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
|
||||
me->DoFleeToGetAssistance();
|
||||
if (e.action.flee.withEmote)
|
||||
sCreatureTextMgr->SendChatString(me, sObjectMgr->GetTrinityStringForDBCLocale(LANG_FLEE), CHAT_MSG_MONSTER_EMOTE);
|
||||
{
|
||||
TrinityStringTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, LANG_FLEE, LANG_UNIVERSAL, 0);
|
||||
sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
|
||||
}
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature %u DoFleeToGetAssistance", me->GetGUIDLow());
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user