LU
dúvida

Função Docreaturefollow

Por LuckOake, 04 de out. de 2012 em Scripts

script
1
694
LuckOakeL
04 de outubro de 2012 às 22:32

Olá galera. Vou direto ao ponto dessa vez. Adaptei de um script uma função de follow, mas ela tá bugada. O monstro não segue, só muda o lookdir.

 

 

function doCreatureFollow(cid, target, playerpos, targetpos, times)

followstor = 51325

if playerdir ~= getCreatureLookDirection(cid) then

doCreatureSetLookDirection(target, getCreatureLookDirection(cid))

end

 

if playerpos ~= getCreaturePosition(cid) then

if playerpos.z == getCreaturePosition(cid).z then

ntpos = getCreaturePosition(cid)

local x,y,z = ntpos.x-playerpos.x,ntpos.y-playerpos.y,ntpos.z-playerpos.z

ntpos = getCreaturePosition(target)

ntpos.x, ntpos.y, ntpos.z = ntpos.x+x,ntpos.y+y,ntpos.z+z

if queryTileAddThing(target, ntpos) == RETURNVALUE_NOERROR and getCreaturePosition(cid).z == getCreaturePosition(target).z then

doMoveCreature(target, getCreatureLookDirection(cid))

end

end

end

local playerpos, targetpos = getCreaturePosition(cid), getCreaturePosition(target)

if getPlayerStorageValue(cid, followstor) == 1 then

addEvent(move, 1, cid, target, playerpos, targetpos, times)

else

doCreatureSetNoMove(target, 0)

end

end

 

 

Dá pra ser usada mais ou menos assim:

 

setPlayerStorageValue(cid, followstor, 1)
doCreatureFollow(cid, target, playerpos, targetpos, times)

 

Mas não sei como usar corretamente. Alguém quer dar uma luz?

Editado Outubro 4 por LuckOake