258{
259 if (!source)
260 return 0;
261
264 {
265 LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Could not find Text for Creature({}) Entry {} in 'creature_text' table. Ignoring.", source->
GetName(), source->
GetEntry());
266 return 0;
267 }
268
270 CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
271 if (itr == textHolder.end())
272 {
273 LOG_ERROR(
"sql.sql",
"CreatureTextMgr: Could not find TextGroup {} for Creature {} ({}). Ignoring.",
275 return 0;
276 }
277
279
280
282 if (options)
283 {
284 if (options->
playerOnly && (!target || !target->IsPlayer()))
285 return 0;
286
288 return 0;
289
291 return 0;
292 }
293
296
297 for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter)
298 if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end())
299 tempGroup.push_back(*giter);
300
301 if (tempGroup.empty())
302 {
304 tempGroup = textGroupContainer;
305 }
306
308 {
310 });
311
314 uint32 finalSound = sound ? sound : iter->sound;
315
317 range = iter->TextRange;
318
319 if (finalSound)
320 SendSound(source, finalSound, finalType, target, range, teamId, gmOnly);
321
322 Unit* finalSource = source;
323 if (srcPlr)
324 finalSource = srcPlr;
325
326 if (iter->emote)
328
329 if (srcPlr)
330 {
331 PlayerTextBuilder builder(source, finalSource, finalSource->
getGender(), finalType, iter->group, iter->id, finalLang, target);
332 SendChatPacket(finalSource, builder, finalType, target, range, teamId, gmOnly);
333 }
334 else
335 {
337 SendChatPacket(finalSource, builder, finalType, target, range, teamId, gmOnly);
338 }
339
341
342
343 if (options && options->
cooldown > 0)
345
346 return iter->duration;
347}
std::vector< CreatureTextEntry > CreatureTextGroup
Definition CreatureTextMgr.h:81
std::unordered_map< uint8, CreatureTextGroup > CreatureTextHolder
Definition CreatureTextMgr.h:82
std::vector< uint8 > CreatureTextRepeatIds
Definition Creature.h:43
bool roll_chance_i(int chance)
Definition Random.h:63
@ CHAT_MSG_ADDON
Definition SharedDefines.h:3384
@ LANG_ADDON
Definition SharedDefines.h:741
Definition CreatureTextMgr.cpp:31
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:184
void SendEmote(Unit *source, uint32 emote)
Definition CreatureTextMgr.cpp:444
void SendSound(Creature *source, uint32 sound, ChatMsg msgType, WorldObject const *target, CreatureTextRange range, TeamId teamId, bool gmOnly)
Definition CreatureTextMgr.cpp:368
CreatureTextOptions const * GetTextOptions(uint32 entry, uint8 group) const
Definition CreatureTextMgr.cpp:244
void SetTextRepeatId(uint8 textGroup, uint8 id)
Definition Creature.cpp:3799
void ClearTextRepeatGroup(uint8 textGroup)
Definition Creature.cpp:3819
void SetTextCooldown(uint8 textGroup, uint32 cooldownMs)
Definition Creature.cpp:3835
bool IsTextOnCooldown(uint8 textGroup) const
Definition Creature.cpp:3826
CreatureTextRepeatIds const & GetTextRepeatGroup(uint8 textGroup)
Definition Creature.cpp:3808
std::string ToString() const
Definition ObjectGuid.cpp:48
uint32 GetEntry() const
Definition Object.h:117
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
Definition CreatureTextMgr.cpp:54
uint8 getGender() const
Definition Unit.h:849
std::string const & GetName() const
Definition Object.h:529
auto SelectRandomWeightedContainerElement(C const &container, std::vector< double > weights) -> decltype(std::begin(container))
Definition Containers.h:175
bool playerOnly
Definition CreatureTextMgr.h:78
uint8 triggerChance
Definition CreatureTextMgr.h:77