@SuppressWarnings("unchecked")
public class marauders extends BaseSpawnPoint {
public boolean firstalertissued;
public boolean alive;
public String fleettype;
public marauders(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor, boolean firstalertissued, boolean alive, String fleettype) {
super(sector, location, daysInterval, maxFleets, anchor);
}
@Override
public CampaignFleetAPI spawnFleet() {
StarSystemAPI system = getSector().getStarSystem("God");
FactionAPI player = getSector().getFaction("player");
FactionAPI marauders = getSector().getFaction("marauders");
SectorEntityToken playerf = system.getEntityByName("Fleet");
CargoAPI cargoplayer = playerf.getCargo();
int reward = 0;
CampaignFleetAPI fleet = null;
if (((float) Math.random() > 0.95) && (!alive)) {
if ((float) Math.random() > 0.60) {
fleettype = "fleetsm";
} else if ((float) Math.random() > 0.25) {
fleettype = "fleetmed";
} else {
fleettype = "fleetlrg";
}
player.setRelationship(marauders.getId(), -0.01f);
SectorEntityToken mtoken;
if ((float) Math.random() > 0.5) {
mtoken = system.createToken((10000 + ((int)(Math.random() * 5000))) * -1, (10000 + ((int)(Math.random() * 5000))) * -1);
} else {
mtoken = system.createToken(10000 + ((int)(Math.random() * 5000)), 10000 + ((int)(Math.random() * 5000)));
}
fleet = getSector().createFleet("marauders", fleettype);
getLocation().spawnFleet(mtoken, 0, 0, fleet);
fleet.setPreferredResupplyLocation(mtoken);
fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 1000);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, mtoken, 1000);
Global.getSectorAPI().addMessage("SYSTEM-WIDE ALERT:", Color.red);
if (fleettype == "fleetsm") {
Global.getSectorAPI().addMessage("A small band of pirates has been detected in-system.", Color.red);
} else if (fleettype == "fleetmed") {
Global.getSectorAPI().addMessage("A medium-sized band of pirates has been detected in-system.", Color.red);
} else {
Global.getSectorAPI().addMessage("A large band of pirates has been detected in-system.", Color.red);
}
if (!firstalertissued) {
Global.getSectorAPI().addMessage("A reward will be issued to anyone who eliminates them.", Color.red);
firstalertissued = true;
}
alive = true;
}
if (fleettype == "fleetsm") {
reward = 5000;
} else if (fleettype == "fleetmed") {
reward = 8000;
} else if (fleettype == "fleetlrg") {
reward = 12000;
} else {
reward = 0;
}
SectorEntityToken marauderf;
if ((fleettype == "fleetsm")) {
marauderf = system.getEntityByName("Group ");
} else if ((fleettype == "fleetmed")){
marauderf = system.getEntityByName("Flotilla ");
} else {
marauderf = system.getEntityByName("Fleet ");
}
if (!alive){
player.setRelationship(marauders.getId(), 0);
}
if ((player.getRelationship(marauders.getId()) < -0.01f) && (marauderf == null)) {
Global.getSectorAPI().addMessage("Your actions against the pirate forces are commended.", Color.cyan);
Global.getSectorAPI().addMessage(reward + " credits have been transferred to your account.", Color.cyan);
cargoplayer.getCredits().add(reward);
}
if ((marauderf == null)) {
player.setRelationship(marauders.getId(), 0);
alive = false;
}
//Global.getSectorAPI().addMessage("HERP DERP TEST", Color.cyan);
return fleet;
}
}