It seems when I use while statements it tend to lag ALOT and my game becomes unplayable alot of the time.
Is there a way to reduce lag or am I doing something wrong?
For example if I write this, It works but the game is very laggy, but if I remove it the game runs well.
mob/proc/attackAI()
while(src)
for(var/mob/M in oview(5))
if(M.Enemy == 1)
walk_to(src,M,1,2)
M.HP -= 1
oview() << "A Fire Fight Has Ensued!"
if(M.HP <= 0)
oview() << "Unit [M] Destroyed."
del(M)
sleep(10)
I am sure I am just missing something simple but I thought I would ask.
I have used while statements in other games without lag but I can't see why sometime it lags and other times I don't have a problem.
Any Help is appreciated!
Thanks in advance!
Bloodocean7.
How many AI controlled mobs are there in the world, roughly?