Merge pull request #693 from noudess/master

This patches gross pet errors in Z.
This commit is contained in:
Chris Miles 2018-01-12 03:11:34 -06:00 committed by GitHub
commit 4cd7d98224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1391,19 +1391,33 @@ void Mob::AI_Process() {
//if(owner->IsClient())
// printf("Pet start pos: (%f, %f, %f)\n", GetX(), GetY(), GetZ());
float dist = DistanceSquared(m_Position, owner->GetPosition());
if (dist >= 400)
glm::vec4 ownerPos = owner->GetPosition();
float dist = DistanceSquared(m_Position, ownerPos);
float distz = ownerPos.z - m_Position.z;
if (dist >= 400 || distz > 100)
{
int speed = GetWalkspeed();
if (dist >= 5625)
speed = GetRunspeed();
CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), speed);
if (distz > 100)
{
m_Position = ownerPos;
SendPositionUpdate();
moved = true;
}
else
{
CalculateNewPosition2(owner->GetX(),
owner->GetY(), owner->GetZ(), speed);
}
}
else
{
if(moved)
{
this->FixZ();
SetCurrentSpeed(0);
moved = false;
}