Starbound

[DAILY BLOG] Belated Weekly Update Round-Up!

Hey!

27th October - Caves


Last Wednesday I decided to spend some time on caves as part of my work improving the terrain generation. Starbound’s cave generation used some very simple algorithms that worked reasonably well but weren’t very exciting, and I wanted to try my hand at an improved cave generation algorithm. So, I wrote a new generation method and reworked the existing ones to get more interesting results. The short version is that caves are more frequent, more connected, and more varied. If you want the long version, keep reading for a technical explanation!

I’ve been calling the new method “karst” cave generation since it loosely mimics natural geology by generating caves in layers. The algorithm itself is fairly simple, relying on a combination of several Perlin noise sources with different configurations. All of the noise is applied vertically, so it’s possible to use only one-dimensional noise sources. For Starbound, however, I’m sampling in two-dimensional coordinates around a circle with circumference equal to the world width, which creates a noise pattern that smoothly wraps around the world seam.

The first step in the algorithm is to pick layers to place caves at. This could be a simple probability applied to each Y position in the world, but I’ve chosen to enforce a minimum layer resolution in order to avoid clumps:



Next I use a Perlin function with a high period to select where on these layers caves should be generated:



Then I apply a second Perlin function with a moderate period and amplitude, as well as some positive bias, to vary the caves’ ceiling height:



I use another, similar function to vary the floor depth, with a lower amplitude to make the caves easier to walk in:



Next, I taper the endpoints of the caves to avoid the harsh edges, based on the original noise function being below a cutoff point:



At this point it looks a bit like real caves, but they’re very horizontal and boring, so the next step is to apply another function with a very high amplitude and period, which gives the caves slopes and makes the layers cross over each other:





This is looking much better, but is still very horizontal, so we mix in some large, tall chambers using a different configuration of the same algorithm:



…and finally mix in some normal worm caves to further increase verticality and connectivity:



The final result is a good mix of caves that feel natural and provide plenty of opportunities for exploration as well as some hazards (sudden drops and chambers of enemies) to keep things fresh.



In this example there are a LOT of caves in the world, and I’ve been tuning the configuration to get slightly fewer caves but still retain the right amount of complexity. I’ve already been having a lot of fun testing it, so that’s a good sign!

Sorry for the lengthy post, but hopefully some of you will find the explanation interesting and maybe even useful in your future projects.



28th October - All The Small Things


G’day folks! Today I’ve taken a bit of a break away from getting more of the new biome weapons and drops working, in favor of working on a number of smaller things that I’ve needed to give some attention to for a while now.

Many of the game’s trap objects were broken when the status system overhaul hit, resulting in players no longer taking damage. Some of these objects were already a bit broken to begin with (electric-sounding instakill wooden spikes, anyone?) so I gave the traps we had a bit more TLC today.

Now their damage levels are a bit more reasonable across the board (though they could still be subject to change down the line), they make more appropriate sounds when you hit them, and what was probably most time-consuming was fixing all their hitboxes to more accurately reflect the areas that are actually dangerous, including when they are flipped.



Previously most had their hitboxes generated automatically, often extending into empty space around the object that should have been safe for the player. It’s one of those subtler details that one would rarely think about when playing games (unless they’re done poorly), but it’s pretty important to get right when you’re the one making them.

As a small aside, those of you more familiar with the game’s objects may have noticed that the propeller can be placed on walls and ceilings now. The more I looked at it, I figured it would be nice for the airship-enthusiasts in our player base to have more options. The spinning propellers are still dangerous though, so be careful where you place them!

I also did a little tidying with the interface to make sure all the new status effects were displaying the appropriate graphics when inflicted upon the player.



In a bit of more exciting news, Metadept has pretty much wrapped up work on the shield generator for our dungeons (which I spent some time testing today). Essentially these generators will exist somewhere within the dungeons, restricting the player’s ability to build, place, break and wire objects within that space. That is until the player locates the generator and disables it. This will mean players can no longer circumvent all obstacles by building across or digging through them unless they’ve already been lucky enough to find the shield generator before-hand.

Setting up the existing dungeons with this new functionality will likely be my focus for the next few days. This will mean creating shield generator rooms for each one and getting them to spawn reliably. This can sometimes be difficult when you want to have them appearing in randomized locations (and preferably some distance from the entrance).

If things go the way I’d like, it’s my intent that each shield generator should have some form of obstacle to make shutting the generator off challenging or risky in some way. This could be as simple as the generator being locked behind doors that are only able to be opened from elsewhere in the dungeon, some strong enemies might be guarding it, maybe a little tricky platforming and problem-solving, or perhaps a combination of all of the above.

That’s it from me, good night folks!



30th October - Biomes


After working on terrain and cave generation last week, I’m now configuring biomes and treasure pools to include all the new assets that GeorgeV, Armagon and the rest have been building. It’s actually been a lot of fun to test, and I’ve enjoyed discovering many interesting little spots:







…yep, just another day in the universe!

'Til Friday! <3 ːpizzasliceː