Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Can I spawn a faction specific fleet?  (Read 1842 times)

MrDavidoff

  • Captain
  • ****
  • Posts: 398
    • View Profile
Can I spawn a faction specific fleet?
« on: October 02, 2013, 11:44:41 AM »

Hey guys, I was wondering- is it possible to spawn a single specific fleet from the faction fleet list in a system? And how?

(please if it IS possible post your guide as if for dummies)
Logged

Trylobot

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1170
    • View Profile
    • Github profile
Re: Can I spawn a faction specific fleet?
« Reply #1 on: October 02, 2013, 12:06:13 PM »

Code: java
SectorAPI sector = Global.getSector();
String faction_id = "MrDavidoffsFaction";
String fleet_id = "SupercoolFleetGuise";
// instantiate (reserve memory for/create) the fleet object
CampaignFleetAPI fleet = sector.createFleet( faction_id, fleet_id );
LocationAPI system = sector.getStarSystem("Corvus"); // or wherever else
SectorEntityToken station = system.getOrbitalStations().get( 0 ); // first station in list
// spawn the fleet ingame
system.spawnFleet( station, 0, 0, fleet );
Logged

MrDavidoff

  • Captain
  • ****
  • Posts: 398
    • View Profile
Re: Can I spawn a faction specific fleet?
« Reply #2 on: October 02, 2013, 10:32:56 PM »

Great!

(dummy momnet)

So I put this in the MrDavidoffsFactionSpawnPoint, right?  :-X

Thank you!

Code: java
SectorAPI sector = Global.getSector();
String faction_id = "MrDavidoffsFaction";
String fleet_id = "SupercoolFleetGuise";
// instantiate (reserve memory for/create) the fleet object
CampaignFleetAPI fleet = sector.createFleet( faction_id, fleet_id );
LocationAPI system = sector.getStarSystem("Corvus"); // or wherever else
SectorEntityToken station = system.getOrbitalStations().get( 0 ); // first station in list
// spawn the fleet ingame
system.spawnFleet( station, 0, 0, fleet );
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: Can I spawn a faction specific fleet?
« Reply #3 on: October 02, 2013, 11:20:29 PM »

You can do that from a spawn point, but you can also do it from -anywhere- (EveryFrameScript, fleetAssignment attached script, etc.) :)

So, you could write an EveryFrameScript that used the above code to spawn a fleet every frame (not advisable though!) or you could attach that code in a script that runs when a supply convoy DELIVERS_RESOURCES (where the StarSector examples display a message). It would then spawn a fleet when that supply convoy reaches that station.

You just need to put that code somewhere where it will be executed by the game engine; spawnPoints are handy and easy for this as they have the inbuilt advance() method that is called by the game engine automatically, but there is no reason you can't put the code in other places, and have it executed under different conditions.
Logged

MrDavidoff

  • Captain
  • ****
  • Posts: 398
    • View Profile
Re: Can I spawn a faction specific fleet?
« Reply #4 on: October 03, 2013, 04:52:55 AM »

Yayks.

(dummy rage)

I planned on putting it in the spawnpoint, since its also where i could determine the fleet behaviour  + got a script there, to narrow crew experince, so I thought putting it there would make less stuff redundant.

(Im really thankful for the help guys, I do expect to be comming back, when i try to actually make the thing..)

Logged