ID:305376
 
(See the best response by Kaiochao.)
i have it so they come towards me, but i cant figure out how to make them attack....
here is my 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_to(src,PC)
Found = TRUE
break
if(Found != TRUE)
sleep(8)
sleep(8)
Simple approach in pseudocode:
if(distance(enemy, player) == 1)
player.Health -= enemy.strength
Best response
The oview proc has an implicit usr as it's center. Simply change it to oview(6, src).