Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Damn Solar System refusing to show up (Solved!)  (Read 4032 times)

Dibuk

  • Lieutenant
  • **
  • Posts: 71
    • View Profile
Damn Solar System refusing to show up (Solved!)
« on: May 13, 2014, 10:19:18 AM »

So I've been at it, trying to fix this damn system. It's obvious I'm missing something.

The mod starts up fine (no errors), but the new system does not show up in the Hyperspace map (or in space). WHY!?

Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.InteractionDialogImageVisual;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl;
import java.awt.Color;
import java.util.List;

@SuppressWarnings("unchecked")
public class NihilGen {

public void generate(SectorAPI sector) {

StarSystemAPI system = sector.createStarSystem("Noll");
LocationAPI hyper = Global.getSector().getHyperspace();
system.setBackgroundTextureFilename("graphics/backgrounds/background4.jpg");
//system.setBackgroundTextureFilename("graphics/backgrounds/background2.png");

// create the star and generate the hyperspace anchor for this system
PlanetAPI star = system.initStar("star_neutron", // id in planets.json
1000f, // radius (in pixels at default zoom)
1500, 1500);   // location in hyperspace

system.setLightColor(new Color(45, 35, 45)); // light color in entire system, affects all entities


/*
* addPlanet() parameters:
* 1. What the planet orbits (orbit is always circular)
* 2. Name
* 3. Planet type id in planets.json
* 4. Starting angle in orbit, i.e. 0 = to the right of the star
* 5. Planet radius, pixels at default zoom
* 6. Orbit radius, pixels at default zoom
* 7. Days it takes to complete an orbit. 1 day = 10 seconds.
*/

PlanetAPI n1 = system.addPlanet(star, "Nihil", "nihil", 290, 120, 11500, 450);

PlanetAPI n2 = system.addPlanet(star, "Zenit", "cryovolcanic", 5, 180, 2500, 100);
PlanetAPI n21 = system.addPlanet(n2, "Zenit Minor", "rocky_unstable", 35, 85, 800, 25);

/*
* addAsteroidBelt() parameters:
* 1. What the belt orbits
* 2. Number of asteroids
* 3. Orbit radius
* 4. Belt width
* 6/7. Range of days to complete one orbit. Value picked randomly for each asteroid.
*/



/*
* addRingBand() parameters:
* 1. What it orbits
* 2. Category under "graphics" in settings.json
* 3. Key in category
* 4. Width of band within the texture
* 5. Index of band
* 6. Color to apply to band
* 7. Width of band (in the game)
* 8. Orbit radius (of the middle of the band)
* 9. Orbital period, in days
*/

system.addRingBand(n1, "misc", "rings2", 256f, 2, Color.white, 256f, 200, 20f);
system.addRingBand(n1, "misc", "rings2", 256f, 2, Color.white, 256f, 400, 40f);
system.addRingBand(n1, "misc", "rings3", 256f, 2, Color.white, 256f, 800, 60f);



JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("Unstable Jump Point");
OrbitAPI orbit = Global.getFactory().createCircularOrbit(n1, 0, 500, 30);
jumpPoint.setOrbit(orbit);
jumpPoint.setRelatedPlanet(n1);
jumpPoint.setStandardWormholeToHyperspaceVisual();
system.addEntity(jumpPoint);


FactionAPI nihil = sector.getFaction( "nihil" );

nihil.setRelationship( "hegemony",     -1 );
nihil.setRelationship( "tritachyon",   -1 );
nihil.setRelationship( "pirates",      -1 );
nihil.setRelationship( "independent",  -1 );
nihil.setRelationship( "nomads",       -1 );
nihil.setRelationship( "junk_pirates", -1 );
nihil.setRelationship( "sindrian_diktat", -1);
nihil.setRelationship( "player",       -1 );




// SectorEntityToken station = system.addOrbitalStation(a1, 45, 300, 50, "Command & Control", "sindrian_diktat");
// initStationCargo(station);

// example of using custom visuals below
// a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
// station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));

// generates hyperspace destinations for in-system jump points
system.autogenerateHyperspaceJumpPoints(true, true);

//NihilSpawnPoint patrolSpawn = new NihilSpawnPoint(sector, system, 5, 3, n1);
//system.addScript(patrolSpawn);
//for (int i = 0; i < 5; i++)
// patrolSpawn.spawnFleet();

//NihilSpawnPoint garrisonSpawn = new NihilSpawnPoint(sector, system, 1, 2, n1);
//system.addSpawnPoint(Nihilspawn);
//Nihilspawn.spawnFleet();

   // NihilSpawnPoint NihilSpawn = new NihilSpawnPoint(sector, system, 1, 2, n1);
//system.addSpawnPoint(NihilSpawn);
//Nihilspawn.spawnFleet();

NihilSpawnPoint nihilSpawn = new NihilSpawnPoint( sector, system, 1, 2, n1 );
system.addSpawnPoint( nihilSpawn );

  // for (int i = 0; i < 3; i++) nihilSpawn.spawnFleet();


// system.addScript(new IndependentTraderSpawnPoint(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), station));
        
sector.registerPlugin(new CoreCampaignPluginImpl());
}


// private void initStationCargo(SectorEntityToken station) {
// CargoAPI cargo = station.getCargo();
// addRandomWeapons(cargo, 5);
//
// cargo.addCrew(CrewXPLevel.VETERAN, 20);
// cargo.addCrew(CrewXPLevel.REGULAR, 500);
// cargo.addMarines(200);
// cargo.addSupplies(1000);
// cargo.addFuel(500);
//
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "heron_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "heron_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "monitor_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "monitor_Hull"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
// cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
// }

// private void addRandomWeapons(CargoAPI cargo, int count) {
// List weaponIds = Global.getSector().getAllWeaponIds();
// for (int i = 0; i < count; i++) {
// String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
// int quantity = (int)(Math.random() * 4f + 2f);
// cargo.addWeapons(weaponId, quantity);
// }
}



Code is full of placeholders and things commented as of trying to find the damn problem.

ples halp.
« Last Edit: May 15, 2014, 11:24:33 AM by Dibuk »
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Damn Solar System refusing to show up
« Reply #1 on: May 13, 2014, 10:27:52 AM »

Ironclads` initialization of 'Grant' system in SectorGen.java. You need to add a similar one for every new system you make.

import data.scripts.world.ISA.Grant;

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #2 on: May 13, 2014, 10:35:27 AM »

Did you add NihilGen to generators.csv/are you calling it in your ModPlugin.onNewGame()? It's possible that it's not even running.
Logged

Dibuk

  • Lieutenant
  • **
  • Posts: 71
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #3 on: May 13, 2014, 10:44:27 AM »

Damn you guys are fast.

Did you add NihilGen to generators.csv/are you calling it in your ModPlugin.onNewGame()? It's possible that it's not even running.


I had actually, not done that but now the generators looks like this:
Code
"className"
"data.scripts.world.NihilGen"
and should be fine, still not showing up though.

The plugin should work fine. Even if it's messy (NullGen is not done yet, will probably be a sister-mod)
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import data.scripts.world.NihilGen;

public class NihilModPlugin extends BaseModPlugin
{
    private static void initnihil()
    {
        try
        {
            Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.NullGen");
        }
        
        catch (ClassNotFoundException ex)
        {
            new NihilGen().generate(Global.getSector());
        }
    }

    @Override
    public void onNewGame()
    {
        initnihil();
    }
}

Ironclads` initialization of 'Grant' system in SectorGen.java. You need to add a similar one for every new system you make.

import data.scripts.world.ISA.Grant;

Eh? You need to import the system to the *Gen.java?

« Last Edit: May 13, 2014, 10:46:30 AM by Dibuk »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #4 on: May 13, 2014, 10:58:41 AM »

You only need it in one of the places - either in generators.csv (legacy method) or in ModPlugin.onNewGame() (preferred). Otherwise it'll run twice and generate duplicate entities.

As to why it's not working, hmm. It looks right, so you might want to do something to make sure it's actually running. Logging/connecting via debugger/that type of thing.
Logged

Dibuk

  • Lieutenant
  • **
  • Posts: 71
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #5 on: May 13, 2014, 11:16:43 AM »

I have a sneaking suspition that NihilGen.java is not running... I guess I'll get try to get this thing working more tomorrow (6hours is enough today...)

If anyone want to have a look at the magical invisible solar system, be my guest.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #6 on: May 13, 2014, 11:47:58 AM »

Aha - you need to point to your mod plugin from mod_info.json. Example/doc here: http://fractalsoftworks.com/forum/index.php?topic=4760.0
Logged

Dibuk

  • Lieutenant
  • **
  • Posts: 71
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #7 on: May 14, 2014, 09:37:50 AM »

Aha - you need to point to your mod plugin from mod_info.json. Example/doc here: http://fractalsoftworks.com/forum/index.php?topic=4760.0

I could kiss you.  ;D

This is what happens when you don't mod on a game for two years, things change.

Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #8 on: May 14, 2014, 11:31:20 AM »

Glad that's all it was, and also to see you back around these parts :)
Logged

Dibuk

  • Lieutenant
  • **
  • Posts: 71
    • View Profile
Re: Damn Solar System refusing to show up
« Reply #9 on: May 15, 2014, 11:23:51 AM »

Thank you! I'm happy to see you going strong after all this time!
Logged