ok, so Im using a function to see how far away I am from my enemies, then if they are so far away they follow me then attack,well, everything works fine until I walk away from them, they stop following me but there animations still walk and dont idle. So I need to figure out a way to check if I am far enough away for the animation to change back.Here is my code, any help is appreciated
for nights=5 to 20
if nightanim=1 then loop object nights,1,59
if nightanim=2 then loop object nights,67,97
if stall=0 then nightanim=1
dist# = ObjDistToObj(2, nights)
if dist# < (300 * 300)
point object nights,object position x(2), object position y(2), object position z(2)
move object nights,0.5
nightanim=2
stall=1
endif
function ObjDistToObj(Obj1 as word, Obj2 as word)
dx# = object position x(Obj1) - object position x(Obj2)
dy# = object position y(Obj1) - object position y(Obj2)
dz# = object position z(Obj1) - object position z(Obj2)
dx# = dx# * dx#: dy# = dy# * dy#: dz# = dz# * dz#
Dist# = dx# + dy# + dz#
endfunction Dist#
my signature keeps being erased by a mod So this is my new signature.