heres my enemy code
var/mob/PC
mob
NPC
Brolly
name = "{NPC} Brolly"
icon = 'Enemy.dmi'
density = 1
Health=25
Defence=1
Strength=2
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src)
var/Found = FALSE
for(var/mob/PC in oview(6)).
step_away(src,PC)
Found = TRUE
break
if(Found != TRUE)
sleep(8)
sleep(8)
If you want your NPCs to attack you when they are a certain number of tiles away from you, you can use the get_dist() proc.
Also, your Wander() proc isn't usr safe because oview() has usr set as it's default Center argument.
For more information, read the reference on these procs.
Here is an example too: