Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: Campaign API function and what they do.  (Read 16668 times)

jocan2003

  • Lieutenant
  • **
  • Posts: 96
    • View Profile
Campaign API function and what they do.
« on: February 19, 2012, 09:55:07 AM »

While playing with my new project i had to fidle up with some function calls and figure out what they do, im sharing my findings.

SectorEntityToken *name* = system.addPlanet(parent, planetname, planettype, position, size, distancetoparent, orbitspeed)

Parent: Object on what the planet/moon/asteroidbelt will orbit around
Planetname: Name shown in game
planettype: any of (gas_giant, ice_giant, lava, desert, frozen, barren, toxic, jungle, terran, arid, cryovolcanic ) capsensitive
position: position at the creation 0 = right, 90 = 180 = left, 90 = up and 270 = down
size: 0 and you better get a magnifiying glass to find it, 1000 YOU will feel small like real small
distancetoparent: usually 1500 to 3000 between planet *orbit* moon is more like 300-500 between moon orbits
orbitspeed: 0 game hangup (Keep processing orbit? i dont know just no crash) 1000 idle or very slow.

So far its the one i played with, as i find more i will post more, if you found something share it up!
Logged

Paul

  • Commander
  • ***
  • Posts: 159
    • View Profile
Re: Campaign API function and what they do.
« Reply #1 on: February 19, 2012, 11:52:23 AM »

Spawn points work like so:

You create a file called and put it in data/scripts/world, and in there you put all the information about how the spawn will work. You can even influence things other than the spawn in this - like say change the inventory of a station when a fleet despawns/docks at it. Then in a gen file (sectorgen or a custom gen file you make) you call up this file to create the spawn point, like so:

new NameOfSpawnPointFile(sector, system, daysinterval, maxfleets, spawnlocation);

All that information relates to the data in the spawn point file, so you could customize it. The spawn location is referred to as the anchor, and most ships are set to return to that point to despawn. It can be a planet, station, or simply a fixed point in space. The convoy spawns have a destination in addition to that. To actually add the point you just go

system.addSpawnPoint(new nameofspawnpointfile(sector, system, daysinterval, maxfleets, spawnlocation, destination));

Or if you wanted you could set the spawn point up first and then add it like this:

NameOfSpawnPointFile Spawn = new NameOfSpawnPointFile(sector, system, daysinterval, maxfleets, spawnlocation);
system.addSpawnPoint(Spawn);


So for a full example this is how I added the station and convoy spawn to the game for the TT station:

SectorEntityToken station2 = system.addOrbitalStation(corvusV, 45, 300, 50, "Orbital Headquarters", "tritachyon");
Here I add a station, referring to it simply as station2. Orbiting Corvus IV (reference to it is mislabeled CorvusV in default sector gen for some reason) at angle 45, radius 300, with a 50 day orbit, named Orbital Headquarters, and belonging to the tritachyon faction.

token = system.createToken(15000, -15000);
Here I create a invisible token in space at 15000,-15000 (which corresponds to the bottom right of the system map)

system.addSpawnPoint(new TConvoySpawnPoint(sector, system, 14, 1, token, station2));
And finally here I'm adding the spawn point, which references a file named TConvoySpawnPoint, with a 14 day interval, a 1 max limit for parties, at the location specified in token, with a destination set as station2.

Then inside the TConvoySpawnPoint file it spawns a fleet at the location, gives it cargo, and tells it to go deliver supplies to the station then return to the anchor location to despawn.
Logged

icepick37

  • Admiral
  • *****
  • Posts: 1788
  • Go.
    • View Profile
Re: Campaign API function and what they do.
« Reply #2 on: February 25, 2012, 08:40:32 PM »

Thanks for this. It helped me immensely as well.  :D
Logged
“I [may] not agree with a word that you say, but I will defend to the death your right to say it”
- Voltaire

WarStalkeR

  • Captain
  • ****
  • Posts: 343
  • Per Aspera Ad Astra!
    • View Profile
Re: Campaign API function and what they do.
« Reply #3 on: April 09, 2012, 09:02:25 AM »

From Alex:
Quote
Here's the function signature:
   void addAsteroidBelt(SectorEntityToken focus, int numAsteroids, float orbitRadius, float width, float minOrbitDays, float maxOrbitDays);

The width is the width of the belt. The last two parameters affect how fast the asteroids move - i.e., how many days a full orbit takes.
« Last Edit: April 09, 2012, 09:21:50 AM by WarStalkeR »
Logged

"Happiness for everybody, freely, and let no one to leave unhappy!" (c) Strugatsky Brothers
Independent Defense Force is here! And they already in Sector Xplo.

echo66

  • Ensign
  • *
  • Posts: 5
    • View Profile
Re: Campaign API function and what they do.
« Reply #4 on: April 09, 2012, 12:30:33 PM »

Some questions:

1) What about the player spawnpoints? How do i define them?

2) What java classes do we have in order to implement UI components of our own?

3) Does the game engine load all the solar systems declared in the Sector object or can i add them dynamically? I ask this because, as said in one of the sticky threads, this game makes use of Janino.

Cheers.
Logged

echo66

  • Ensign
  • *
  • Posts: 5
    • View Profile
Re: Campaign API function and what they do.
« Reply #5 on: April 10, 2012, 11:46:03 AM »

bump
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Campaign API function and what they do.
« Reply #6 on: April 10, 2012, 11:52:36 AM »

1) Hardcoded for now.

2) Can't do it, and probably won't be able to down the line, either. Except for possibly in very specific cases.

3) There's only one solar system. To be honest, I don't understand the question. The stuff defined in SectorGen/Corvus.java *is* dynamic, in some sense.
Logged

echo66

  • Ensign
  • *
  • Posts: 5
    • View Profile
Re: Campaign API function and what they do.
« Reply #7 on: April 10, 2012, 02:50:37 PM »

Thanks for the explanation, Alex.

Well, about the third question, the objective was to add, dynamically, more star systems to the game. But, if i can't even define player spawn points, it's useless.
Logged

echo66

  • Ensign
  • *
  • Posts: 5
    • View Profile
Re: Campaign API function and what they do.
« Reply #8 on: April 12, 2012, 09:48:32 AM »

Btw, just out of curiosity, what is the real reason for you not giving access to UI components, to use inside a mod?? Is it just hardcoded and you dont have the time to reengineer it or do you want to limit the kind of mods that will be available?
Logged

echo66

  • Ensign
  • *
  • Posts: 5
    • View Profile
Re: Campaign API function and what they do.
« Reply #9 on: April 15, 2012, 03:52:39 PM »

Hmmm did i ask something that isn't supposed to be answered?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Campaign API function and what they do.
« Reply #10 on: April 15, 2012, 04:38:26 PM »

Btw, just out of curiosity, what is the real reason for you not giving access to UI components, to use inside a mod?? Is it just hardcoded and you dont have the time to reengineer it or do you want to limit the kind of mods that will be available?

The amount of effort it would take, yes.
« Last Edit: April 15, 2012, 04:43:00 PM by Alex »
Logged