So I decided to work on putting limits on where monsters can go and where they can't.
First thought was to do it by loading in all the height maps from the client files but I quickly discarded that idea on the grounds that it's a pain in the ass to work with those files and because it would have only given me a heightmap in the end anyway when what i really wanted was to define area where they can and can't go
I came up with the idea of hijacking lmame's grid system to make a massive X,Y grid by the name of "collisions" for each map
Basically each point in the grid represents 1 meter (as displayed on the minimap)
Each point contains an X, Y coordinate that translates directly from the Position.coords values by subtracting the X and Y minimums (as defined in the existing grid system) and a value to define which monsters (if any) can go there.
0 is a no go for any monster
1 is basic land for pretty much any monster
2 is water so just fish and aquatic monsters for that.
I plan to add more terrain types later. maybe sand for beaches and desserts, heavy grassland and so on.
So how do I get these fancy shmancy grids into place? that's the tricky bit.
It was trivial to actually build and implement the structures so that the server loads the grids but they are all empty
"So what happens if I use a character to run around the maps recording the locations and then save it from the server"? i think to myself.
So i did it. Added some new config stuff and a couple of GM commands along with a new save routine that only saves maps that I've actually modified. (otherwise it takes WAY too long to save)
OK so that gives me the outlines, rings around trees and buildings and stuff. Now what? I can't physically run over every single square meter of ground in every map. That would take years.
Let's load it into excel and display all the 1s and 2s and 0s in a nice easy to see spreadsheet.
Yeah... That was a smart idea
99% of the spreadsheet is empty and there are a few skinny little lines of 1s and 2s in a massive sea of zeroes, and it's really hard to see where the non-zero values are.
And even then, HOW to fill in all the huge spaces between the edges that I had recorded?
To cut a long story short, I built some cool little macros that re-color the cells whenever a value is changed, made all the cells square and zoomed way the hell out so I could see a significant chunk of the map.
Then I spent a couple of hours designing a flood-fill algorithm, during which i had to code a method to actually use a stack in VBA.
VBA doesn't have any stackable structures like Vectors. It has to be done with arrays and movable pointers. It was a pain in the ass but I finally got it done.
I now have a complete map of Adventurer's plains that loads into the server (along with all the other empty maps)
Now to do the others.....
And then start modifying AIP so that it can actually work with my new system.
Dynamic spawning will be along pretty soon
The worst of the groundwork is done now.