Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: fatal null when convoy spawns *solved*  (Read 3606 times)

TheHappyFace

  • Admiral
  • *****
  • Posts: 1168
  • The critic
    • View Profile
fatal null when convoy spawns *solved*
« on: November 06, 2012, 07:21:13 AM »

so been trying to put in a convoy for my station ,but cant get it to deliver the resources cause since i added that line it keeps giving fatal null when it spawns

here is the convoy spawn
Spoiler
Quote

public class hpconvoySpawnPoint extends BaseSpawnPoint {

   private final SectorEntityToken convoyDestination;

   public hpconvoySpawnPoint(SectorAPI sector, LocationAPI location,
                     float daysInterval, int maxFleets, SectorEntityToken anchor) {
      super(sector, location, daysInterval, maxFleets, anchor);
   }

   @Override
   protected CampaignFleetAPI spawnFleet() {
      //if ((float) Math.random() < 0.5f) return null;
      
      String type = null;
      float r = (float) Math.random();
      if (r > .8f) {
         type = "defencefleet";
      } else {
         type = "defencefleet";
      }
      
      CampaignFleetAPI fleet = getSector().createFleet("happy_drunk", type);
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
      
      
      if (type.equals("defencefleet")) {
         CargoAPI cargo = fleet.getCargo();

            cargo.addWeapons("annihilatorpod", 10);
            cargo.addWeapons("harpoon", 5);
            cargo.addWeapons("heavymg", 5);
            cargo.addWeapons("arbalest", 35);
            cargo.addWeapons("heavyac", 10);
            cargo.addWeapons("dualflak", 5);
            cargo.addWeapons("heavyblaster", 5);
            cargo.addWeapons("lightdualac", 5);
            cargo.addWeapons("lightag", 5);
            cargo.addWeapons("lightneedler", 5);
            cargo.addWeapons("heavymauler", 5);
            cargo.addWeapons("gravitonbeam", 5);
            cargo.addWeapons("hellbore", 5);
            cargo.addWeapons("cyclone", 2);
            cargo.addWeapons("pilum", 5);
            cargo.addWeapons("taclaser", 5);
            cargo.addWeapons("pulselaser", 5);
            cargo.addWeapons("heavyburst", 5);
            cargo.addWeapons("hil", 3);
            cargo.addWeapons("hveldriver", 5);
            cargo.addWeapons("reaper", 5);

            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_nomad_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_phoenix_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_phoenix_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_piker_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_piker_Hull", null);


            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "firefly_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "firefly_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);

            cargo.addCrew(CrewXPLevel.ELITE, 25);
            cargo.addCrew(CrewXPLevel.VETERAN, 250);
            cargo.addCrew(CrewXPLevel.REGULAR, 500);

            cargo.addCrew(CrewXPLevel.GREEN, 500);
            cargo.addSupplies(630);
            cargo.addFuel(500);
      
      fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000);
      fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
      }


      return fleet;
   }
}
[close]

its n the gen file so you got the trust me all the things at the beginning are there and complete.


*solved!!!*
« Last Edit: November 07, 2012, 10:21:12 AM by TheHappyFace »
Logged
Fractalsoftworks limited edition ban hammer.

ValkyriaL

  • Admiral
  • *****
  • Posts: 2145
  • The Guru of Capital Ships.
    • View Profile
Re: fatal null when convoy spawns
« Reply #1 on: November 06, 2012, 10:19:51 AM »

Here is my convoy file, see anything missing in yours?  :D i can see it already at several spots

Spoiler
Quote
package data.scripts.world;


//And yet again with this, make sure you have the imports correct
import java.util.List;

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.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.FleetMemberType;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;


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

   //All of this is required for the script to work. So just copy this in
   private final SectorEntityToken convoyDestination;

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

   //This line is for if you're wanting incremental convoys to add more stuff. For example if you want to simulate an arms race, or just have a bit of pacing with the way things are going
   private static int convoyNumber = 0;
  
   @Override
   protected CampaignFleetAPI spawnFleet() {
      String type = null;

      //For creating different kinds of convoy, similar to the Hegemony ones, with different resources depending on convoy. Not required, but still worth knowing about
      float r = (float) Math.random();
      if (r > .6f) {
         type = "resupplyfleet";
      } else if (r > .4f) {
         type = "fuelfleet";
      } else {
         type = "personnelfleet";
      }    
      //Creates the convoy
      CampaignFleetAPI fleet = getSector().createFleet("nephalem", type);
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
      

      //Changes the delivered goods depending on the convoy type
      if (type.equals("resupplyfleet")) {
         //In the case of a Supply convoy, delivers 5 random weapons from the list to the station
         CargoAPI cargo = fleet.getCargo();
         addRandomWeapons(cargo, 5);
      }      
      else if (type.equals("personnelfleet")) {
         CargoAPI cargo = fleet.getCargo();
         cargo.addCrew(CrewXPLevel.ELITE, 175);
            cargo.addCrew(CrewXPLevel.VETERAN, 375);
     }      
      
      //Line used for determining what random ships from the list of defined ships are actually added to the station on the delivery run
      addRandomShips(fleet.getCargo(), (int) (Math.random() * 4f));
      
      //Message for when the supply convoy has entered the system.
      Script script = null;
      if (type.equals("resupplyfleet") || type.equals("fuelfleet") || type.equals("personnelfleet")) {
         script = createArrivedScript();
         Global.getSectorAPI().addMessage("A convoy belonging to the nephalem industries has arrived in the system");
      }
      //Tells the fleet to go to the station, then afterwards return to the point and despawn. To simulate delivering to the station, then moving to another system
      fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000, script);
      fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
      
      return fleet;
   }
  
   //Message for when the supply convoy has successfully delivered its cargo
   private Script createArrivedScript() {
      return new Script() {
         public void run() {
            Global.getSectorAPI().addMessage("The convoy has delivered new supplies to the nephalem starbase");
         }
      };
   }
  
   //Determining random weapons to add to the station from the list at the end
   private void addRandomWeapons(CargoAPI cargo, int count) {
      List weaponIds = getSector().getAllWeaponIds();
      for (int i = 0; i < count; i++) {
         String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
         int quantity = (int)(Math.random() * 4f + 2f);
         cargo.addWeapons(weaponId, quantity);
      }
   }
  
   //Determining random ships to add to the station from the list at the end. Including fighter wings
   private void addRandomShips(CargoAPI cargo, int count) {
      List weaponIds = getSector().getAllWeaponIds();
      for (int i = 0; i < count; i++) {
         if ((float) Math.random() > 0.4f) {
            String wing = (String) wings[(int) (wings.length * Math.random())];
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, wing, null);
         } else {
            String ship = (String) ships[(int) (ships.length * Math.random())];
            cargo.addMothballedShip(FleetMemberType.SHIP, ship, null);
         }
      }
   }

   //These three blocks are for defining the different types of ships, fighter wings and weapons the station stocks. No repetition of types is needed for this part.
   private static String [] ships = {
                           "siegfried_Hull",
                     "kyou_Hull",
                     "phoenix_Hull",
                     "nexus_Hull",
                     "kurosaki_Hull",
                     "kishida_Hull",
                     "hawk_Hull",
                     "gintama_Hull",
                     "altima_Hull",
                     "shibusen_Hull",
                     "shinda_Hull",
                     "taiyou_Hull",
                     "whirlwind_Hull",
                     "tornado_Hull",
                     "darius_Hull",

                           };

   private static String [] wings = {
                           "masaki_wing",
                           "aeon_wing",   
                           "evony_wing",
                           "code_wing",      
                    
                           };
  
   private static String [] weapons = {
                           "laserpdcannon",
                     "duallaserpdcannon",
                     "autopulse",
                     "autoblaster",
                     "pulsemg",
                     "hydra",      
                     "plasma",   
                     "sabotpod",
                     "harpoonpod",
                     "sabotpod",
                     "particle_cannon",
                     "pdburst",
                     "hlc",
                     "vanguard_single",
                    
                           };
                          
}
[close]

And here is the gen file

Spoiler
Quote
//This section details the folder in which this will be. If you have  a Corvus folder in world, then it'd be package.data.scripts.world.corvus for example
package data.scripts.world;

//Importing required libraries and such. Be sure to have all the required imports
import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;

import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

@SuppressWarnings("unchecked")
public class nephalemGen implements SectorGeneratorPlugin {

   public void generate(SectorAPI sector) {

            //These lines are getting data from vanilla Starfarer's Corvus System. Critical for locations and such

            //Getting the system itself
            StarSystemAPI system = sector.getStarSystem("Corvus");
            
            //In this one, it's getting the abandoned station orbiting Corvus I. This line can be done with Stars, planets or stations. Basically any fixed object in a star system it will get by name in quotations
            SectorEntityToken stock = system.getEntityByName("Abandoned Storage Facility");
         SectorEntityToken corvustoken = system.getEntityByName("Corvus");
         SectorEntityToken token = system.createToken(-15000, 15000);

            //Creating a token in the system. Doesn't do much except act as a reference point for getting the planet placement right for any added
            //SectorEntityToken <token> = system.createToken(0, 0);

            //Creates a new planet. <planet type> can be gas_giant, ice_giant, lava, frozen, barren, toxic, jungle, terran, desert, arid, or cryovolcanic. <angle> refers to the planet's bearing dependant on <token>. 0 would be to the “east”, with increasing values                going anti-clockwise
            SectorEntityToken carius = system.addPlanet(corvustoken, "Carius", "ice_giant", 90, 300, 8500, 225);
        
            //If you so desire, you can even make an asteroid belt for yourself. <orbit-parent> refers to the entity that the belt orbits
            system.addAsteroidBelt (carius, 250, 750, 250, 10, 15);
            
            //This is where you create the station for your faction, or just another station for an existing faction, if you so please.
            SectorEntityToken nephalemstarbase = system.addOrbitalStation(carius, 90, 500, 15, "Starbase", "nephalem");
         SectorEntityToken starbasetoken = system.getEntityByName("Starbase");
            
            //Creates a spawn point for the faction's convoys. The combat/reconnaissance fleets will be dealt with in the next line
            system.addSpawnPoint (new nephalemConvoySpawnPoint(sector, system, 10, 1, token, starbasetoken));
            
            //Creates a spawn point for the factions combat/reconnaissance fleets. Just a repetition of before, but still important, as the values will likely be different.
            nephalemSpawnPoint nephalemSpawn = new nephalemSpawnPoint(sector, system, 5, 10, starbasetoken);
            
            //Actually adding the combat/reconnaissance spawn
            system.addSpawnPoint(nephalemSpawn);
            
            //This for example, creates 4 fleets from the <Faction>Spawn.java specs. More on that when the time comes
            for (int i = 0; i < 3; i ++) nephalemSpawn.spawnFleet();
            
            //Getting the cargo of the station. Vital for adding more cargo and ships to the station
            CargoAPI nephalemcargo = nephalemstarbase.getCargo();
            
            
            //Adding weapons to the station's initial inventory.
            nephalemcargo.addWeapons("harpoon", 5);
         nephalemcargo.addWeapons("sabot", 5);
         nephalemcargo.addWeapons("pulsemg", 20);
         nephalemcargo.addWeapons("pulsemg", 20);
         nephalemcargo.addWeapons("autopulse", 10);
         nephalemcargo.addWeapons("plasma", 5);
         nephalemcargo.addWeapons("hlc", 4);
         nephalemcargo.addWeapons("hydra", 3);
         nephalemcargo.addWeapons("pulselaser", 20);
         nephalemcargo.addWeapons("particle_cannon", 5);
         nephalemcargo.addWeapons("pdburst", 40);
         nephalemcargo.addWeapons("laserpdcannon", 40);
         nephalemcargo.addWeapons("duallaserpdcannon", 20);
         nephalemcargo.addWeapons("autoblaster", 20);
         nephalemcargo.addWeapons("vanguard_single", 20);
         nephalemcargo.addWeapons("vanguard_single", 20);
                     
            //Adding misc. cargo to the station's inventory. In this instance it is regular crew and supplies
            nephalemcargo.addCrew(CrewXPLevel.GREEN, 250);
         nephalemcargo.addCrew(CrewXPLevel.REGULAR, 250);
         nephalemcargo.addCrew(CrewXPLevel.VETERAN, 100);
         nephalemcargo.addCrew(CrewXPLevel.ELITE, 50);
         nephalemcargo.addMarines(250);
            nephalemcargo.addSupplies(500);
         nephalemcargo.addFuel(250);
            
            //Adding a ship to the station's inventory. Note that you'll have to repeat lines if you're wanting multiple of the same hull type
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "kishida_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "gintama_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "hawk_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "shibusen_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "shinda_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "taiyou_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "whirlwind_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "whirlwind_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "tornado_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "darius_Hull", null);
         nephalemcargo.addMothballedShip(FleetMemberType.SHIP, "darius_Hull", null);


         
         
            
            //Fighter wings are slightly different, but it's the same principle
         nephalemcargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "code_wing", null);
         nephalemcargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "code_wing", null);


            
               FactionAPI nephalem = sector.getFaction("nephalem");
            nephalem.setRelationship("hegemony", -1);
         nephalem.setRelationship("tritachyon", 1);
         nephalem.setRelationship("pirates", -1);
            nephalem.setRelationship("independent", -1);
            nephalem.setRelationship("player", 0);
         nephalem.setRelationship("lotus_pirates", -1);
         nephalem.setRelationship("interstellarFederation", -1);
         nephalem.setRelationship("shadow_industry", 1);
         nephalem.setRelationship("nomads", -1);
         nephalem.setRelationship("neutrinocorp", 1);
         nephalem.setRelationship("junk_pirates", -1);
         nephalem.setRelationship("syndicate_asp",-1);
         nephalem.setRelationship("antediluvian", -1);
         nephalem.setRelationship("ghost", -1);
         nephalem.setRelationship("hekmatyar", -1);
         }
}
[close]

or maybe yours works without the imports and directory path and so on? XD
« Last Edit: November 06, 2012, 10:30:13 AM by ValkyriaL »
Logged

TheHappyFace

  • Admiral
  • *****
  • Posts: 1168
  • The critic
    • View Profile
Re: fatal null when convoy spawns
« Reply #2 on: November 07, 2012, 02:36:24 AM »

well i know that is a way to do it ,but i want some changes to it.
1. I just want one type of convoy that carries all resources
2. I dont want random weapons

ehm the lines that add data from corvus etc. are in there just not in the part i pasted (put everything in one file).

thanks anyway i will go through the file again might see something important missing.

maybe it helps saying that it only crashes when i add the line that delivers the resources which might crash because i didnt have the ,script in it.
which might crash because i dont have the exact script in the file which i dont since then it gives me the error unknown type "private". get it  ;D

complete file
Spoiler
Quote
package data.scripts.world;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.campaign.LocationAPI;

@SuppressWarnings("unchecked")
public class HappyGen extends SectorGen {

     public void generate(SectorAPI sector) {
      
   StarSystemAPI system = sector.getStarSystem("Corvus");

      SectorEntityToken token = system.createToken(4000, 0);

      SectorEntityToken station = system.addOrbitalStation(token, 10, 45, 200, "spacecafe", "happy_drunk");  
      
      system.addSpawnPoint(new hpdefenceSpawnPoint(sector, system, 50, 1, token));

      token = system.createToken(15000, 15000);    

      system.addSpawnPoint(new hpconvoySpawnPoint(sector, system, 1, 1, token));   

      CargoAPI cargo = station.getCargo();
         
         
         cargo.addCrew(CrewXPLevel.ELITE, 25);
         cargo.addCrew(CrewXPLevel.VETERAN, 250);
         cargo.addCrew(CrewXPLevel.REGULAR, 500);

         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_nomad_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_phoenix_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_phoenix_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_piker_Hull", null);
         cargo.addMothballedShip(FleetMemberType.SHIP, "hp_piker_Hull", null);


         cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "firefly_wing", null);
         cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "firefly_wing", null);
         cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);
         cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);
         cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);

         cargo.addWeapons("bomb", 25);
         cargo.addWeapons("reaper", 12);
      
         cargo.addWeapons("lightac", 25);
         cargo.addWeapons("lightmg", 40);
         cargo.addWeapons("annihilator", 10);
         cargo.addWeapons("taclaser", 10);

         cargo.addWeapons("harpoon_single", 12);


         cargo.addWeapons("lightmortar", 40);
         cargo.addWeapons("miningblaster", 1);
      
   
         cargo.addWeapons("swarmer", 5);
         cargo.addWeapons("mininglaser", 25);
         cargo.addWeapons("pdlaser", 25);
      
         cargo.addWeapons("flak", 5);
         cargo.addWeapons("shredder", 5);
         cargo.addWeapons("annihilatorpod", 1);
         cargo.addWeapons("pilum", 2);
         cargo.addWeapons("mark9", 2);
   
         cargo.addCrew(CrewXPLevel.GREEN, 500);
         cargo.addSupplies(630);
         cargo.addFuel(500);


            FactionAPI happy_drunk = sector.getFaction("happy_drunk");

              happy_drunk.setRelationship("hegemony", 1);
      happy_drunk.setRelationship("tritachyon", 0);
      happy_drunk.setRelationship("pirates", -1);
      happy_drunk.setRelationship("independent", 1);
          happy_drunk.setRelationship("player", 1);


   }
      
  
}

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

   public hpdefenceSpawnPoint(SectorAPI sector, LocationAPI location,
                     float daysInterval, int maxFleets, SectorEntityToken anchor) {
      super(sector, location, daysInterval, maxFleets, anchor);
   }

   @Override
   protected CampaignFleetAPI spawnFleet() {
      //if ((float) Math.random() < 0.5f) return null;
      
      String type = null;
      float r = (float) Math.random();
      if (r > .8f) {
         type = "defencefleet";
      } else {
         type = "defencefleet";
      }
      
      CampaignFleetAPI fleet = getSector().createFleet("happy_drunk", type);
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
      
      
      if (type.equals("defencefleet")) {
         fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 51);
         fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
      } else {
         if ((float) Math.random() > 0.5f) {
            fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 51);
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
         } else {
            fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 51);
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
         }
      }
      
      return fleet;
   }

}

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

   private final SectorEntityToken convoyDestination;

   public hpconvoySpawnPoint(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() {
      //if ((float) Math.random() < 0.5f) return null;
      
      String type = null;
      float r = (float) Math.random();
      if (r > .8f) {
         type = "defencefleet";
      } else {
         type = "defencefleet";
      }
      
      CampaignFleetAPI fleet = getSector().createFleet("happy_drunk", type);
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
      
      
      if (type.equals("defencefleet")) {
         CargoAPI cargo = fleet.getCargo();

            cargo.addWeapons("annihilatorpod", 10);
            cargo.addWeapons("harpoon", 5);
            cargo.addWeapons("heavymg", 5);
            cargo.addWeapons("arbalest", 35);
            cargo.addWeapons("heavyac", 10);
            cargo.addWeapons("dualflak", 5);
            cargo.addWeapons("heavyblaster", 5);
            cargo.addWeapons("lightdualac", 5);
            cargo.addWeapons("lightag", 5);
            cargo.addWeapons("lightneedler", 5);
            cargo.addWeapons("heavymauler", 5);
            cargo.addWeapons("gravitonbeam", 5);
            cargo.addWeapons("hellbore", 5);
            cargo.addWeapons("cyclone", 2);
            cargo.addWeapons("pilum", 5);
            cargo.addWeapons("taclaser", 5);
            cargo.addWeapons("pulselaser", 5);
            cargo.addWeapons("heavyburst", 5);
            cargo.addWeapons("hil", 3);
            cargo.addWeapons("hveldriver", 5);
            cargo.addWeapons("reaper", 5);

            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_nomad_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_phoenix_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_phoenix_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_scissor_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_piker_Hull", null);
            cargo.addMothballedShip(FleetMemberType.SHIP, "hp_piker_Hull", null);


            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "firefly_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "firefly_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);
            cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "spike_wing", null);

            cargo.addCrew(CrewXPLevel.ELITE, 25);
            cargo.addCrew(CrewXPLevel.VETERAN, 250);
            cargo.addCrew(CrewXPLevel.REGULAR, 500);

            cargo.addCrew(CrewXPLevel.GREEN, 500);
            cargo.addSupplies(630);
            cargo.addFuel(500);
      
      fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000);
      fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
      }


      return fleet;
   }
}

[close]

so this is the "new" file its actually an old one since i removed some stuff to actually make the game start and it gives me this error on start up.
Spoiler
Code
9546 [Thread-6] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/ships/atlas_af.png] as texture with id [graphics/ships/atlas_af.png]
19557 [Thread-6] DEBUG com.fs.graphics.TextureLoader  - Loaded 83,59 MB of texture data so far
19776 [Thread-6] INFO  com.fs.profiler.Profiler  - ID     Calls   Duration    Percent
19776 [Thread-6] INFO  com.fs.profiler.Profiler  - --------------------------------
19789 [Thread-6] ERROR com.fs.starfarer.combat.String  - java.lang.RuntimeException: Error compiling [data.scripts.world.HappyGen]
java.lang.RuntimeException: Error compiling [data.scripts.world.HappyGen]
at com.fs.starfarer.loading.scripts.ScriptStore$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: Compiling unit "data/scripts/world/HappyGen.java"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:212)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:164)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/world/HappyGen.java, Line 35, Column 27: No applicable constructor/method found for actual parameters "com.fs.starfarer.api.campaign.SectorAPI, com.fs.starfarer.api.campaign.StarSystemAPI, int, int, com.fs.starfarer.api.campaign.SectorEntityToken"; candidates are: "data.scripts.world.hpconvoySpawnPoint(com.fs.starfarer.api.campaign.SectorAPI, com.fs.starfarer.api.campaign.LocationAPI, float, int, com.fs.starfarer.api.campaign.SectorEntityToken, com.fs.starfarer.api.campaign.SectorEntityToken)"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:9403)
at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:6994)
at org.codehaus.janino.UnitCompiler.invokeConstructor(UnitCompiler.java:5975)
at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3797)
at org.codehaus.janino.UnitCompiler.access$69(UnitCompiler.java:3721)
at org.codehaus.janino.UnitCompiler$11.visitNewClassInstance(UnitCompiler.java:2978)
at org.codehaus.janino.Java$NewClassInstance.accept(Java.java:2918)
at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:2993)
at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:4017)
at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3629)
at org.codehaus.janino.UnitCompiler.access$63(UnitCompiler.java:3552)
at org.codehaus.janino.UnitCompiler$11.visitMethodInvocation(UnitCompiler.java:2967)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:2831)
at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:2993)
at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:4017)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2413)
at org.codehaus.janino.UnitCompiler.access$38(UnitCompiler.java:2412)
at org.codehaus.janino.UnitCompiler$8.visitMethodInvocation(UnitCompiler.java:2381)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:2831)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2407)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1426)
at org.codehaus.janino.UnitCompiler.access$8(UnitCompiler.java:1425)
at org.codehaus.janino.UnitCompiler$5.visitExpressionStatement(UnitCompiler.java:926)
at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:1447)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:946)
at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:972)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2083)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:851)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:832)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:528)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:421)
at org.codehaus.janino.UnitCompiler$3.visitPackageMemberClassDeclaration(UnitCompiler.java:376)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:765)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:383)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:352)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:210)
... 5 more
[close]
line 35
Code
system.addSpawnPoint(new hpconvoySpawnPoint(sector, system, 1, 1, token));
funny part is that this line is not changed since the last version, so it must be giving an error because something is wrong with the code hes pointing at which is the conoy spawn.

which probaply crashes due to something i just edited and that is this part
Spoiler
Quote
   public hpconvoySpawnPoint(SectorAPI sector, LocationAPI location,
                     float daysInterval, int maxFleets, SectorEntityToken anchor, SectorEntityToken convoyDestination) {
      super(sector, location, daysInterval, maxFleets, anchor);
      this.convoyDestination = convoyDestination;
[close]
If i would look at this with some reason i would say its because convoydestination is not given ,although i cant seem to find any file where convoy destination is defined ,so it might just be something else.
« Last Edit: November 07, 2012, 02:57:33 AM by TheHappyFace »
Logged
Fractalsoftworks limited edition ban hammer.

ValkyriaL

  • Admiral
  • *****
  • Posts: 2145
  • The Guru of Capital Ships.
    • View Profile
Re: fatal null when convoy spawns
« Reply #3 on: November 07, 2012, 05:27:58 AM »

convoy spawn/return is defined here
Quote
SectorEntityToken token = system.createToken(-15000, 15000);
 
convoy destination is defined here
Quote
SectorEntityToken starbasetoken = system.getEntityByName("Starbase");

 and is used by this
Quote
system.addSpawnPoint (new nephalemConvoySpawnPoint(sector, system, 10, 1, token, starbasetoken));

and you probably already knew all that which makes those quotes pointless XD

Btw you cant have the convoy file and spawn file in a single file, or maybe you can, i haven't tried and neither will i, wouldn't it be easier if you just went a did it the normal way? 1 gen file, 1 convoy file and 1 spawn file?

all convoys deliver the same stuff more or less depending on what you code it to give more of, so simply make 1 convoy and it will deliver everything.

my personnel convoy delivers supplies, fuel, weapons ext, but they deliver veteran and elite crew as well, the other convoys don't. while the fuel convoy delivers alot of fuel and the resupply delivers everything else in larger quantities.
Logged

TheHappyFace

  • Admiral
  • *****
  • Posts: 1168
  • The critic
    • View Profile
Re: fatal null when convoy spawns
« Reply #4 on: November 07, 2012, 06:05:17 AM »

those quotes above might help. i will look at that later ,but i think that might be the reason.
i never knew that the last part of the spawnpoint line was for destination.
thanks will change it as soon as i find some time and we'll see if it worksout  ;)

edit: It worked!!!
thank you so much.
I'll name my next destroyer after you ^^
Valkyrial-class heavy destroyer

the mod with the destroyer in it will be uploaded Soontm

for anyone curious what caused it:
my convoy destination was missing.
« Last Edit: November 07, 2012, 10:22:49 AM by TheHappyFace »
Logged
Fractalsoftworks limited edition ban hammer.

ValkyriaL

  • Admiral
  • *****
  • Posts: 2145
  • The Guru of Capital Ships.
    • View Profile
Re: fatal null when convoy spawns *solved*
« Reply #5 on: November 08, 2012, 10:10:59 AM »

You will name a ship after me? Im so happy i could cry. XD
Logged