ID:144819
 
Code:
Enemy
Blob
HP = 20
MaxHP = 20
icon = 'Blob.dmi'
New()
..()
while(src)
sleep(10)
var/way = pick(NORTH,SOUTH,WEST,EAST)
step(src,way)
for(var/mob/M in world)
if(M.client && M in oview())
if(HP >= 7)
Chase(M)
else
Run(M)

proc
Chase(mob/M in world)
while(HP >= 7 && M in oview())
walk_towards(src,M,10)
sleep(8)
Run(mob/M in world)
while(src.HP <= 7 && M in oview())
walk_away(src,M,10)


Problem description:

The problem seems to only occur when there's more than one enemy on screen, but when I get the enemy's HP low enough for it to run, the game freezes.
You forgot the sleep() for Run. Also, there's no need to loop through the entire world for players when you're going to check if they're in oview() anyway. Just loop through oview() and then check if they have a client.

This is a really easy fix, and you have been posting a lot lately. Try to take a look at the code and fix it yourself first, and then if you're truely stumped, we're glad to help.

Edit: And I would suggest using step_towards() and step_away() instead of walk_towards() and walk_away().
In response to DarkCampainger
Ok thanks, and I'll try to look closer at my code.
The reason why it's freezing is because you keep calling walk_away() over and over again in your while() loop. You should call it once. And then run a loop or something to stop it running away. I prefer to use the step() processes though.