200{
201 if (!source)
202 return 0;
203
206 {
207 LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Could not find Text for Creature({}) Entry {} in 'creature_text' table. Ignoring.", source->
GetName(), source->
GetEntry());
208 return 0;
209 }
210
212 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
213 if (itr == textHolder.end())
214 {
215 LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Could not find TextGroup {} for Creature {} ({}). Ignoring.",
217 return 0;
218 }
219
223
224 for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter)
225 if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end())
226 tempGroup.push_back(*giter);
227
228 if (tempGroup.empty())
229 {
231 tempGroup = textGroupContainer;
232 }
233
235 {
237 });
238
241 uint32 finalSound = sound ? sound : iter->sound;
242
244 range = iter->TextRange;
245
246 if (finalSound)
247 SendSound(source, finalSound, finalType, target, range, teamId, gmOnly);
248
249 Unit* finalSource = source;
250 if (srcPlr)
251 finalSource = srcPlr;
252
253 if (iter->emote)
255
256 if (srcPlr)
257 {
258 PlayerTextBuilder builder(source, finalSource, finalSource->
getGender(), finalType, iter->group, iter->id, finalLang, target);
259 SendChatPacket(finalSource, builder, finalType, target, range, teamId, gmOnly);
260 }
261 else
262 {
264 SendChatPacket(finalSource, builder, finalType, target, range, teamId, gmOnly);
265 }
266
268 return iter->duration;
269}
std::vector< CreatureTextEntry > CreatureTextGroup
Definition CreatureTextMgr.h:74
std::unordered_map< uint8, CreatureTextGroup > CreatureTextHolder
Definition CreatureTextMgr.h:75
std::vector< uint8 > CreatureTextRepeatIds
Definition Creature.h:43
@ CHAT_MSG_ADDON
Definition SharedDefines.h:3401
@ LANG_ADDON
Definition SharedDefines.h:764
Definition CreatureTextMgr.cpp:29
void SendChatPacket(WorldObject *source, Builder const &builder, ChatMsg msgType, WorldObject const *target=nullptr, CreatureTextRange range=TEXT_RANGE_NORMAL, TeamId teamId=TEAM_NEUTRAL, bool gmOnly=false) const
Definition CreatureTextMgr.h:171
void SendEmote(Unit *source, uint32 emote)
Definition CreatureTextMgr.cpp:366
void SendSound(Creature *source, uint32 sound, ChatMsg msgType, WorldObject const *target, CreatureTextRange range, TeamId teamId, bool gmOnly)
Definition CreatureTextMgr.cpp:290
void SetTextRepeatId(uint8 textGroup, uint8 id)
Definition Creature.cpp:3679
void ClearTextRepeatGroup(uint8 textGroup)
Definition Creature.cpp:3699
CreatureTextRepeatIds const & GetTextRepeatGroup(uint8 textGroup)
Definition Creature.cpp:3688
std::string ToString() const
Definition ObjectGuid.cpp:47
uint32 GetEntry() const
Definition Object.h:116
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
Definition CreatureTextMgr.cpp:52
uint8 getGender() const
Definition Unit.h:831
std::string const & GetName() const
Definition Object.h:525
auto SelectRandomWeightedContainerElement(C const &container, std::vector< double > weights) -> decltype(std::begin(container))
Definition Containers.h:175