ID:141264
 
Code:
        var/turf/home
New()
. = ..()
home = loc
spawn Life()
proc/Life()
while(1)
var/mob/M
for(M in oview(5, src)) break
while(M)
if(M.team=="Alliance")
if( M in oview(1,src) )
step_towards(src,M)
else
step_to(src,M)
break
sleep(10)

if(home in oview(6, src))
step_towards(src, home)
sleep(25)



this is an npc that is soppost to follow mobs with the team= "Alliance" and then when that mob gets out of range, this npc goes back to its home. but then this npc just stays in 1 spot and when a mob comes closer to it, it attacks but doesn't follow

----
This is how it is when it follows every mob.
var/turf/home
New()
. = ..()
home = loc
spawn Life()
proc/Life()
while(1)
var/mob/M
for(M in oview(5, src)) break
while(M)
if(M in oview(1, src))
step_towards(src, M)
else if(M in oview(5, src))
step_to(src, M)
else
M = null
break
sleep(10)

if(home in oview(6, src))
step_towards(src, home)
sleep(25)

Heh, I so saw this coming. Learn your lesson here; don't just copy code without understanding it. As you can see it just won't work very well. It's also poor usage of the help you've been given.
Please read the code I wrote before actually using it. The key to receiving help is to learn from it, not to copy it over and hope it works.