I was thinking about how the smartspawning is done by scanning sectors for players, and how you had said somewhere that it's best not to use smartspawning on spawners with a really large range because it has to scan that entire area.
Well I was thinking, why not just check the map of all the players, and then for each player on the same map as the xmlspawner, check the distance and see if they're within the spawnrange + 21
This could potentially reduce a lot of the processing time needed to determine whether to spawn the monsters or not. This method would probably only cause lag if there were a BUNCH of players logged on and all on the same map that had a TON of spawners.
Here's another thing I was wondering about... the spawners have an annoying habit if placing the spawn ON the spawner more frequently than away from the spawner. about 50% of the new spawns created are placed directly on top of the spawner instead of in a random location within the spawn range.
QUOTE (Xarlon @ December 18, 2006 06:19 am) |
Here's another thing I was wondering about... the spawners have an annoying habit if placing the spawn ON the spawner more frequently than away from the spawner. about 50% of the new spawns created are placed directly on top of the spawner instead of in a random location within the spawn range. |
this happens when the spawner cannot find a valid location within the defined spawning range. It makes 10 attempts to find a random location and if it fails it just puts the spawn at the spawner location.
If you are getting a lot of spawns at the spawner location it is probably because your spawn area includes a lot of invalid locations or a high density of existing spawns (it considers a location that is already occupied by a mobile to be invalid).
QUOTE (Xarlon @ December 04, 2006 11:52 pm) |
I was thinking about how the smartspawning is done by scanning sectors for players, and how you had said somewhere that it's best not to use smartspawning on spawners with a really large range because it has to scan that entire area.
Well I was thinking, why not just check the map of all the players, and then for each player on the same map as the xmlspawner, check the distance and see if they're within the spawnrange + 21
This could potentially reduce a lot of the processing time needed to determine whether to spawn the monsters or not. This method would probably only cause lag if there were a BUNCH of players logged on and all on the same map that had a TON of spawners. |
it doesnt actually scan all of the sectors in the spawn area when testing for smartspawning. What it does it to scan the sectors currently occupied by players and then looks up those sectors in a hash table to determine whether there are any spawners that include that sector in their spawning area and then it checks those spawners to see if they need to be smartspawned. This is done once a second.
So having a spawner with a large area means that it is simply more likely that the spawner will be checked. Spawners that have a large spawning area with no players in it, have essentially no impact on performance.
Since individual players will typically be in the spawning range of one or two spawners, the number of checks being made will be roughly one or two times the number of active players, which is a lot less than the number of scannable sectors that could be included in the smartspawning detection (by like four orders of magnitude).
So as you pointed out, you would only start seeing significant load if you had large numbers of players that were within range of many spawners. I have benchmarked it with the equivalent of thousands of players in a typical spawning configuration with minimal performance impact. I believe that I posted the results of those benchmarks a while back.
QUOTE (ArteGordon @ December 18, 2006 01:41 pm) |
I believe that I posted the results of those benchmarks a while back. |
Ah, I had seen mention of benchmarks in a post while I was browsing, but what I read had said that they had yet to be done. I'll have to find those benchmarks. Thanks.
As for the problem of it placing spawns on the spawner... I guess that's probably becase I have my range set to include the entire dungeon, and there's lots of black space between corridors. Do you know offhand which file I would need to look in if I wanted to raise it to check more locations than the default 10? I'll browse around and see if I can find it, so if you don't know, and don't want to look it up, that's fine.
here is some info from xmlspawner2.txt
QUOTE |
New to version 3.00 updated 10/13/05
- optimized the smartspawning algorithm for reduced cpu load. This will increase memory use slightly but will come with significantly reduced cpu usage. The new smartspawning cpu load is now only a function of the number of players online rather than the number of spawners and their spawn ranges. It uses hashtable mapping of current player sector occupancy to spawners. The estimated increased memory use for a fully spawned shard with all spawners set to smartspawn is approximately 0.3M. The old activation method added a 1-2% cpu load for a fully smartspawned shard while the new method uses less than 0.01% under a benchmark configuration of 3K spawners, avg spawn range 10 tiles, 100 active players.
|
To change the random location selection attempts look at this method in XmlSpawner2.cs
public Point3D GetSpawnPosition(bool requiresurface, int packrange, Point3D packcoord, List<SpawnPositionInfo> spawnpositioning, Mobile mob)
around line 10000
CODE |
// Try 10 times to find a Spawnable location. // trace profiling indicates that this is a major bottleneck for (int i = 0; i < 10; i++)
|
Wow... You really answered that fast, and in a lot more detail than I expected.
Something I noticed when I was modifying the file... it looks to see if the region is set, and if it is, it spawns things across the entire region instead of looking for random locations within the spawn range. For some reason I had never noticed the region setting before... I'll probably use that a lot more when I spawn things in dungeons.
I'll definitely mention the region thing to the other staff on the shard. They tend to just guess a range, and it's almost always too big, and ends up spawning things in other dungeons, and green acres... they drive me nuts! lol
I think that the best way to get optimal spawning distributions is to install the SpawnEditor transfer server and have staff use SpawnEditor to see what they are doing.
You get to specify the spawning areas exactly and you can also see where there is overlap with other spawners, what the spawn densities are in different areas, and the actual distributions of specific spawned objects.
Sounds awesome. I'll have to test it out on my comp, and if it's not to complex to use I'll try and teach them. (there's still some staff members that don't know how to use [xmlfind)