mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/AI: Make charmed creatures follow their owner (#24195)
* Core/AI: Make charmed creatures follow their owner
* Follow the charmer only when applying the charm
* Make SmartAI follow the charmer
(cherry picked from commit ddf2f60c13)
This commit is contained in:
@@ -632,6 +632,14 @@ void PetAI::UpdateAllies()
|
||||
_allySet.insert(owner->GetGUID());
|
||||
}
|
||||
|
||||
void PetAI::OnCharmed(bool isNew)
|
||||
{
|
||||
if (me->IsCharmed())
|
||||
me->GetMotionMaster()->MoveFollow(me->GetCharmer(), PET_FOLLOW_DIST, me->GetFollowAngle());
|
||||
|
||||
CreatureAI::OnCharmed(isNew);
|
||||
}
|
||||
|
||||
void PetAI::ClearCharmInfoFlags()
|
||||
{
|
||||
CharmInfo* ci = me->GetCharmInfo();
|
||||
|
||||
@@ -46,6 +46,7 @@ class TC_GAME_API PetAI : public CreatureAI
|
||||
void ReceiveEmote(Player* player, uint32 textEmote) override;
|
||||
void JustEnteredCombat(Unit* who) override { EngagementStart(who); }
|
||||
void JustExitedCombat() override { EngagementOver(); }
|
||||
void OnCharmed(bool isNew) override;
|
||||
|
||||
// The following aren't used by the PetAI but need to be defined to override
|
||||
// default CreatureAI functions which interfere with the PetAI
|
||||
|
||||
@@ -692,6 +692,9 @@ void SmartAI::OnCharmed(bool /*isNew*/)
|
||||
|
||||
_charmed = charmed;
|
||||
|
||||
if (charmed)
|
||||
me->GetMotionMaster()->MoveFollow(me->GetCharmer(), PET_FOLLOW_DIST, me->GetFollowAngle());
|
||||
|
||||
if (!charmed && !me->IsInEvadeMode())
|
||||
{
|
||||
if (_repeatWaypointPath)
|
||||
|
||||
Reference in New Issue
Block a user