proc/Wander()
while(src)
if(P in oview(5)) //if a Player comes in 5 steps pf him
step_towards(src,P) //Chase him!
for(P in oview(1)) //here you can define some stuff
break //if you want your NPC to shoot make it so
for(P in oview(2)) //these are saying if the Player is within 1,2,3,4 blocks do nothing
break
for(P in oview(3))
break
for(P in oview(4))
break
else
step_rand(src) //if no NPC is 5 blocks or less away walk around
sleep(10) //stop for 1 second
for(P in oview(5)) //.......
break
sleep(5)
spawn(5)
Wander()//Wonder again...
Bump(mob/M)
if(M.player == 1) //If the NPC bumps you
Fight(M)//Fight You!
else
return
proc/Fight(mob/M)
var/damage = rand(1,10)
M.Health -= damage
M << "[src] attacks you for [damage] damage!!"//This tells "M" they have been attacked
src<<"You attack [M] for [damage] damage!!" //This tells you that you atttack M for how many damage
Dcheck(M) // Run Death Check
Problem description:k for some reason my monsters are runing from me what am i doing wrong here
That is untested, but should work to some extent. The monster should attack the nearest player in view, focusing on his first target if there are a few 'closest' players, and walks randomly otherwise. It will step towards its target if it is out of range. Of course, monsters can be made far more intelligent. Focus on the fighters/mages/archers, decide based on level, etc.