ID:179117
 
Unfortunately, my mobs aren't supposed to attack each other, only PCs. My code worked well for one mob, but when I added more, they swarmed together and died at an incredible rate. Here is part of my code:

mob
NPC
mnstr
New(/mob/NPC/mnstr)
icon = 'mnstr.dmi'
spawn()
for()
var/mob/PC/M
for(M as mob in oview(5))
walk_to(src,M,0,5)
sleep(15)
for(M as mob in oview(1))
M.HP = attack([different parameters])
walk_rand(src,5)
sleep(10)

I think the problem is with the var/mob/PC/M line, but shouldn't this keep the mobs from attacking each other?
I think the problem is that your using "as mob" in combination with a specific mob type. From what I'm told using "as mob" means it will include all mobs and treat them as the type you specify.

In this instance it would grab ALL mobs and assume they are PC's.

Try this:

for(var/mob/PC/M in oview(5))


As a last resort you can do this:
for(var/mob/PC/M in oview(5))
if(istype(M,/mob/PC)) continue //this will skip to the next mob

Also, I'm not sure you want that second loop in there with the oview(1). That will cause it to attack every mob arround it for every mob it moves to. Meaning, if they are all grouped together it will attack each mob several times.
Gakumerasara wrote:
Unfortunately, my mobs aren't supposed to attack each other, only PCs. My code worked well for one mob, but when I added more, they swarmed together and died at an incredible rate.

Makes for an intersting LIFE type game I bet! ;)

LJR

Only the strongest survive!