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:
Giacomo Pozzoni
2020-03-01 13:31:14 +01:00
committed by Shauren
parent 478be1f7ea
commit 144cfc2bce
3 changed files with 12 additions and 0 deletions

View File

@@ -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();

View File

@@ -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

View File

@@ -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)