ID:154071
 
Ack, I tried to decrease the lag from the many, many mobs running around in Fenris's Apocolypse, but now I just made it more laggy... sigh.


What I did today was this:

Made it so the mob would only move if a player was on that map.

Got rid of all the while(src) statements and put in if(src in world) -- I had to do this to get the other code in there to work.

Got rid of all the sleep() procs and turned them into spawn() procs (This is why I had to get rid of the while() statements)


But now, with my oh so good lag decreasing technique, I seem to have made it so bad that it takes like 10 seconds for an input to come that came from another input.

Please help me on this, this is the 3rd time I went through the grueling 208 different mobs and replaced code in them. It takes around 2 hours every time I have to go through them, and for the 3rd time too...
Try just if(src). Also, if it takes you hours to edit the code for every monster, why don't you just have them all have a parent, Wandering_Monsters, and put the wandering code there?
I think the recommended course to take is to have the players run a check for all NPC mobs in view whenever they move, then whenever it finds an NPC mob, it tells that mob to attack the player (assuming you want them to attack). It might seem laggy to run a proc every time you take a step, but it's a whole lot less laggy than running a proc repeatedly for all 208 monsters.

Of course, I don't know how you're doing them in the first place. Basically, avoid letting the mobs act on their own. Make it so that when the player does something, like go near the mob, then it tells the mob to start up. That way, mobs aren't doing anything while there are no players around to effect with their doings.

There were some discussions on this a while back, but I don't remember the topic name of them...
In response to Garthor
I didn't do that in the first place because I wanted to avoid going through allo of them again. But I just made them all using a parent proc like an hour ago. Well I found out that using a looping proc creates A TON more lag than the while statement, and thats why it was so much laggier (in fact about every thing I tried just made it worse).
In response to Foomer
Accually, its 208 types of mobs, there would probably have to be 600+ mobs on the maps total.

But what you said would make it so there basicly wasnt any lag at all. Thanks I will try to do that.