Improving coastal maps
Back from mini hiatus due to some work deadlines and a cold (yes, most of you are roasting, but the British Isles are cursed weather-wise). A variety of topics since last time, but I'm going to focus on a couple, a "done" and a "not-done".
Improving coastal maps
Being summer, one cannot help but think about nice beaches and water, right? So, obviously to the deranged gamedev mind this means "make your coastal maps better!". Previously, water maps had ... a lot of water, and I don't expect much action to take place in water, in a level at least. Another problem was that optional prefabs were placed in water and connected to land, but they were ... too close to water. E.g. a rectangular cemetery-island situation. Not nice. So why not (figuratively speaking) kill two birds with one stone? Enter, or better, re-enter, distance fields. Before I bore you, here's a before-after picture pair.
I've used distance fields previously in coastal maps to differentiate shallow and deep water. So, how do we use them effectively to fix the problems above?
- Calculate a distance field to landmasses and gather all points above a certain distance. Keep up to 10 of those points, randomly. These will be the island seed points.
- Calculate a distance field to different zones AND to the island seed points calculated above
- Go through all water tiles int he map, and sample this new distance field. Perturb the distance with a bit of noise, and for all points where this perturbed distance is lower than some threshold, set this to land. This adds land padding. Padding for an island seed point results in an island, and padding for a subzone border means ... natural environment border, rather than abrupt/direct one (e.g. rectangular cemetery island).
- Fill the new tiles with randomised floor or blocked elements.
- Run some connected component algorithm to carve out blocked elements so that all areas some accessible. Otherwise a teleport trap would teleport you in-between some trees and that's no fun.
Here are a few images from intermediate stages.
Boss zones
Part of the time was spent misering over improving and thinking more about integration of boss zones/lairs. It's a complex combo of procedural prefab areas with content that should be controllable on the fly. It's a nightmare really to set in a remotely clean way. For example: we have a dragon's lair, which is a procedural zone (cavernous) that includes a procedural prefab preset for placement of things, like "dragon" and "hoard". So, "dragon" and "hoard" can be placed dutifully according to rules, but the runtime code, without using a fugly if-else, should be able to provide a way to instantiate this "dragon" and "hoard" according to the current adventure location requirements. More on this to come, hopefully next week with some prefabs after I flog myself to action.
In other news
- I've made some Unity editor window to ease with test dungeon generation, allowing some level of configuration
- Prefab zones now can belong in groups, so that I can control the randomness better. E.g. if I have 5 varieties of "beast caves" and I spawn 5 optional zones in a map, we shouldn't ever spawn 5 beast caves. Pick something else you silly RNG!
- Bug fixing, this time on team config. This bug was clearly visible when I spawned a bunch of monsters in a boss room and they started attacking each other. Disgruntled employees I guess.