Im back leveling with this bot and since I've been having problems with the nav mesh crashing I dont wanna get banned standing still forever... So I made some functions for detection this...
Add these functions and run: StopIfStuck(); on every iteration.
function SavePos()
local x, y, z = GetUnitsPosition(GetLocalPlayer());
SetVar('myX', x);
SetVar('myY', y);
SetVar('myZ', z);
SetVar('myTime', GetTimeX());
end
function GetSavedX() if (GetVar('myX') ~= 0) then return GetVar('myX'); else return 0; end end
function GetSavedY() if (GetVar('myY') ~= 0) then return GetVar('myY'); else return 0; end end
function GetSavedZ() if (GetVar('myZ') ~= 0) then return GetVar('myZ'); else return 0; end end
function GetSavedTime() if (GetVar('myTime') ~= 0) then return GetVar('myTime'); else return 0; end end
function GetDistanceDif()
local x, y, z = GetUnitsPosition(GetLocalPlayer());
local xV = GetSavedX()-x;
local yV = GetSavedY()-y;
local zV = GetSavedZ()-z;
return math.sqrt(xV^2 + yV^2 + zV^2);
end
function StopIfStuck()
-- Draw functions
DrawText('Stuck feature:', 250, 240, 255, 255, 0);
DrawText('Current distance to last saved coordinates: ' .. math.floor(GetDistanceDif()) .. ' yards...', 250, 250, 255, 255, 255);
DrawText('Logging out in' .. ' ' .. math.floor(30-((GetTimeX()-GetSavedTime())/1000)) .. ' s if we do not move or save a new position...', 250, 260, 255, 255, 255);
DrawText('New position is saved if we move more than 20 yards or when we are in combat or eating...', 250, 270, 255, 255, 255);
-- Save our pos if we moved more then 20 yards or if we are in combat or eating
if (GetDistanceDif() > 20 or IsInCombat() == 1 or IsEating() == 1) then
SavePos();
return;
end
-- Check if we are stuck/standing still (moved less than 20 yards) since 30 sec since last saved position
if (GetDistanceDif() < 20 and ((GetTimeX()-GetSavedTime())/1000) > 30) then
if (logOutIfStuck) then Logout(); end
StopBot();
return;
end
end
Add these functions and run: StopIfStuck(); on every iteration.
function SavePos()
local x, y, z = GetUnitsPosition(GetLocalPlayer());
SetVar('myX', x);
SetVar('myY', y);
SetVar('myZ', z);
SetVar('myTime', GetTimeX());
end
function GetSavedX() if (GetVar('myX') ~= 0) then return GetVar('myX'); else return 0; end end
function GetSavedY() if (GetVar('myY') ~= 0) then return GetVar('myY'); else return 0; end end
function GetSavedZ() if (GetVar('myZ') ~= 0) then return GetVar('myZ'); else return 0; end end
function GetSavedTime() if (GetVar('myTime') ~= 0) then return GetVar('myTime'); else return 0; end end
function GetDistanceDif()
local x, y, z = GetUnitsPosition(GetLocalPlayer());
local xV = GetSavedX()-x;
local yV = GetSavedY()-y;
local zV = GetSavedZ()-z;
return math.sqrt(xV^2 + yV^2 + zV^2);
end
function StopIfStuck()
-- Draw functions
DrawText('Stuck feature:', 250, 240, 255, 255, 0);
DrawText('Current distance to last saved coordinates: ' .. math.floor(GetDistanceDif()) .. ' yards...', 250, 250, 255, 255, 255);
DrawText('Logging out in' .. ' ' .. math.floor(30-((GetTimeX()-GetSavedTime())/1000)) .. ' s if we do not move or save a new position...', 250, 260, 255, 255, 255);
DrawText('New position is saved if we move more than 20 yards or when we are in combat or eating...', 250, 270, 255, 255, 255);
-- Save our pos if we moved more then 20 yards or if we are in combat or eating
if (GetDistanceDif() > 20 or IsInCombat() == 1 or IsEating() == 1) then
SavePos();
return;
end
-- Check if we are stuck/standing still (moved less than 20 yards) since 30 sec since last saved position
if (GetDistanceDif() < 20 and ((GetTimeX()-GetSavedTime())/1000) > 30) then
if (logOutIfStuck) then Logout(); end
StopBot();
return;
end
end