mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 13:46:24 +00:00
feat(Core/AI): Implement delay option to the Talk() function (#14950)
This commit is contained in:
@@ -40,9 +40,26 @@ void CreatureAI::OnCharmed(bool /*apply*/)
|
||||
AISpellInfoType* UnitAI::AISpellInfo;
|
||||
AISpellInfoType* GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; }
|
||||
|
||||
void CreatureAI::Talk(uint8 id, WorldObject const* target /*= nullptr*/)
|
||||
/**
|
||||
* @brief Causes the creature to talk/say the text assigned to their entry in the `creature_text` database table.
|
||||
*
|
||||
* @param uint8 id Text ID from `creature_text`.
|
||||
* @param WorldObject target The target of the speech, in case it has elements such as $n, where the target's name will be referrenced.
|
||||
* @param Milliseconds delay Delay until the creature says the text line. Creatures will talk immediately by default.
|
||||
*/
|
||||
void CreatureAI::Talk(uint8 id, WorldObject const* target /*= nullptr*/, Milliseconds delay /*= 0s*/)
|
||||
{
|
||||
sCreatureTextMgr->SendChat(me, id, target);
|
||||
if (delay > Seconds::zero())
|
||||
{
|
||||
me->m_Events.AddEventAtOffset([this, id, target]()
|
||||
{
|
||||
sCreatureTextMgr->SendChat(me, id, target);
|
||||
}, delay);
|
||||
}
|
||||
else
|
||||
{
|
||||
sCreatureTextMgr->SendChat(me, id, target);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsValidCombatTarget(Creature* source, Player* target)
|
||||
|
||||
Reference in New Issue
Block a user