ID:178965
 
How would I make it so that enemies only attack players not each other?
you just do.
Here's a code that might help although it gives runtime errors -_-

mob
NPC
bat
name = "Bat"
icon = 'bat.dmi'
HP = 20
MaxHp = 20
Str = 8
Exp = 16
Enterif = 0
var/mob/PC/P
New()
.=..()
spawn(1)
Wander()
proc/Wander()
while(src)
if (P in oview(5))
step_towards(src,P)
else
step_rand(src)
for(P in view(src))
break
sleep(5)
spawn(40)
Wander()
Bump(mob/M)
if (M.key)
Attack(M)
Attack(M)
flick("attack",src)
sleep(2)
var/damage = rand(1,Str)
M.HP -= damage
M.Die()
Here's an example:
mob/NPC
icon = 'icons.dmi'
icon_state = "npc"
Click()//When clicked
usr.attack(src)//attack!
proc/move()
for(var/mob/M in oview())//mobs in view
if(get_step_away(src,M,3))
if(!M.client)//Not a player
continue
else
step_to(src,M,1)
else continue
spawn(10) move()

var/tmp
next_move_time = 0
movement_delay = 10


Move() if (world.time >= next_move_time)
next_move_time = world.time + 10

return ..()
else
// Not allowed to move yet.
return 0

proc/attackplayer()//Handles attacking
for(var/mob/M in oview(1))
if(get_step_away(src,M,1))
if(!M.client)
continue
else
src.attack(M)//Calls the attack proc
else
return..()
spawn(20) attackplayer()

New()//When created
attackplayer()//Calls the procs for it
move()

Hope I helped.

~~~~SSJ4_Gohan_Majin


In response to SSJ4_Gohan_Majin
You don't have my permission to use my code for helping people anymore. The code in your post was used in Nadrew's leveling system.