-- Farmine Depots
local depots = {{33025, 31443,11},{33027, 31443,11},{33034, 31450,11},{33034, 31452,11},{33034, 31454,11},{33034, 31456,11},
{33019, 31451,11},{33019, 31453,11},{33019, 31455,11},{33019, 31449,11},{33030, 31462,11},{33028, 31462,11}}
-- Just a simple function that says if a position is on the screen or not
function onScreen(pos)
return (math.abs(Self.Position().x - pos.x) <= 7) and (math.abs(Self.Position().y - pos.y) <= 5)
end
-- Simple function that waits until your char isn't moving anymore
function waitUntilStill()
local pos = Self.Position()
repeat
pos = Self.Position()
wait(1000,1500)
until (Self.Position().x == pos.x) and (Self.Position().y == pos.y)
end
-- Calculates how many times you have to use the ground to get somewhere
function amountOfSteps(pos)
local dx = math.ceil(math.abs(Self.Position().x - pos.x)/6)
local dy = math.ceil(math.abs(Self.Position().y - pos.y)/4)
return math.max(dx,dy)
end
-- Function that makes your char "walk" somewhere using the ground.
function walkTo(pos)
local fromPos = Self.Position()
local toPos = pos
local tries = 0
local booly = false
repeat
if not onScreen(pos) then
local steps = amountOfSteps(pos)
for i = 1, steps do
toPos = {x = fromPos.x + math.ceil((pos.x - fromPos.x)*(i/steps)),
y = fromPos.y + math.ceil((pos.y - fromPos.y)*(i/steps)), z = pos.z}
if onScreen(toPos) then
Self.UseItemWithGround(3003, toPos.x, toPos.y, toPos.z)
waitUntilStill()
end
end
if onScreen(pos) then
booly = true
else
wait(2000)
print("Depot still not on the screen. Trying for the " .. tostring(tries) .. " time.")
end
else
booly = true
Self.UseItemWithGround(3003, toPos.x, toPos.y, toPos.z)
waitUntilStill()
end
tries = tries + 1
until booly or (tries > 3)
return booly
end
-- Randomly chooses a depot to go to
function findDepot()
local tries = 3
local booly = false
local reached = false
repeat
local maxi = #depots
-- Very random

not pseudo !
math.randomseed( os.time() )
math.random(); math.random(); math.random()
local i = math.random(maxi)
print("Trying to reach depot " .. tostring(i) .. ".")
local pos = {x = depots[i][1], y = depots[i][2], z = depots[i][3]}
if walkTo(pos) and (Self.LookPos().x == pos.x) and (Self.LookPos().y == pos.y) then
if Self.OpenDepot() then
booly = true
print("Depot reached and opened!")
else
print("Depot reached but could not open it.")
end
else
print("Depot cant be reached.")
gotoLabel("Start")
end
tries = tries + 1
until booly or (tries > 3)
return booly
end