Courageous
Wanderer
Courageous' "True" LOS
COURAGEOUS' "TRUE" LOS
0.9.1-A---WARNING ALPHA RELEASE
In response to a request, about six weeks back or so, for a "TRUE" LOS system that would hide mobiles that went out of sight due to obstructions, I built up a highly performance tuned implementation of LOS using a compressed binary shadow casting technique. The short story is that I have a huge matrix of precalculated "shadows" that can determine in very low O() time whether or not any entity is visible to the viewer.
There are many dirty coding tricks in this source code; if you are not a l33t coder, I think you're probably out of luck in trying to understand it. However, if you find hard problems to be interesting challenges, note that the code is fairly well commented, even in this early release, and I'll also be happy to explain it in further detail if you are interested.
How the system works and performs: what you need to know:
1. When a player mobile is being tested to see if it can see another mobile, the system checks to see if there is a previously-cached VisibilityMatrix for that location on that map.
2. If there isn't, the Matrix is generated. If there is, the matrix is fetched from a MRU cache that holds as many as mapsize/96 matrices in ram. This cache has O(1) performance for the Hit and Store methods. I.e., it's quick.
3. Just after the matrix is fetched from the cache or created, it's given a second processing pass, the account for items that may block LOS. The initial pass only considers land and statics. The initial pass is relatively expensive. The second pass is very very cheap.
4. The fact of a mobile's visibility is tested against the matrix.
Some notes. After the first generation of the matrix, it's quite likely that a player will be tested several times for more LOS. This follow up checks are "almost free," due to the nature of the matrix. Furthermore, because of the cacheing, any test that occurs where another player has been is likely to be a "cache hit". If it is, it likewise is almost free. What this ought to mean is one wicked-fast LOS system. However.
I have not actually tested this system on any large shard. What I have done is enter in big loops in a variety of locations, to verify the performance of the system under load. The biggest restriction is that I can't know how often a cache hit will occur. If you assume that 95% of the players go to 5% of the places, this system will work like wild fire. If it's the other way around, I wouldn't expect more than 300 or so simultaneous players to work out on some good computer equipment.
Finally, one last note:
The current system uses "dead reckoning" for mobiles that go out of LOS. You'll see a mobile for a while, standing there, doing nothing, when you can actually "no longer see it". A future release may remove the dead reckoning, but for now it's there, so keep an eye out for it. That's what you're supposed to see.
Now. Hooking up the system:
THIS IS A CORE MOD.
First. It only works with DOTNET 2.0.
Second, all the files that you need are attached in the zip. There is one directory called "LOS" that should be compiled into your server. There are two files, Map.cs and Mobile.cs that you can either use to replace your own, or you can look for the XXX LOS comments to find the (few) changes and merge them into your own versions. Finally, you have to do the same thing with PlayerMobile.cs
THIS IS AN ALPHA RELEASE.
Bugs are a possibility. I don't know of any, and have tested it quite a bit, but there may be things I didn't know to test. Caveat emptor.
CORE MOD ATTACHED.
[TEMPORARILY REMOVED PENDING RESOLVING A COPYRIGHT MATTER]
0.9.A Initial Release
0.9.1A Fixed bug at edges of map
COURAGEOUS' "TRUE" LOS
0.9.1-A---WARNING ALPHA RELEASE
In response to a request, about six weeks back or so, for a "TRUE" LOS system that would hide mobiles that went out of sight due to obstructions, I built up a highly performance tuned implementation of LOS using a compressed binary shadow casting technique. The short story is that I have a huge matrix of precalculated "shadows" that can determine in very low O() time whether or not any entity is visible to the viewer.
There are many dirty coding tricks in this source code; if you are not a l33t coder, I think you're probably out of luck in trying to understand it. However, if you find hard problems to be interesting challenges, note that the code is fairly well commented, even in this early release, and I'll also be happy to explain it in further detail if you are interested.
How the system works and performs: what you need to know:
1. When a player mobile is being tested to see if it can see another mobile, the system checks to see if there is a previously-cached VisibilityMatrix for that location on that map.
2. If there isn't, the Matrix is generated. If there is, the matrix is fetched from a MRU cache that holds as many as mapsize/96 matrices in ram. This cache has O(1) performance for the Hit and Store methods. I.e., it's quick.
3. Just after the matrix is fetched from the cache or created, it's given a second processing pass, the account for items that may block LOS. The initial pass only considers land and statics. The initial pass is relatively expensive. The second pass is very very cheap.
4. The fact of a mobile's visibility is tested against the matrix.
Some notes. After the first generation of the matrix, it's quite likely that a player will be tested several times for more LOS. This follow up checks are "almost free," due to the nature of the matrix. Furthermore, because of the cacheing, any test that occurs where another player has been is likely to be a "cache hit". If it is, it likewise is almost free. What this ought to mean is one wicked-fast LOS system. However.
I have not actually tested this system on any large shard. What I have done is enter in big loops in a variety of locations, to verify the performance of the system under load. The biggest restriction is that I can't know how often a cache hit will occur. If you assume that 95% of the players go to 5% of the places, this system will work like wild fire. If it's the other way around, I wouldn't expect more than 300 or so simultaneous players to work out on some good computer equipment.
Finally, one last note:
The current system uses "dead reckoning" for mobiles that go out of LOS. You'll see a mobile for a while, standing there, doing nothing, when you can actually "no longer see it". A future release may remove the dead reckoning, but for now it's there, so keep an eye out for it. That's what you're supposed to see.
Now. Hooking up the system:
THIS IS A CORE MOD.
First. It only works with DOTNET 2.0.
Second, all the files that you need are attached in the zip. There is one directory called "LOS" that should be compiled into your server. There are two files, Map.cs and Mobile.cs that you can either use to replace your own, or you can look for the XXX LOS comments to find the (few) changes and merge them into your own versions. Finally, you have to do the same thing with PlayerMobile.cs
THIS IS AN ALPHA RELEASE.
Bugs are a possibility. I don't know of any, and have tested it quite a bit, but there may be things I didn't know to test. Caveat emptor.
CORE MOD ATTACHED.
[TEMPORARILY REMOVED PENDING RESOLVING A COPYRIGHT MATTER]
0.9.A Initial Release
0.9.1A Fixed bug at edges of map