Pets should warp to owner >= 450 units Fixes #715

This commit is contained in:
Michael Cook (mackal) 2018-02-23 17:09:04 -05:00
parent ca0b9bc374
commit 959337b592

View File

@ -918,29 +918,26 @@ void Client::AI_Process()
} }
} }
if(IsPet()) if (IsPet()) {
{ Mob *owner = GetOwner();
Mob* owner = GetOwner(); if (owner == nullptr)
if(owner == nullptr)
return; return;
float dist = DistanceSquared(m_Position, owner->GetPosition()); float dist = DistanceSquared(m_Position, owner->GetPosition());
if (dist >= 400) if (dist >= 202500) { // >= 450 distance
{ Teleport(static_cast<glm::vec3>(owner->GetPosition()));
if(AI_movement_timer->Check()) SendPositionUpdate(); // this shouldn't happen a lot (and hard to make it) so lets not rate limit
{ } else if (dist >= 400) { // >=20
int nspeed = (dist >= 5625 ? GetRunspeed() : GetWalkspeed()); if (AI_movement_timer->Check()) {
int nspeed = (dist >= 5625 ? GetRunspeed() : GetWalkspeed()); // >= 75
animation = nspeed; animation = nspeed;
nspeed *= 2; nspeed *= 2;
SetCurrentSpeed(nspeed); SetCurrentSpeed(nspeed);
CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), nspeed); CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), nspeed);
} }
} } else {
else if (moved) {
{
if(moved)
{
SetCurrentSpeed(0); SetCurrentSpeed(0);
moved = false; moved = false;
} }