ID:179245
 
for most of my inifinit loops... I use this...

mob
New()
Years()
mpgain()
hpgain()
npcattack()


is this efficient?

People have been complaining of lag and there's really not anything else that could cause this in my code since I don't have that many infinit loops...

It works though, but another question of mine is...

Ok I understand that New() starts these procs whenever a new mob is created, right?

Or does it continue to cycle through them, like if I were to switch my usr.client.mob to another mob, and then back would it call these procs again??

Which brings up anohter topic about my npcattack...

I have it check for a mob in area, but if there is no mob I have it do an npcattack(defender) to start the proc over again and return

but after awhile I start getting these messages because there's no mob to attack in its oview...
mob/(check) defender=null or something to that effect and like 20 of these keep popping up...


would help to increase the sleep() time?? Would that keep it from lagging so much and causing it to crash?

or would it eventually do it anyways?
Well, I like to stagger my loops called at New, at least:

mob
var
HP = 50
MP = 30
loop-check = 1
proc
loop_HPgain(var/amount = 0)
if(!loop-check) return
src.HP += amount
spawn(20) loop_HPgain(amount)
loop_MPgain(var/amount = 0)
if(!loop-check) return
src.MP += amount
spawn(20) loop_MPgain(amount)
New()
..()
spawn(1200) loop-check = 0
loop_HPgain(rand(40-length(src.key),40)
sleep(10)
loop_MPgain(rand(40-length(src.name),40)