Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Uniquifying the Factions, Part 2 (04/30/22)

Pages: 1 ... 49 50 [51] 52 53 ... 585

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 1289728 times)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20353
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #750 on: September 14, 2013, 10:41:35 AM »

As far as I can see, if I use an index from 0 and out it uses core sounds. But if a different mod tried to call the same list entries as the ones I'm using, would there be a conflict? Can I do this in a more... isolated fashion?

Hm, that's a good point, this is a problem. Will take a look.
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #751 on: September 14, 2013, 01:46:51 PM »

Hey, I've noticed that my ships aren't spawning with the proper names.

If have
Code
    "shipNameSources":{
"regime":1,
},
in the .faction file and then a ship_names.json in data/strings of my mod that looks like this
Code
{
"regime":
[
"Hand of God",
"Repentant",
],
}
is there any reason why my ships are showing up in stations etc. with names pulled from other lists? Bug, or am I overlooking something dumb?

edit: I have quite a few names on there, but I'll add more and see if that fixes anything? I don't think that's it, though.
« Last Edit: September 14, 2013, 03:11:09 PM by Vayra »
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

Gotcha!

  • Admiral
  • *****
  • Posts: 1119
    • View Profile
    • Welcome to New Hiigara
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #752 on: September 14, 2013, 02:55:33 PM »

Maybe your name list is too short so the game gets needed names from other lists as well? (Dunno if it is short, haven't checked.)
Logged
  

Psiyon

  • Admiral
  • *****
  • Posts: 772
  • Trippy
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #753 on: September 14, 2013, 02:55:51 PM »

Why do ships with 0 crew (As in, unmanned--there shouldn't be any crew) always have 0% combat readiness? Is there a way to override the automatically-assigned 0% CR, or is this a bug?
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #754 on: September 14, 2013, 03:14:46 PM »

I updated my mod to the new ModPlugin system as per LazyWizard's post and it kept calling the OnEnabled part every time a saved game was loaded -- as if it wasn't reading the "if (!wasEnabledBefore)" or rather I suppose as if wasEnabledBefore never got set. I was under the impression the game's built-in mod handling set it automatically, is there a way I can do it manually in the onNewGame? I'm sure it's really simple but I can't really into java :v

Code
     @Override
     public void onEnabled(boolean wasEnabledBefore)
     {
         if (!wasEnabledBefore)
         {
            // Calling a separate method avoids duplicate code with onNewGame()
            initVayra();
         }
     }

I fixed the problem for now by just commenting that block of code out, but that's obviously nonoptimal as it means I can't add my mod to existing games.
« Last Edit: September 14, 2013, 03:28:36 PM by Vayra »
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

FlashFrozen

  • Admiral
  • *****
  • Posts: 988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #755 on: September 14, 2013, 03:36:12 PM »

Why do ships with 0 crew (As in, unmanned--there shouldn't be any crew) always have 0% combat readiness? Is there a way to override the automatically-assigned 0% CR, or is this a bug?

I can't give a why , but I had the same prob.

http://fractalsoftworks.com/forum/index.php?topic=6634.0
Logged

Verrius

  • Captain
  • ****
  • Posts: 369
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #756 on: September 14, 2013, 05:53:05 PM »

Thanks Lazy, that's pretty helpful. Although I'm still confused, I may as well try to describe what I want to do.

All I wanna do is add special dialogue options for Stations controlled by a specific faction.
Also would like to do a special dialogue that only plays when you interact with a planet.

But things don't ever seem to work the way I want them to.

I should add that I'd like to to NOT replace anything I can avoid replacing, for compatibility.

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #757 on: September 14, 2013, 06:18:02 PM »

Why do ships with 0 crew (As in, unmanned--there shouldn't be any crew) always have 0% combat readiness? Is there a way to override the automatically-assigned 0% CR, or is this a bug?

Seem like CR is connected to the crew XP, 0 crew will return a bonus of 0f, resulting in 0 CR created.
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1354
    • View Profile
    • GitHub Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #758 on: September 14, 2013, 06:41:03 PM »

Thanks Lazy, that's pretty helpful. Although I'm still confused, I may as well try to describe what I want to do.

All I wanna do is add special dialogue options for Stations controlled by a specific faction.
Also would like to do a special dialogue that only plays when you interact with a planet.

But things don't ever seem to work the way I want them to.

I should add that I'd like to to NOT replace anything I can avoid replacing, for compatibility.

Here's an example of picking an interaction plugin for a specific entity without using generics (this goes in your CampaignPlugin implementation):

Code
    @Override
    public PluginPick pickInteractionDialogPlugin(SectorEntityToken interactionTarget)
    {
        // The Omnifactory uses a special interaction dialog
        if (OmniFac.isFactory(interactionTarget))
        {
            // PluginPick is a wrapper that allows you to assign a priority to a plugin
            // The highest priority plugin returned by all mods' CampaignPlugins will be the one used
            return new PluginPick(new OmniFacInteractionPlugin(),
                    PickPriority.MOD_SPECIFIC);
        }

        // Returning null means this mod doesn't have a specific interaction plugin for this entity
        // If all mods return null, the vanilla interaction behavior for that entity will be used
        return null;
    }

Writing the plugin that handles interaction itself is significantly more complicated. If you open up starfarer.api.zip and look in the com/fs/starfarer/api/impl/campaign/ directory you can find some examples (anything with InteractionDialogPluginImpl in the name). Just note that you might need to change the switch statements to a series of if/else if blocks because Janino can't handle switch on enumerations.


I updated my mod to the new ModPlugin system as per LazyWizard's post and it kept calling the OnEnabled part every time a saved game was loaded -- as if it wasn't reading the "if (!wasEnabledBefore)" or rather I suppose as if wasEnabledBefore never got set. I was under the impression the game's built-in mod handling set it automatically, is there a way I can do it manually in the onNewGame? I'm sure it's really simple but I can't really into java :v

Code
     @Override
     public void onEnabled(boolean wasEnabledBefore)
     {
         if (!wasEnabledBefore)
         {
            // Calling a separate method avoids duplicate code with onNewGame()
            initVayra();
         }
     }

I fixed the problem for now by just commenting that block of code out, but that's obviously nonoptimal as it means I can't add my mod to existing games.

You should write a post in the Bug Reports section. :(
Logged

Psiyon

  • Admiral
  • *****
  • Posts: 772
  • Trippy
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #759 on: September 14, 2013, 09:16:46 PM »

I'm getting an error when I go to start a new game in my mod:


Code
32318 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.K.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.OooO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.O00o.super(Unknown Source)
at com.fs.starfarer.ui.F.processInput(Unknown Source)
at com.fs.starfarer.ui.newsuper.o00000(Unknown Source)
at com.fs.starfarer.new.????00(Unknown Source)
at com.fs.oOOO.super.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

I'm using a very generic SectorGen script, something that, when put alone in a test mod, loads into the campaign just fine. However, in Obsidian Void, it crashes after hitting "start game" in the character screen.

Any ideas on what might be causing this? I'm at a total loss, as I've removed all of my custom campaign code, meaning none of my mod's files are even be aware of com.fs.starfarer.campaign.Hyperspace's existence.

...And interestingly, upon checking, com.fs.starfarer.campaign.Hyperspace doesn't seem to exist in the API. Weird.
Logged

FlashFrozen

  • Admiral
  • *****
  • Posts: 988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #760 on: September 15, 2013, 12:51:11 AM »

Welp I've tried basically doing a copy of Askonia and renaming it, but it doesn't appear on the hyperspace map as expected, so now I'm digging through how to actually add my system in, what other file do I need to modify in order to add in a system.

I've seen how Mshadowy does it, but replicating that method seems ill advised since i don't actually know how it'll turn out lol.

Do I need to put in;

Code
import data.scripts.world.systems.CoronaAustralis;

in a gen file ? or something cause idk I'm just lost lol.

Temporary file for my system:

Code
package data.scripts.world.systems;

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

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

public class CoronaAustralis {

public void generate(SectorAPI sector) {
StarSystemAPI system = sector.createStarSystem("Corona Australis");
LocationAPI hyper = Global.getSector().getHyperspace();

system.setBackgroundTextureFilename("graphics/backgrounds/CoronaAustralis.jpg");

// create the star and generate the hyperspace anchor for this system
PlanetAPI CoronaAustralis = system.initStar("neut_star_neutron", // id in planets.json
200f, // radius (in pixels at default zoom)
2500, 3000);   // location in hyperspace

system.setLightColor(new Color(255, 255, 255)); // light color in entire system, affects all entities


/*
* addPlanet() parameters:
* 1. What the planet orbits (orbit is always circular)
* 2. Name
* 3. Planet type id in planets.json
* 4. Starting angle in orbit, i.e. 0 = to the right of the star
* 5. Planet radius, pixels at default zoom
* 6. Orbit radius, pixels at default zoom
* 7. Days it takes to complete an orbit. 1 day = 10 seconds.
*/
PlanetAPI p1 = system.addPlanet(CoronaAustralis, "Deadworld IS7", "neut_rocky_unstable", 0, 150, 2500, 100);
//PlanetAPI a2 = system.addPlanet(star, "Salus", "gas_giant", 230, 350, 7000, 250);

//PlanetAPI a21 = system.addPlanet(a2, "Cruor", "rocky_unstable", 45, 80, 800, 25);
//PlanetAPI a22 = system.addPlanet(a2, "Volturn", "water", 110, 120, 1400, 45);

//PlanetAPI a3 = system.addPlanet(star, "Umbra", "rocky_ice", 280, 150, 12000, 650);

p1.setCustomDescriptionId("neut_planet_IS7");
//a2.setCustomDescriptionId("planet_salus");
//a21.setCustomDescriptionId("planet_cruor");
//a22.setCustomDescriptionId("planet_volturn");
//a3.setCustomDescriptionId("planet_umbra");

p1.getSpec().setPlanetColor(new Color(255,215,190,255));
p1.getSpec().setAtmosphereColor(new Color(160,110,45,140));
p1.getSpec().setCloudColor(new Color(255,164,96,200));
p1.getSpec().setTilt(10);
p1.applySpecChanges();

/*
* addAsteroidBelt() parameters:
* 1. What the belt orbits
* 2. Number of asteroids
* 3. Orbit radius
* 4. Belt width
* 6/7. Range of days to complete one orbit. Value picked randomly for each asteroid.
*/
system.addAsteroidBelt(p1, 50, 1100, 128, 40, 80);


/*
* addRingBand() parameters:
* 1. What it orbits
* 2. Category under "graphics" in settings.json
* 3. Key in category
* 4. Width of band within the texture
* 5. Index of band
* 6. Color to apply to band
* 7. Width of band (in the game)
* 8. Orbit radius (of the middle of the band)
* 9. Orbital period, in days
*/
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1400, 40f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1450, 60f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1500, 80f);

system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1750, 70f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1800, 90f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1850, 110f);

system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2100, 50f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2150, 70f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2200, 80f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 1, Color.white, 256f, 2250, 90f);

system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1400, 40f);
system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1450, 60f);
system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1500, 80f);

system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1750, 70f);
system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1800, 90f);
system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1850, 110f);




JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("Jump Point Alpha");
OrbitAPI orbit = Global.getFactory().createCircularOrbit(p1, 0, 400, 40);
jumpPoint.setOrbit(orbit);
jumpPoint.setRelatedPlanet(p1);
jumpPoint.setStandardWormholeToHyperspaceVisual();
system.addEntity(jumpPoint);

/*
* addPlanet() parameters:
* 1. What the planet orbits (orbit is always circular)
* 2. Name
* 3. Planet type id in planets.json
* 4. Starting angle in orbit, i.e. 0 = to the right of the star
* 5. Planet radius, pixels at default zoom
* 6. Orbit radius, pixels at default zoom
* 7. Days it takes to complete an orbit. 1 day = 10 seconds.
*/

SectorEntityToken NCstation1 = system.addOrbitalStation(CoronaAustralis, 200, 700, 90, "Small Extraction Drill", "neutrinocorp");
SectorEntityToken NCstation2 = system.addOrbitalStation(CoronaAustralis, 200, 1600, 90, "Large Processing Dock", "neutrinocorp");
SectorEntityToken NCstation3 = system.addOrbitalStation(p1, 45, 300, 50, "Small Research Station", "neutrinocorp");

initStationCargo(NCstation1);
initStationCargo(NCstation2);
initStationCargo(NCstation3);

// example of using custom visuals below
// a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
// jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
// station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));

// generates hyperspace destinations for in-system jump points
system.autogenerateHyperspaceJumpPoints(true, true);

system.addSpawnPoint(new neutrinoConvoySpawnPoint(sector, system, 7, 1, token, NCstation2));
neutrinoSpawnPoint NCSpawn1 = new neutrinoSpawnPoint(sector, system, 2, 2, NCstation1);
neutrinoSpawnPoint NCSpawn2 = new neutrinoSpawnPoint(sector, system, 2, 3, NCstation2);
neutrinoSpawnPoint NCSpawn3 = new neutrinoSpawnPoint(sector, system, 2, 1, NCstation3);

system.addSpawnPoint(NCSpawn1);
for (int i = 0; i < 2; i++) NCSpawn1.spawnFleet();
system.addSpawnPoint(NCSpawn2);
for (int i = 0; i < 2; i++) NCSpawn2.spawnFleet();
system.addSpawnPoint(NCSpawn3);
for (int i = 0; i < 2; i++) NCSpawn3.spawnFleet();





system.addScript(new IndependentTraderSpawnPoint(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), NCstation2));
}


private void initStationCargo(SectorEntityToken NCstation2) {
CargoAPI cargo = NCstation2.getCargo();
addRandomWeapons(cargo, 3);

cargo.addCrew(CrewXPLevel.VETERAN, 20);
cargo.addCrew(CrewXPLevel.REGULAR, 500);
cargo.addMarines(80);
cargo.addSupplies(2000);
cargo.addFuel(500);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
}

private void initStationCargo(SectorEntityToken NCstation3) {
CargoAPI cargo = NCstation3.getCargo();
addRandomWeapons(cargo, 5);

cargo.addCrew(CrewXPLevel.VETERAN, 69);
cargo.addCrew(CrewXPLevel.ELITE, 25);
cargo.addMarines(200);
cargo.addSupplies(600);
cargo.addFuel(200);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
}


private void addRandomWeapons(CargoAPI cargo, int count) {
List weaponIds = Global.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);
}
}

}


« Last Edit: September 15, 2013, 07:44:07 PM by FlashFrozen »
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #761 on: September 15, 2013, 12:54:29 AM »

I'm getting an error when I go to start a new game in my mod:


Code
32318 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.K.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.OooO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.O00o.super(Unknown Source)
at com.fs.starfarer.ui.F.processInput(Unknown Source)
at com.fs.starfarer.ui.newsuper.o00000(Unknown Source)
at com.fs.starfarer.new.????00(Unknown Source)
at com.fs.oOOO.super.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

I'm using a very generic SectorGen script, something that, when put alone in a test mod, loads into the campaign just fine. However, in Obsidian Void, it crashes after hitting "start game" in the character screen.

Any ideas on what might be causing this? I'm at a total loss, as I've removed all of my custom campaign code, meaning none of my mod's files are even be aware of com.fs.starfarer.campaign.Hyperspace's existence.

...And interestingly, upon checking, com.fs.starfarer.campaign.Hyperspace doesn't seem to exist in the API. Weird.

I am also getting this error. I can remove/add a few things and it won't get this error, but instead I get a NullPointerException at the exact same point.

However, if I leave the single line from StarSector-core's SectorGen.java that creates the system "Corvus" it works (I just end up with an empty system called Corvus I don't want...). If I then try and put the starting position in another system, I can move around it that system but my fleet doesn't show and the framerate plummeted! (it was at this point I decided I was well into the wilderness and should stop hacking around...)

Still, hopefully it is something simple :)
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #762 on: September 15, 2013, 02:51:21 AM »

Is there a functional way I can get a mod to check for other installed mods, and trigger code if they are, without crashing if they aren't?

example: I have both my Kadur Theocracy and MShadowy's Shadowyards Heavy Industries mods installed. Can I somehow write code in the Kadur Theocracy scripts to trigger if SHI is loaded and make a station in the Kadur star system send supply convoys to/from stations in the star system that Shadowyards Heavy Industries adds, without crashing the game if the SHI mod isn't installed?
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #763 on: September 15, 2013, 03:29:53 AM »

Is there a functional way I can get a mod to check for other installed mods, and trigger code if they are, without crashing if they aren't?

example: I have both my Kadur Theocracy and MShadowy's Shadowyards Heavy Industries mods installed. Can I somehow write code in the Kadur Theocracy scripts to trigger if SHI is loaded and make a station in the Kadur star system send supply convoys to/from stations in the star system that Shadowyards Heavy Industries adds, without crashing the game if the SHI mod isn't installed?

This should still work:

Code
try
{
Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.SHIGen");
System.out.println("Shadowyards HI installed");
// TODO STUFF
}
catch (ClassNotFoundException ex)
{
System.out.println("Shadowyards HI not installed");
}
Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #764 on: September 15, 2013, 12:38:42 PM »

Guys, did anyone made a workable custom AI to use a specific weapon yet?

Ive got a repair armor beam that needs a custom AI made, but i cant seem to find a good example for me to start from, heres the code of the beam:

Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;

public class RepairArmorBeam implements BeamEffectPlugin
{  
    private IntervalUtil timer = new IntervalUtil(1f, 1f);
            
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        ShipAPI ship = beam.getSource();
        if (ship == null)
        {
            return;
        }

        if(beam.didDamageThisFrame() && timer.intervalElapsed())
        {
            ShipAPI target = (ShipAPI) beam.getDamageTarget();
            int[] armorcell = target.getArmorGrid().getCellAtLocation(beam.getTo());
            
            float armorAmount = target.getArmorGrid().getArmorValue(armorcell[0], armorcell[1]);
            float armorToFix = target.getArmorGrid().getMaxArmorInCell() - armorAmount;
            target.getArmorGrid().setArmorValue(armorcell[0], armorcell[1], armorToFix);
        }
        
        timer.advance(amount);
    }
}
« Last Edit: October 02, 2013, 07:24:53 AM by silentstormpt »
Logged
Pages: 1 ... 49 50 [51] 52 53 ... 585