|
Post by moinphyst on Aug 16, 2020 4:00:27 GMT
This function was tested and working as of build 1.0.0.33. It will assist you in moving great distances as long as there are not large objects or terrain to work around. If you're in the wide open, you can cover a VERY long distance. This can be used instead of Move() or MoveEx() in any case that you have the xyz coords rather than using an ID.
function runStraight(x2,y2,z2)
local x1 = tonumber(CHARPOSX)
local y1 = tonumber(CHARPOSY)
local z1 = tonumber(CHARPOSZ)
local xDif = x2 - x1
local yDif = y2 - y1
local zDif = z2 - z1
local distance = ((xDif^2 + zDif^2)^.5)
local n = math.ceil(distance / 40)
for i=1,n do
local count = 0
repeat
count = count + 1
Move((x1 + ((xDif / n) * i)),y2,(z1 + ((zDif / n) * i)))
sleep(250)
until
((((math.abs(tonumber(CHARPOSX)) - math.abs((x1 + ((xDif / n) * i)))) < 2)
and (math.abs((math.abs(tonumber(CHARPOSZ)) - math.abs((z1 + ((zDif / n) * i)))))) < 2)
or count == 100)
end
end
|
|
|
Post by crowface28 on Aug 26, 2020 17:16:38 GMT
Update for EasyLOU 1.1+
function runStraight(x2,y2,z2)
local x1 = CHARPOSX
local y1 = CHARPOSY
local z1 = CHARPOSZ
local xDif = x2 - x1
local yDif = y2 - y1
local zDif = z2 - z1
local distance = ((xDif^2 + zDif^2)^.5)
local n = math.ceil(distance / 40)
for i=1,n do
local count = 0
repeat
count = count + 1
Move((x1 + ((xDif / n) * i)),y2,(z1 + ((zDif / n) * i)))
sleep(250)
until
((((math.abs(CHARPOSX) - math.abs((x1 + ((xDif / n) * i)))) < 2)
and (math.abs((math.abs(CHARPOSZ) - math.abs((z1 + ((zDif / n) * i)))))) < 2)
or count == 100)
end
end
|
|