ID:164045
 
the monsters move randomely but they dont chase or attack.



mob
monster

goblin
HP = 50
icon= 'goblin.dmi'
dragon
HP = 150
icon = 'dragon.dmi'
elf
HP = 10
icon= 'elf.dmi'
zombie
HP = 40
icon= 'zombie.dmi'

mob
New()//when a mob is created
sleep(20)
if(isnull(src.client))//if it's not human
ai_random_wander()//wander
return..()//continue on with normal New() (create and whatnot)
else
return..()

mob
proc//core procs for the system

ai_random_wander()//random wander if no mobs are in range to attack
if(src.key)//if the source is human
return//don't call the rest
else
walk_rand(src,10)//walk randomly with 10 lag
spawn(10)//delay for one tick
ai_random_wander()//wander some more

ai_run_away()//used for checking to see if it should run or attack
if(src.client)
return
else
for(var/mob/M in oview(5,src))//loops over all mobs within 5 tiles of the monster
if(M.client)//if the mob is human

src.ai_walk_to()//calls the walk_to (for attacking) proc
else
continue//if it's a monster keep looping

ai_walk_to()
if(src.client)
return 0
else
for(var/mob/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5)//within 5 tiles
walk_to(src,M,1,5)//walk to the player
ai_check_dist(src,M)//checks distance
break//stops the loop
else
continue
else
continue

ai_check_dist(mob/attacker,mob/defender)
if(attacker.client)
return
else
if(get_dist(attacker,defender) <= 1)//if the monster is one tile away from the player
attacker.attackm(defender)//attack!
else
return

attackm(mob/defender)
var/damago = rand(1,10)//sets the damage variable to a random number between 1 and 10
defender << "You take [damago] damage!"
src << "You attack for [damago] damage!"
if(!src.client) //if it's not human
sleep(10)
src.ai_random_wander()//wander
Your not checking for players to attack in your ai_random_wander() proc.
Rat
icon = 'NPCs.dmi'
icon_state = "Rat"
var/mob/Health=10
var/mob/Defense=0
var/mob/User/player/P
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src)
var/Found = FALSE
for(P in oview(5,src))
step_towards(src,P)
Found = TRUE
break
if(Found != TRUE)
step_rand(src)
sleep(10)
sleep(5)
Bump(mob/M)
if(istype(M,/mob/User/player))
Attack(M)
proc/Attack(mob/M)
flick("attack",src)
sleep(2)
var/damage = rand(1,2)-usr:Defensebonus
M:Health -= damage
M << "You have been attacked by [src] for [damage]!"
M.death_check()

To get this to work you will need a deathcheck proc, other than that it works well for me. I think this is what you are looking for...
In response to Zythyr
how do make it check my ai_random_wander() proc.
I mean which proc should i make to check it.