diff options
-rw-r--r-- | src/server/game/AI/CoreAI/PetAI.cpp | 30 | ||||
-rw-r--r-- | src/server/game/AI/CoreAI/PetAI.h | 3 |
2 files changed, 23 insertions, 10 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index e92db6063f4..006fad0acf3 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -447,7 +447,10 @@ void PetAI::HandleReturnMovement() me->GetCharmInfo()->GetStayPosition(x, y, z); ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsReturning(true); - me->GetMotionMaster()->Clear(); + + if (me->HasUnitState(UNIT_STATE_CHASE)) + me->GetMotionMaster()->Remove(CHASE_MOTION_TYPE); + me->GetMotionMaster()->MovePoint(me->GetGUID().GetCounter(), x, y, z); } } @@ -457,7 +460,10 @@ void PetAI::HandleReturnMovement() { ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsReturning(true); - me->GetMotionMaster()->Clear(); + + if (me->HasUnitState(UNIT_STATE_CHASE)) + me->GetMotionMaster()->Remove(CHASE_MOTION_TYPE); + me->GetMotionMaster()->MoveFollow(me->GetCharmerOrOwner(), PET_FOLLOW_DIST, me->GetFollowAngle()); } } @@ -481,29 +487,35 @@ void PetAI::DoAttack(Unit* target, bool chase) bool oldCmdAttack = me->GetCharmInfo()->IsCommandAttack(); // This needs to be reset after other flags are cleared ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsCommandAttack(oldCmdAttack); // For passive pets commanded to attack so they will use spells - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveChase(target, me->GetPetChaseDistance(), (float)M_PI); + + if (me->HasUnitState(UNIT_STATE_FOLLOW)) + me->GetMotionMaster()->Remove(FOLLOW_MOTION_TYPE); + + me->GetMotionMaster()->MoveChase(target, me->GetPetChaseDistance(), float(M_PI)); } else // (Stay && ((Aggressive || Defensive) && In Melee Range))) { ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsAtStay(true); - me->GetMotionMaster()->Clear(); + + if (me->HasUnitState(UNIT_STATE_FOLLOW)) + me->GetMotionMaster()->Remove(FOLLOW_MOTION_TYPE); + me->GetMotionMaster()->MoveIdle(); } } } -void PetAI::MovementInform(uint32 moveType, uint32 data) +void PetAI::MovementInform(uint32 type, uint32 id) { // Receives notification when pet reaches stay or follow owner - switch (moveType) + switch (type) { case POINT_MOTION_TYPE: { // Pet is returning to where stay was clicked. data should be // pet's GUIDLow since we set that as the waypoint ID - if (data == me->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning()) + if (id == me->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning()) { ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsAtStay(true); @@ -516,7 +528,7 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) { // If data is owner's GUIDLow then we've reached follow point, // otherwise we're probably chasing a creature - if (me->GetCharmerOrOwner() && me->GetCharmInfo() && data == me->GetCharmerOrOwner()->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning()) + if (me->GetCharmerOrOwner() && me->GetCharmInfo() && id == me->GetCharmerOrOwner()->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning()) { ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsFollowing(true); diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h index 5df11ad8282..4ce30b1f93f 100644 --- a/src/server/game/AI/CoreAI/PetAI.h +++ b/src/server/game/AI/CoreAI/PetAI.h @@ -39,7 +39,7 @@ class TC_GAME_API PetAI : public CreatureAI void AttackStart(Unit* target) override; // always start attacking if possible void _AttackStart(Unit* target); - void MovementInform(uint32 moveType, uint32 data) override; + void MovementInform(uint32 type, uint32 id) override; void OwnerAttackedBy(Unit* attacker) override; void OwnerAttacked(Unit* target) override; void DamageTaken(Unit* attacker, uint32& /*damage*/) override { AttackStart(attacker); } @@ -67,4 +67,5 @@ class TC_GAME_API PetAI : public CreatureAI GuidSet _allySet; uint32 _updateAlliesTimer; }; + #endif |