Pre-Order the Game!

Desura Digital Distribution

Thursday, December 1, 2011

Planets and Star Systems

While working on the equipment selection screen, I realized something. In order to have custom technologies which includes colony base technologies, I will have to specify which planets a colony base can settle. Since those types of planets are hard-coded in the game, it'd be easy to make mistakes and cause the colony bases to be useless because spelling don't match.

This led me to think, what if I make the planet types non-hardcoded? I can separate the planets art into its own graphic file, then have a XML file "planets.xml" that contains name of the type of planet, description of that type, pollution threshold, type that it degrades to, and type that it terraforms to (if any), max population range, and where in the planets.png the planet art is located. It will always be 40x40 since the UI in game expects that size, but you can make different sized that is under 40x40. Also, more than one planet can use the same art.

This will allow users to create really unique planets for their mods, rather than just replacing the artwork.

While thinking about the planets, I realized another thing. Star Systems are hard-coded as well, it have a pre-set probability for types of planets to show up in its system (all different colors have the same probability). I can change star systems to use XML file instead of hard-coded. There would be different types of stars (colors, black hole, etc). Again, I would separate the star artwork from the artwork into its own file: stars.png. The XML file would determine which graphic to use, color of the star, probability range for different types of planets, and whether or not this kind of star allows planets (black holes don't have planets for example). This would allow users to create different stars, rather than just being limited to the normal one and black hole. For example, quastars or binary star systems.

So with the above system, you could designate yellow stars to have more organic planets (terran, jungle, ocean, etc), and designate red stars to have more mineral rich planets (you can specify the probability range of bonuses as well)

The amount of planets will still be adjustable in-game, just that their types would be determined by stars.xml file's probability range. However, if I were to convert to the xml file for stars, I will need to remove the black hole slider, since it will be determined by the xml file/galaxy script.

I will then also improve the galaxy script to actually specify which type of star to add when generating galaxy. Currently it just says "size 2 star here, size 3 star there", then the game randomly picks a percentage of stars and change them to black holes based on your percentage selection.

I think this should improve the game a lot, and allow me to more easily modify things without having to change the code inside the game. One of my goal is to make this game very easy to mod, and I realized that just changing the artwork may not be enough for some people, so I hope this will help satisfy the modding desire of those people :)

5 comments:

  1. Sounds like a great idea! My game uses Enums in Java for hard-coded data, but my ultimate plan is to convert all of them and certain other data into external XML files that users can modify.

    ReplyDelete
  2. What do you mean by planet type? Is it as abstract as asteroid, rock and gas giant or it includes the climate (barren, arid, terrain but essencialy a rock)?

    ReplyDelete
  3. Planet type would be the name of the planet. You also need to specify how much population can be on this, or if it's uninhabitable. You set the pollution threshold, and if it's exceeded, which planet type in the list of planets to degrade to. If the planet is terraformed, you specify which planet type it becomes.

    Let's use Star Control 2's planets. If you add "Emerald" planets, each with production bonuses, and a max pop of 150, then specify "Rainbow" world as its terraforming result, when you terraform any Emerald planet, it becomes a Rainbow planet with say, max pop of 200. It would also have production bonuses due to your variables that you've set. Terraforming do not change the planet's original bonuses.

    You then add a technology that says "Terraform Emerald Planets", and add a variable terraformPlanet="Emerald". Then when that technology is "built" on an emerald planet, it changes to Rainbow planet.

    If a planet is uninhabitable (asteroids, gas giant, etc), you can specify the same variable - terraformPlanet="Asteroids", and technology name of "Build Planet from Asteroids". Or you could create a "Build Planet" with two variables, both "Asteroids" and "Gas Giant" meaning that this technology can be used for both planet types. The resulting planet would be the type that you specified in the planets file. So if you specify "Barren" as result of asteroid "building", it will change to Barren once technology is done building.

    Building and Terraforming may look different to the player, but behind the scene, it's the same functionality.

    The reason why "uninhabitable" is important variable in the planets file is that if the max pop is 0, but it's "inhabitable", you can establish a base there without people (an outpost essentially). If it's uninhabitable, you can't put a base there, and if a planet degrades into this type, the base is removed.

    I hope that's clear, if you have any more questions, feel free to ask!

    ReplyDelete
  4. i had an idea. how about they ability to load up a percentage of a colonies population and abandon the colony? and being able go give colonies to other empires.
    -Walloping

    ReplyDelete