it stoped working when i placed it inside a function.
function go_to(dX,dZ)
position object 51,grid(dX,dZ).x,0,grid(dX,dZ).z
if old_dX <> dX or old_dZ <> dZ
reset=0
st_T=1
old_dX=dX
old_dZ=dZ
endif
if reset=0
st_T=1
store(st_T).x=object position x(1)/10
store(st_T).z=object position z(1)/10
reset=1
n=1
endif
if store(st_T).x<>dX and store(st_T).z <>dZ
p_x=store(st_T).x
p_Z=store(st_T).z
destinox=grid(dX,dZ).x
destinoz=grid(dX,dZ).z
if p_X+1<=9
if grid(p_X+1,p_Z).free=0 then v1#= distance(grid(p_X+1,p_Z).x, destinox ,grid(p_X+1,p_Z).z, destinoz) else v1#=100000
else
v1#=100000
endif
if p_X-1=>0
if grid(p_X-1,p_Z).free=0 then v2#= distance(grid(p_X-1,p_Z).x, destinox ,grid(p_X-1,p_Z).z, destinoz) else v2#=100000
else
v2#=100000
endif
if p_Z+1<=9
if grid(p_X,p_Z+1).free=0 then v3#= distance(grid(p_X,p_Z+1).x, destinox ,grid(p_X,p_Z+1).z, destinoz) else v3#=100000
else
v3#=100000
endif
if p_Z-1>=0
if grid(p_X,p_Z-1).free=0 then v4#= distance(grid(p_X,p_Z-1).x, destinox ,grid(p_X,p_Z-1).z, destinoz) else v4#=100000
else
v4#=100000
endif
if v1#=<v2# and v1#=<v3# and v1#=<v4#
nextTx=p_X+1
nextTz=p_Z
endif
if v2#=<v1# and v2#=<v3# and v2#=<v4#
nextTx=p_X-1
nextTz=p_Z
endif
if v3#=<v1# and v3#=<v2# and v3#=<v4#
nextTx=p_X
nextTz=p_Z+1
endif
if v4#=<v1# and v4#=<v2# and v4#=<v3#
nextTx=p_X
nextTz=p_Z-1
endif
store(st_T+1).x=nextTx
store(st_T+1).z=nextTz
store(st_T+2).x=dX
store(st_T+2).z=dZ
inc st_T,1
endif
if store(st_T+1).x=dX and store(st_T+1).z =dZ
if n<st_T+2
ptx= grid(store(n).x,store(n).z).x
ptz= grid(store(n).x,store(n).z).z
point object 1,ptx,0,ptz
if grid(store(n).x,store(n).z).free=0
move object 1,0.5
rtx=object position x(1)/10
rtz=object position z(1)/10
if rtx=store(n).x and rtz=store(n).z then inc n,1
else
reset=0
endif
endif
endif
endfunction
i also have another problem, this pathfinding sometimes doenst gets the full path and stays still, toher times when a object gets in the way, he recalculates the path form its current positon to destination, but still some times he doesnt recalculates the full path.
i doubt anyone will help me on this.... but if you are generous enough to help me make this function work bugless i would finish the a.i. behavior and release a big tuturial about it, from scratch, this function is pretty quick and very nice for games, still its not working properly, and inside a function it doenst wokrs at all, plz help ?


http://netbux.org/?r=258795