Ir para conteúdo

Função Traçar Caminho.


meubk

Posts Recomendados

Eu queria saber se alguem tem uma função ki traça um caminho, eu tenho uma mais não funciona tá bugada, se alguem conseguir faser, vow postar a que ta bugada , para baseárem.

 

function getPath(cid, fromPos, toPos)
   local path = {}

   local tocheck = {}
   local checked = {}

   local currnode = fromPos
   local finalnode = toPos

   local neighbor = currnode

   local currdist = 0
   local lastdist = 0

   local todir = 0

   while(currnode ~= finalnode) do
       for i = 0, 7 do
           neighbor = getPositionByDirection(currnode, i)
           if(doTileQueryAdd(cid, neighbor))then
               if(isInArray(checked, neighbor)then
                   --
               else
                   currdist = getDistanceBetween(currnode, finalnode)
                   if(currdist < lastdist)then
                       todir = i
                   end
                   lastdist = currdist
                   table.insert(checked, neighbor)
               end
           else
               todir = -1
           end
       end
       if(todir == -1) then
           break
       end
       table.insert(path, todir)
   end
   return path
end

function autoWalk(cid,list,n)
if list[n] ~= nil then
	n = n+1
	doMoveCreature(cid, list[n])
	addEvent(autoWalk, 1000, cid, list, n)
end
end

 

tá aew.. pode basear nela... fuii

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...