ID:1120432
 
(See the best response by A.T.H.K.)
Code:
            var/mob/P
var/mob/PC/O
New()
. = ..()
src.CreateName()
spawn()
Wander()

proc/Wander()
while(src)
var/Found = FALSE
for(O in oview(6))
if(O.safe==0|O.dead==0)
step_towards(src,O)
Found = TRUE
break

if(Found != TRUE)
for(P in oview(6))
if(P.safe==0|P.dead==0)
step_towards(src,P)
break
sleep(3)
sleep(2)

Bump(mob/M)
if(istype(M,/mob))
Attack2(M)
if(M.dodge==1)
src.Evade(M)


Problem description: Ok so, what I am trying to do, is get certain mobs active throughout the world. By that I mean, I want to get mobs to fight each other when players are not around. The thing works perfectly fine when it actually runs. I get 0 errors and 0 warnings. But when I run it, within a few minutes, the game freezes and i get a message saying "Dream Seeker has stopped responding" and yada yada (the windows thing). As I code this code in to other mobs, the crashing gets worse and quicker. I am pretty sure it has to do with me using faulty loops...but I would like to know exactly where I went wrong. Any help will be much appreciated.

Best response
Honestly having the mobs fight each other is just stupid, no offense, but you are are just using the CPU for no reason, if a player isn't their to watch them fight whats the point?

I would suggest, if you really want mobs to fight each other, is to make them do it when a player is around, even randomly take hp before they start so the player thinks they have been fighting for awhile.
To be honest, I agree too. But I am just following the Owner's wishes, even after I told him that it would be pretty stupid. But apparently he really wants me to do this. Is the crashing due to the large usage of CPU?
I can't say, you may have many many other factors as well.

I would use the profiler.
hm, I did use a profiler and it showed a bunch of procs and calls all in a matter of seconds, each at about 0.3 CPU usage.