Problem solved. Please close this thread.
Thanks.
Ok I modified the auto grind to make it auto loot in example.atmt. I almost have it but a few problem:
When i @startlooting, it moves to the item but don't collect and i need to @stoplooting then @startlooting to where the item is to make it collect.
Could someone please help me?
In OnTick Event:
Code:
if ( LastTarget == nil ) then
local Best = { Drop = nil, Distance = nil }
local Drops = GetDrops ()
for k, Drop in pairs (Drops) do
local DPos = Drop:Get ( "Position" )
if ( not IsPlayer ( Drop ) )then
local Dist = Distance ( PPos, DPos )
if ( Best.Distance == nil ) or ( Best.Distance > Dist ) then
Best.Distance = Dist
Best.Drop = Drop
end
end
end
if ( Best.Drop ~= nil ) then
LastTarget = Best.Drop
LogF ( "Got %s!", LastTarget:Get ( "Type" ) )
local Position = LastTarget:Get ( "Position" )
Move ( Position.x, Position.y, Position. z )
if(gdist == 0) or (Distance ( PPos, Position ) < gdistance) then
Collect ( LastTarget )
end
else
if ( LastTarget:Get ( "Destroyed" ) ) then
LastTarget = nil
LastCycle = LastCycle + DeltaTime
if ( LastCycle > CycleInterval ) then
local Position = LastTarget:Get ( "Position" )
Move ( Position.x, Position.y, Position.z )
if(gdist == 0) or (Distance ( PPos, Position ) < gdistance) then
Collect ( LastTarget )
end
LastCycle = 0
end
end
end
end
end