chicken
icon = 'animals.dmi'
icon_state = "chick"
name = "Chicken"
density = 0
MaxHealth = 15
Health = 15
Strength = 7
Defense = 1
Level = 1
Gold = 5
Alignment = "Good"
Kills = 0
Category = "Critter"
New()
startX = x
startY = y
startZ = z
while(src)
chickenRun()
if(prob(20))
flick("chickpeck",src)
chickenRun Code:
mob/ai/proc
chickenRun()
for(var/mob/M in oview(1))
if(M.client)
walk_away(src, M, 1, 3)
else
walk_rand(src,30)
Problem description:
Right now, running the game is extremely laggy. So laggy, in fact, that it takes a good 40 seconds just to start it. I'm not quite sure what's wrong with this code.
All long (execution-time wise) loops should have delays at least once in a while, to allow other things to run in the meantime as well - infinite or psuedo-infinite loops like what you have certainly must have one.
The above loop has a space of one second between its iterations, as in the end of every iteration, it sleeps (waits) for a second before continuing to the next one.
Note that in your code, you're also misusing walk() and abusing usr (because your oview() call defaults to using Center=usr, look it up).