Entã galera, fiz a função selfMovement, tipo assim, vc define o qto o npc pode andar afastando da coordenada x original e tbm da coordenada y e ele não saí da area! \o\
Coloquem no npcs\lib\npc.lua
function selfMovement(maxx,maxy,x,y)cx, cy, cz = selfGetPosition()
randmove = math.random(1,6)
if (randmove < 5) then
if randmove == 1 then
nx = cx + 1
end
if randmove == 2 then
nx = cx - 1
end
if randmove == 3 then
ny = cy + 1
end
if randmove == 4 then
ny = cy - 1
end
else
nx = cx
ny = cy
end
if (maxx > 0) and (maxy > 0) then
if (nx > (x + maxx)) or (nx < (x - maxx)) then
nx = x
end
if (ny > (y + maxy)) or (ny < (y - maxy)) then
ny = y
end
end
moveToPosition(nx, ny, cz)
end
E aih, é só colocar isso no npc q vc quer q ande:
if focus == 0 thenfunction selfMovement(maxx,maxy,x,y)
end
Ps.: Coloca dentro da função OnThink dele...
maxx = O quanto ele pode se afastar no eixo x, tanto pra esquerda como pra direita...
maxy = O quanto ele pode se afastar no eixo y, tanto pra cima como pra baixo...
x = A coordenada X original dele, onde ele é carregado...
y = A coordenada Y original dele, onde ele é carregado...
Caso queira que seu npc ande livremente, e só colocar:
if focus == 0 thenfunction selfMovement(,,x,y)
end
E pronto \o/