if(npc in orange(x,npc.spawn_loc))
//continue with AI
else return_to_spawn()
Unfortunately, that doesn't work. I think the issue lies with how I am setting NPCs' spawn_loc variable.
mob/npc/New()
..()
//I tried...
for(var/turf/t in orange(0,src))
src.spawn_loc = t
break
//also
src.spawn_loc = locate() in src.loc
That should help. I also suggest having all NPC AI be relative to the client. By this I mean use a loop like Stat() to check for any of your NPCs in the area and having that make them move randomly or aggro. There's no sense having NPC interaction in NPCs that aren't noticed by clients.