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?
ID:179117
![]() Feb 15 2002, 9:42 pm
|
|
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! |
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.