Page 1 of 1

spawner back end fixes [completed]

Posted: Mon Oct 08, 2007 9:48 pm
by Red Squirrel
I'm working on enhancing the performance of spawners. This will hopefully help cut back on the spikes that happen every couple seconds. thats IF those are caused by spawners, if its not spawners then I'll have to look for other scripts that could potentially be the cause.

The way the spawners will work is that if they have been innactive for N amount of time, the rate at which they are checked for respawn will decrease by NN amount until it needs to respawn (which will take longer to be detected). N and NN are variables that are higher based on the default rate of the spawn.

This will mean that if you go to a spawn that is not very active, you may possibly wait long for the next respawn, but after that, it will go at a normal rate until its left innactive for an hour. When the shard first boots up, all spawners will be considered innactive (take longer to respawn) unless they arn't fully spawned. So if before SW you some slimes in parox lair when shard boots up that spawn will be at normal active rate.

Also, any spawns that are for vendors or otherwise blessed mobs, will go innactive automaticly since vendors cannot be killed.

The numbers may change, but this is the general idea of what I plan to do.

Archived topic from AOV, old topic ID:1405, old post ID:8793

spawner back end fixes [completed]

Posted: Sat Oct 13, 2007 11:42 pm
by Red Squirrel
Done, here is an explanation of how spanners now work:

A spawner that is set to 10 and has all 10 creatures spawned and remains in this condition for over an hour goes into "sleep mode" which means the interval at which the defrag() runs is much lower. We're talking about 5 minutes on a spawner that is normally 10 seconds per defrag(). What defrag() does is loop through the array of creatures and check if any are dead, then updates the creature counts. Then if the min/max delay random value is met, the respawn() is called.

At this point, the spawner is no longer in sleep mode so defrag() is now called more frequently. When creatures spawn, a calculation is used to determine what is the number of creatures required to be spawned to reach the max. So basically, max-currentnumber.

This number is then divided by 3 and added by 1. This is then randomized so it can be between 1 and the number. The final number is the number of creatures to be spawned.This is why often you'll see multiple creatures spawn at once. This speeds up the spawning process with the least amount of defrag()s.

Now, there are about 2000 spawners on the shard, which all do this process. In normal conditions, if I were to do a [global kill, or if there was simply tons of people raping mobs in every dungeon, we have a problem, they'd all be working on spawning at once, bogging down the server. This would happen if defrag() on multiple spawners would happen to run at once. I found that any more then 10 spawners calling defrag() at the exact same time caused a slighly noticeable cpu spike.

To solve this, there is a global date and int value. Each time there is a respawn on any spawner this value is updated, and the int is increased. If the date is less then 0.5 seconds ago and that the number is more then 10, it skips the respawn. If its more then 0.5 seconds ago, the number is reset.

I may still need to tweak those values, but a [global kill proved to be quite cpu friendly with this setup, and spawns did not queue too much.

As a player, the only thing you may notice is if you go to a spawn, it may take a while for the initial respawn to take place, but once thats happened, the speed should be normal.

Archived topic from AOV, old topic ID:1405, old post ID:9002

spawner back end fixes [completed]

Posted: Sun Oct 14, 2007 1:13 am
by Nexus Graveheart
Will this take effect with stealable artifacts and treasure chests as well?

Archived topic from AOV, old topic ID:1405, old post ID:9009

spawner back end fixes [completed]

Posted: Sun Oct 14, 2007 1:16 am
by Death
Nexus Graveheart wrote:Will this take effect with stealable artifacts and treasure chests as well?
Those are on a different system.

Archived topic from AOV, old topic ID:1405, old post ID:9010

spawner back end fixes [completed]

Posted: Sun Oct 14, 2007 1:24 am
by Red Squirrel
Some of those do spawn using regular spawners (as in, the chests appearing on the ground) but the chests themselves are on a totally different system. They spawn at a much lower rate (hours) so efficiency is not as important as it is with the mobile spawners.

Archived topic from AOV, old topic ID:1405, old post ID:9012

spawner back end fixes [completed]

Posted: Sun Oct 14, 2007 1:34 am
by Death
Red Squirrel wrote:Some of those do spawn using regular spawners (as in, the chests appearing on the ground) but the chests themselves are on a totally different system. They spawn at a much lower rate (hours) so efficiency is not as important as it is with the mobile spawners.
Those no longer spawn on a spawner system. It was a lot more efficient to just drop the chest itself as the timer is built into that class.

Archived topic from AOV, old topic ID:1405, old post ID:9013