Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Spawn point help  (Read 2489 times)

MindsEye

  • Lieutenant
  • **
  • Posts: 91
    • View Profile
Spawn point help
« on: March 23, 2013, 06:38:22 AM »

So I have been fiddling with the star wars mod. Finally got the empire sb up and stocked with wings.There is a specific defense fleet I want to create with the sole purpose of guarding the station.Everything I do seem to not work.I have copied and pasted what others have done and from the tutorials with 0 success.I guess what I need is someone to show me exactly what I need to do to create a fleet and then have it always spawn at the station and stay there.
Logged

RawCode

  • Admiral
  • *****
  • Posts: 511
    • View Profile
Re: Spawn point help
« Reply #1 on: March 23, 2013, 08:11:50 AM »

post your code, we have telepatic server ddosed and can't use it right now.
Logged

MindsEye

  • Lieutenant
  • **
  • Posts: 91
    • View Profile
Re: Spawn point help
« Reply #2 on: March 23, 2013, 08:22:41 AM »

Ok so I made a spawn point for this one fleet I was trying to make.I did alot of experimentation so it may be off but I did try copied versions from others.


Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

public class sw_empiredefensefleetSpawnPoint extends BaseSpawnPoint
{
    public sw_empiredefensefleetSpawnPoint(SectorAPI sector, LocationAPI location,
            float daysInterval, int maxFleets, SectorEntityToken anchor)
    {
        super(sector, location, daysInterval, maxFleets, anchor);
    }

      @Override
   protected CampaignFleetAPI spawnFleet() {
      String type = null;
      float r = (float) Math.random();
      if (r > .6f) {
         type = "defensefleet";
      } else if (r > 0.25f) {
         type = "defensefleet";
      } else if (r > 0.10f) {
         type = "defensefleet";
      } else {
         type = "defensefleet";
      }
CampaignFleetAPI fleet = getSector().createFleet("sw_empire", type);
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
 
 fleet.setPreferredResupplyLocation(getAnchor());


if (type.equals("defensefleet")) {
         fleet.addAssignment(FleetAssignment.DEFEND_LOCATION,  getAnchor(), 10);
         fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
      }
      
      return fleet;
   }

}




« Last Edit: March 23, 2013, 08:25:41 AM by MindsEye »
Logged

RawCode

  • Admiral
  • *****
  • Posts: 511
    • View Profile
Re: Spawn point help
« Reply #3 on: March 24, 2013, 12:50:47 AM »

you copy from wrong location, check HegemonySDFSpawnPoint, it does exactly what you want.
Logged

MindsEye

  • Lieutenant
  • **
  • Posts: 91
    • View Profile
Re: Spawn point help
« Reply #4 on: March 24, 2013, 07:40:38 AM »

Still having trouble.What am I missing?

Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

import data.scripts.world.BaseSpawnPoint;

@SuppressWarnings("unchecked")
public class sw_EmpireSDFSpawnPoint extends BaseSpawnPoint {

private final SectorEntityToken station;


public sw_EmpireSDFSpawnPoint(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor, SectorEntityToken station) {
super(sector, location, daysInterval, maxFleets, anchor);
this.station = station;
}


@Override
public CampaignFleetAPI spawnFleet() {
//if ((float) Math.random() < 0.75f) return null;
String type = "defensefleet";

CampaignFleetAPI fleet = getSector().createFleet("sw_empire", type);
getLocation().spawnFleet(getAnchor(), 0, 0, fleet);

fleet.setPreferredResupplyLocation(station);

fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, empirehq, 100000);

return fleet;
}

}






Logged

RawCode

  • Admiral
  • *****
  • Posts: 511
    • View Profile
Re: Spawn point help
« Reply #5 on: March 25, 2013, 01:27:15 AM »

after you created your spawnpoint code you must create runtime object and register it inside core eventbus for it to actually execute

corvus.java lines from 45 to 48 register vanilla HegemonySDFSpawnPoint inside eventbus:

Code
		SectorEntityToken token = system.createToken(0, 15000);
HegemonySDFSpawnPoint sdfSpawn = new HegemonySDFSpawnPoint(sector, system, 30, 1, token, YOUR STATION);
system.addSpawnPoint(sdfSpawn);
spawnSDF(sector, system, YOUR STATION);
Logged

MindsEye

  • Lieutenant
  • **
  • Posts: 91
    • View Profile
Re: Spawn point help
« Reply #6 on: March 25, 2013, 05:34:47 AM »

ok added that in with a no go.Even added that second part still doesnt work.

Code
SectorEntityToken token = system.createToken(0, 15000);
sw_EmpireSDFSpawnPoint sdfSpawn = new sw_EmpireSDFSpawnPoint(sector, system, 30, 1, token, empirehq);
system.addSpawnPoint(sdfSpawn);
spawnsdf(sector, system, empirehq);

private void spawnSDF(SectorAPI sector, StarSystemAPI system, SectorEntityToken location) {
CampaignFleetAPI fleet = sector.createFleet("sw_empire", "defensefleet");
system.spawnFleet(location, -500, 200, fleet);

fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, empirehq, 1000000);
fleet.setPreferredResupplyLocation(location);
Logged