Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Making Planets?  (Read 5327 times)

TheMessiah

  • Captain
  • ****
  • Posts: 315
  • Captain of the Sidus Dim
    • View Profile
Making Planets?
« on: June 03, 2012, 07:32:32 AM »

I'm not intrested in the coding part of it but what different files are needed for one planet and what do they do? Is there a tutorial somewhere?
Logged

Vandala

  • Admiral
  • *****
  • Posts: 1841
  • We need ponies, ponies in spaceships!
    • View Profile
Re: Making Planets?
« Reply #1 on: June 03, 2012, 09:28:20 AM »

Only one line in one file needs to be added to add a planet.

The file is: "SectorGen.java"
Located in the folder: "./data/scripts/world/"

Here is how it looks. I've bolded one of the planets below.

You can add any planet you want from the "planets.json" file located in "./data/config/". You can even build your own planets by editing this file, even add custom graphics which are located in "./graphics/planets/".

Spoiler
This signals that something needs to be created.
This is the ID of what you create.
This is the function that creates the planet.
This is the ID of the celestial body around which it orbits, usually a star but you can use any ID.
This is the name of the object as displayed to the player in-game.
This is the ID of which object to use in relation to the "planets.json" file.
The 4 numbers after all this is about the distance, size, etc of the object you want to create.
Distance as in distance from the object it orbits.
Size as in the size of the object itself.
I don't recall what the others did.

Quote
package data.scripts.world;

import java.awt.Color;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;

@SuppressWarnings("unchecked")
public class SectorGen implements SectorGeneratorPlugin {

   public void generate(SectorAPI sector) {
      
      StarSystemAPI system = sector.createStarSystem("Corvus");
      
      SectorEntityToken star = system.initStar("star_yellow", Color.white, 500f);
      
      SectorEntityToken corvusI = system.addPlanet(star, "Corvus I", "desert", 55, 150, 3000, 100);
      SectorEntityToken corvusII = system.addPlanet(star, "Corvus II", "jungle", 235, 200, 4500, 200);
      
      system.addAsteroidBelt(star, 500, 5500, 1000, 150, 300);
      
      SectorEntityToken corvusIII = system.addPlanet(star, "Corvus III", "gas_giant", 200, 300, 7500, 400);
      SectorEntityToken corvusIIIA = system.addPlanet(corvusIII, "Corvus IIIA", "cryovolcanic", 235, 120, 800, 20);
      system.addAsteroidBelt(corvusIII, 50, 1000, 200, 10, 45);
      SectorEntityToken corvusIIIB = system.addPlanet(corvusIII, "Corvus IIIB", "barren", 235, 100, 1300, 60);
      
      SectorEntityToken corvusIV = system.addPlanet(star, "Corvus IV", "barren", 0, 100, 10000, 700);
      SectorEntityToken corvusV = system.addPlanet(star, "Corvus V", "frozen", 330, 175, 12000, 500);
      
      initFactionRelationships(sector);
   }
   
   private void initFactionRelationships(SectorAPI sector) {
      FactionAPI hegemony = sector.getFaction("hegemony");
      FactionAPI tritachyon = sector.getFaction("tritachyon");
      FactionAPI pirates = sector.getFaction("pirates");
      FactionAPI independent = sector.getFaction("independent");
      FactionAPI player = sector.getFaction("player");
      
      player.setRelationship(hegemony.getId(), 0);
      player.setRelationship(tritachyon.getId(), 0);
      player.setRelationship(pirates.getId(), -1);
      player.setRelationship(independent.getId(), 0);
      

      hegemony.setRelationship(tritachyon.getId(), -1);
      hegemony.setRelationship(pirates.getId(), -1);
      
      tritachyon.setRelationship(pirates.getId(), -1);
      tritachyon.setRelationship(independent.getId(), -1);
      
      pirates.setRelationship(independent.getId(), -1);
      
//      independent.setRelationship(hegemony.getId(), 0);
//      independent.setRelationship(tritachyon.getId(), 0);
//      independent.setRelationship(pirates.getId(), 0);
//      independent.setRelationship(independent.getId(), 0);
//      independent.setRelationship(player.getId(), 0);
      
   }
}
[close]

I hope I got everything correct, I haven't looked at this stuff in a while.
« Last Edit: June 03, 2012, 09:44:45 AM by Vandala »
Logged

TheMessiah

  • Captain
  • ****
  • Posts: 315
  • Captain of the Sidus Dim
    • View Profile
Re: Making Planets?
« Reply #2 on: June 03, 2012, 10:09:54 AM »

But how do you make a planet? What art files will need to be created?
« Last Edit: June 03, 2012, 10:40:57 AM by TheMessiah »
Logged

mrsnuggles

  • Lieutenant
  • **
  • Posts: 59
    • View Profile
Re: Making Planets?
« Reply #3 on: June 03, 2012, 11:56:16 AM »

you just create a sector gen file in your mod and then you set create the planets there
Logged

Upgradecap

  • Admiral
  • *****
  • Posts: 5422
  • CEO of the TimCORP
    • View Profile
Re: Making Planets?
« Reply #4 on: June 03, 2012, 12:11:45 PM »

Guess your asking on how to create a new planet from scratch?  Well, you could always take a look at the mods that do that, like the SC2 mod, or the TimCORP mod.

All you need is an planet.jpg file, an planet.json file, and the knowledge on how to add it ingame. pretty simple, huh? :D
Logged

TheMessiah

  • Captain
  • ****
  • Posts: 315
  • Captain of the Sidus Dim
    • View Profile
Re: Making Planets?
« Reply #5 on: June 03, 2012, 12:46:17 PM »

Ok, so are all those cloud and atmosphere files in the graphics/planets folder used for all planets?
Logged

Upgradecap

  • Admiral
  • *****
  • Posts: 5422
  • CEO of the TimCORP
    • View Profile
Re: Making Planets?
« Reply #6 on: June 03, 2012, 12:51:51 PM »

Ok, so are all those cloud and atmosphere files in the graphics/planets folder used for all planets?

Yes, though you don't have to create your own.
Logged

TheMessiah

  • Captain
  • ****
  • Posts: 315
  • Captain of the Sidus Dim
    • View Profile
Re: Making Planets?
« Reply #7 on: June 03, 2012, 01:35:00 PM »

Edited a planet with new image.

Thanks for the help.
Logged