Skip to content

Commit

Permalink
Fix pet follow
Browse files Browse the repository at this point in the history
Fix pet follow angle and go idle when next to owner
  • Loading branch information
Phatcat committed Jun 18, 2016
1 parent 1da6e9b commit 5dcd127
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/game/Pet.h
Expand Up @@ -129,7 +129,7 @@ typedef std::vector<uint32> AutoSpellList;
#define ACTIVE_SPELLS_MAX 4

#define PET_FOLLOW_DIST 1.0f
#define PET_FOLLOW_ANGLE (M_PI_F/2.0f)
#define PET_FOLLOW_ANGLE (M_PI_F / 4.00f) * 3.50f

class Player;

Expand Down
11 changes: 9 additions & 2 deletions src/game/PetAI.cpp
Expand Up @@ -298,9 +298,16 @@ void PetAI::UpdateAI(const uint32 diff)
}
else if (m_creature->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
{
if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW))
{
// The distance is to prevent the pet from running around to reach the owners back when walking towards it
// and the reason for increasing it more than the follow distance is to prevent the same thing
// from happening when the owner turns and twists (as this increases the distance between them)
if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW) && !owner->IsWithinDistInMap(m_creature, (PET_FOLLOW_DIST * 2)))
m_creature->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
// This is to stop the pet from following you when you're close to each other, to support the above condition.
else if (m_creature->hasUnitState(UNIT_STAT_FOLLOW))
{
m_creature->GetMotionMaster()->Clear(false);
m_creature->GetMotionMaster()->MoveIdle();
}
}
}
Expand Down

0 comments on commit 5dcd127

Please sign in to comment.