// the "package" is the folder it's in, pretty self-explanatory
package data.scripts.world;
// you have to import anything that's not in the package that you want to use
// we need a lot of stuff to spawn a supply fleet and add ships to it
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
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 com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import data.scripts.world.BaseSpawnPoint;
// btw, i copied this almost entirely from the existing scripts in the vanilla game and then tweaked it until it served my purposes
// this is essentially how i do everything, and unless you're a coding god it is what i would reccommend doing yourself
@SuppressWarnings("unchecked")
public class BISOSpawnPoint extends BaseSpawnPoint {
// basic setup stuff, initialize a convoyDestination variable
private final SectorEntityToken convoyDestination;
// ...and the class for the whole script
public BISOSpawnPoint(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor,
SectorEntityToken convoyDestination) {
super(sector, location, daysInterval, maxFleets, anchor);
this.convoyDestination = convoyDestination;
}
@Override
protected CampaignFleetAPI spawnFleet() {
// first things first, create a tritachyon supply fleet
// the faction has to line up with a faction that exists, and the fleet has to line up with a fleet that exists for that faction
// so if you wanted to change that to "Advent" and "Halcyon Carrier Delivery Fleet" or w/e you'd need to first create an Advent
// faction file and a halcyon carrier delivery fleet entry within it
CampaignFleetAPI fleet = getSector().createFleet("tritachyon", "supplyfleet");
// then we spawn the fleet we just created
getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
// addShips is a function that we'll define later in this file
// it's what we're going to use to add the Halcyon Carrier to a tri-tachyon supply fleet
// (which obviously doesn't contain one by default)
addShips(fleet);
// we're also going to add enough crew and supplies to the fleet for it to be able to field the halcyon, heh
CargoAPI cargo = fleet.getCargo();
cargo.addCrew(CrewXPLevel.VETERAN, 4000);
cargo.addSupplies(5000);
// createDockedScripts is a function that we'll define later in this file
// we're going to use it to display a message when the supply fleet docks with the station
Script dockScript = null;
dockScript = createDockedScript(fleet);
// we're also going to tell the fleet what to do so it doesn't just wander around lost
fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000, dockScript);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
return fleet;
}
private Script createDockedScript(final CampaignFleetAPI fleet) {
return new Script() {
public void run() {
if (fleet.isInCurrentLocation()) {
Global.getSector().addMessage("The Tri-Tachyon long distance tech trading expedition has docked");
// this is pretty self-explanatory, if the player's fleet is in Corvus when the halcyon supply fleet docks it displays a message
}
}
};
}
private void addShips(CampaignFleetAPI fleet) {
for (int i = 0; i < 4; i++) { // this line is a fancy way of saying "do the following 4 times"
FleetMemberAPI wasp = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "wasp_wing");
fleet.getFleetData().addFleetMember(wasp);
// so we just added 4 Wasp wings to the fleet (to escort the Halcyon, since it IS a carrier)
}
for (int i = 0; i < 2; i++) { // this line is a fancy way of saying "do the following 2 times"
FleetMemberAPI xyphos = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "xyphos_wing");
fleet.getFleetData().addFleetMember(xyphos);
// so we just added 2 Xyphos wings to the fleet (to escort the Halcyon, since it IS a carrier)
}
FleetMemberAPI activeC1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "C1_S");
fleet.getFleetData().addFleetMember(activeC1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)
FleetMemberAPI mothballedC1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "C1_S");
fleet.getFleetData().addFleetMember(mothballedC1);
mothballedC1.getRepairTracker().setMothballed(true);
// and last but not least, one mothballed Halcyon to be dropped off at the station! :)
FleetMemberAPI activeB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "B1_S");
fleet.getFleetData().addFleetMember(activeB1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)
FleetMemberAPI mothballedB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "B1_S");
fleet.getFleetData().addFleetMember(mothballedB1);
mothballedB1.getRepairTracker().setMothballed(true);
FleetMemberAPI activeD1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "D1_S");
fleet.getFleetData().addFleetMember(activeD1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)
FleetMemberAPI mothballedD1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "D1_S");
fleet.getFleetData().addFleetMember(mothballedD1);
mothballedD1.getRepairTracker().setMothballed(true);
FleetMemberAPI activeR1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB1_S");
fleet.getFleetData().addFleetMember(activeR1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)
FleetMemberAPI mothballedRB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB1_S");
fleet.getFleetData().addFleetMember(mothballedRB1);
mothballedRB1.getRepairTracker().setMothballed(true);
FleetMemberAPI mothballedRB2 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB2");
fleet.getFleetData().addFleetMember(mothballedRB2);
mothballedRB2.getRepairTracker().setMothballed(true);
FleetMemberAPI mothballedX1 = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "X1_variant_wing");
fleet.getFleetData().addFleetMember(mothballedX1);
mothballedX1.getRepairTracker().setMothballed(true);
FleetMemberAPI mothballedRA1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RA1");
fleet.getFleetData().addFleetMember(mothballedRA1);
mothballedRA1.getRepairTracker().setMothballed(true);
}
}