Pre-Order the Game!

Desura Digital Distribution

Tuesday, February 17, 2015

Nebulas and Galaxy Generation

As a reminder, the objective of Beyond Beyaan was to be a MoO 1 clone.  With the merge with Jeff's project into Dominus Galaxia, we still want to make a game like MoO 1, but it won't be a straight clone anymore.  Our goal is to dissect MoO 1's weaknesses (as well as MoO 2's) and strive to try and eliminate them, while retaining MoO 1's feel.

So when there's any major difference between DG and MoO 1, I will regularly post about them, and why we do it a certain way or this way to explain our reasoning behind our decisions.  I'm going to start with the fundamental object of MoO 1, the galaxy.

One major issue in MoO 1/2 is that the galaxy is very open.  There's virtually no "strategic" locations to defend or attack, aside from planets with bonuses.  There's no bottlenecks, no natural obstacles, etc.  Some games has attempted to add strategic elements by adding features, for example, starlanes in MoO 3, unique travel mechanisms in Sword of the Stars, etc.  The major complaint is that they're "unnatural", despite adding a lot of strategic depth.

We wanted to retain MoO 1's simple fuel range, but wanted to make the map more interesting, and not have kludgy features that don't feel "right", while keeping it relatively simple.  So we took MoO 1's "Nebula slows ships" concept and expanded it further.  There are now three types of nebulas.  They are:

Anti-matter (Orange color): No stars spawns within it.  It reacts with everything else in the galaxy, thereby preventing the ability to travel through it.  In game, it's static, blocking any direct travels through it (similar to MoO 2's black holes).  Don't worry, the game will have dynamic pathfinding, so it's possible to traverse around it to your destination without having to go to other stars, provided that the entire journey is within the fuel range.

Heavy (Purple color): This is similar to MoO 1's "Slow Nebula", but it only affects the travel speed.  It does not affect shielding.  If ships were to travel at high speeds, they'd be shredded.  So ships are constrained to travel 1 parsec/turn while in heavy nebulas.

Radioactive (Blue color): Atoms are radioactive, emitting alpha, beta, and gamma.  There's so much noise in the nebula that it's impossible to detect ships within it.  Ships inside it are blind and cannot detect other ships.  In battles, it interferes with electronic systems, reducing the effectiveness of targeting computers, shields, and any technologies that has guiding mechanisms (reducing missles and torpedoes' effectiveness for example).

We've devised a method of generating nebulas that makes them look organic.  A player can control how much chance there are in spawning nebulas in the game setup screen.  Note that there's no code that ensure that all three types show up.  Some galaxy might have only one or two types, or even none.

Now for the eye candy (and also the first galaxy screenshot of DG!):

In the above screenshot, we see the anti-matter nebula taking up 1/3 of the galaxy size (this doesn't happen often!), with some radioactive nebulas on bottom (sorry about jagged edges, I cropped screenshots together).

In the above screenshot, we see dense nebula sprawling over west part of the galaxy, with anti-matter nebula on east part.

For those who may be concerned that the nebulas looks pixelated if zoomed in like my old nebula, rest assured.  Above screenshot is fully zoomed in, you can see that the nebula is not pixelated, and that the planets are 3D.

Now, for galaxy generation part.  MoO 1 and 2 basically have one shape, but several sizes.  A square-ish map of varying sizes.  We decided to create a feature where it reads in a density map to generate stars and nebulas.  The density map is a greyscale image in png format.  The more white a pixel is, the more exponentially chance of having a star spawn there.  Black means absolutely no stars at all.  Each galaxy shape is stored in a folder, with a config file that dictates how much space is needed (the player picks number of stars to play with, it will automatically calculate the size of galaxy to accomodate the number of stars).

The config file dictates which density map image is used for which.  There can be up to 4 density map for a galaxy:  Stars, Anti-matter nebula, dense nebula, and radioactive nebula.  If no nebula density is specified for a type of nebula, it defaults to the star density map.  So it's possible to create a galaxy shape with only one density map.  The reason for multiple density maps is to allow for variety of galaxy types.  For example, a ring galaxy with anti-matter nebulas filling the center to prevent travel across the center.  The possibilities are endless.

With those two features (three nebula types, and density maps for galaxy generation), we've solved the issue of MoO 1's maps being open and not very interesting, while retaining the open feel.