Friday, July 10, 2009

Spawning is BACK!

It's fully functional in the editor now, and looks great. Spawns can be previewed in the map editor, and placed with a click of a button. Onward, to importing old stuff! Items & spells to start...

Oh: randf() and its friends have made my coding life so much easier. Never again will I have to type (rand()/float(RAND_MAX)) * SCALE or (rand()-RAND_MAX/2)/float(RAND_MAX)...these are now just randf() and randfSymmetric(). I can also do randfAngleRadians(), randf(scale), and could easily implement randfGaussian and randfCenterWeighted if I needed them.

Ok, one more thing before I get to importing: I should describe how the spawning system works so that I have notes on it other than in the code.

Step 1: add swarm spawn target level layers. These define to which level of player the spawns at each location on the map should be configured.

Step 2: add a swarm spawning layer. This layer is masked to affect a defined area on the map. Attributes include the ability to clear all existing swarm spawns (default behavior is to simply add more options), and limit the number that this layer adds (the layer can have 32 specified spawns, each with an independent probability of occurring, and the layer can add all of them--but they'll overwrite each other once the maximum is reached.

In the list of swarm references, each swarm has a min/max level and only adds itself to locations that are within this level range. There is also a % chance to be added, so some monster spawns can be very rare. Finally, there is a list of AI types that can be added at the location. Want to spawn 3 kinds of 15 types of rogues? Just stick 'em all in a single reference, set the thing to 100% spawn probability, set the # of monsters to spawn to be 3 and bam! whenever the spawn is triggered, one of three of a random selection of those 15 kinds will be created.

Finally, step 3: There is a boolean mask that triggers whether or not something is spawned on the location at all. This is how you configure spawn points: simply turn it on or off and the configured monsters will show up or go away.

No comments: