Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: 1 ... 585 586 [587] 588 589 ... 706

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

AccuracyThruVolume

  • Commander
  • ***
  • Posts: 133
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8790 on: May 27, 2022, 10:37:52 PM »

Hmmm, working on adding a second faction to my mod.   I got it to generate the system for them, the first faction system is still working.

However when I get <2 light years from the second faction's system, the game crashes with:

Spoiler
425701 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficer sV2(FleetFactoryV3.java:995)
   at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficer s(FleetFactoryV3.java:857)
   at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.createFleet(FleetFactoryV3.java:414)
   at com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager.createTradeR outeFleet(EconomyFleetRouteManager.java:627)
   at com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager.spawnFleet(EconomyFleetRouteManager.java:487)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:619)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
   at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:140)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]


I'm assuming it is trying to generate ships and there is something that it not config'd correctly for the second faction?   Any ideas on where the root cause is?

EDIT:  Hmmm turns out it was my attempt to list a custom names list in the faction file:

"names":
{
    "orks":1,    
},

I have a data/characters/person_names.csv and it looks like this:

name   gender   usage   category
         
Atulg           m,f           f           orks
Azlak   m,f           f           orks
Azuk           m,f           f           orks



Do I need to associate the person_names.csv somehow?



EDIT 2:  Hrrmmmm... everything started working after the 5th attempt  o.0   Not sure about root cause on this one ..........
« Last Edit: May 27, 2022, 11:30:30 PM by AccuracyThruVolume »
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8791 on: May 28, 2022, 07:59:53 AM »

how do weaponOPCostModifier (and their fighter variant) listeners work?

Code
    public static class SDSY_WandererOPCostListener implements WeaponOPCostModifier {

        @Override
        public int getWeaponOPCost(MutableShipStatsAPI stats, WeaponSpecAPI weapon, int currCost) {

            int discount = 0;

            for (String tag : weapon.getTags()) {
                if (tag.startsWith("wanderer_discount_")) {
                    discount = Integer.parseInt(tag.substring(18));
                }
            }
            return discount;
        }
    }

I've got this listener being added in afterShipCreation and it doesn't seem like it's doing anything, what do I need to have it return (does it need to be the modified value or just the difference?) and is there anything else I need to do?

EDIT - cleaned up code, ty to tomatopaste!

EDIT 2 - being more specific about the way I'm testing it- I'm using SCVE's mod tester main menu mission, that might be interfering? (it also prevents me from doing it beforeCreation, if that's the problem) ignore this, read edit 4

EDIT 3 - and a second question - how do you get the status of a ship's right-click system if it isn't shields or phase? is it just getPhaseCloak?

EDIT 4 - Figured it all out, I reread the API documentation and actually noticed that it's gotta be added to the MutableStats, not the ship (also made the hullmod affectOPCosts, but idk if that helped), that I can do just fine in beforeCreation
also for anyone trying to figure this out later- it needs to return the modified value, not just the difference
« Last Edit: May 28, 2022, 05:32:16 PM by Ruddygreat »
Logged

Helldiver

  • Captain
  • ****
  • Posts: 378
  • space fruit
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8792 on: May 28, 2022, 12:47:19 PM »

What determines whether an industry is player-buildable or not? My weak java-fu can't find anything and I don't see anything in industries.csv that would affect that either.
Logged
Afflictor bean plushie that glows purple when you squeeze it
30$

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8793 on: May 28, 2022, 12:57:53 PM »

It is in the industry's script: Industry.isAvailableToBuild() and Industry.showWhenUnavailable()
Logged

Helldiver

  • Captain
  • ****
  • Posts: 378
  • space fruit
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8794 on: May 28, 2022, 01:30:21 PM »

It is in the industry's script: Industry.isAvailableToBuild() and Industry.showWhenUnavailable()

Thanks!
Logged
Afflictor bean plushie that glows purple when you squeeze it
30$

briansd9

  • Ensign
  • *
  • Posts: 47
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8795 on: May 28, 2022, 05:34:46 PM »

Is there a way to detect when a ship has retreated from combat?

ShipAPI.isRetreating() seems to return true once the retreat order is given, but I can't find anything for when it actually leaves the battlefield
Logged

Visha

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8796 on: May 28, 2022, 08:51:55 PM »

So, using UAF and Big Bean's ships and I was getting a crash on the Adventurer and the Pirate Venture when using the auto fit and then hitting weapon groups. This then causes a crash. Then did a test where we removed the auto fit, and added guns one at a time. No crash. Cleared the standard autofits, made one with just UAF guns and fighter. No crash. Seems that something in the Big Bean ship pack autofits is causing the crash.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8797 on: May 29, 2022, 12:38:46 PM »

How can I programmatically modify the base range of specific projectile specs once Starsector has loaded?  The WeaponSpecAPI method setMaxRange affects only the length of the weapon arcs, leaving the projectiles with the same range.  The WeaponSpecAPI method getProjectileSpec returns an object of a class I have determined to be the obfuscated ProjectileSpec behind the ProjectileSpecAPI, but the reflection tools I have borrowed from lyravega's Experimental Hullmods cannot reach the setMaxRange method  that my IDE indicates it inherits.  lyravega has suggested I ask Alex about this.

Hmm, I'm not sure that you can, actually, aside from what you're trying to do. As to why that might not be working, I can't say.

EDIT 3 - and a second question - how do you get the status of a ship's right-click system if it isn't shields or phase? is it just getPhaseCloak?

Yep!

EDIT 4 - Figured it all out, I reread the API documentation and actually noticed that it's gotta be added to the MutableStats, not the ship (also made the hullmod affectOPCosts, but idk if that helped), that I can do just fine in beforeCreation
also for anyone trying to figure this out later- it needs to return the modified value, not just the difference

Glad you got it figured out!


Is there a way to detect when a ship has retreated from combat?

ShipAPI.isRetreating() seems to return true once the retreat order is given, but I can't find anything for when it actually leaves the battlefield

I don't believe there's any actual notification for this. You might look at CombatFleetManagerAPI.getRetreatedCopy() to see when the relevant fleet member shows up.
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8798 on: June 01, 2022, 07:25:41 PM »

Hmm, I'm not sure that you can, actually, aside from what you're trying to do. As to why that might not be working, I can't say.

I've figured it out!

Code
ProjectileSpecAPI projectileSpecAPI = (ProjectileSpecAPI) weaponSpecAPI.getProjectileSpec();
projectileSpecAPI.setMaxRange(maxRange);

Also, do I have your blessing to distribute the following obfuscated code magic? 

I have created a proxy class for that obfuscated ooOOOOOOOO... class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for beam weapons, with a method handle for each obfuscated method of a non-obfuscated type (alongside identical code for the methods of obfuscated types commented-out in-place).  I created it because I needed to call the obfuscated setBeamSpeed method of this obfuscated class to programmatically change the speed of beams.  I also want to complete my existing proxy for that obfuscated class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for projectile weapons.

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8799 on: June 02, 2022, 03:00:08 AM »

Found a weird mod interaction issue.

Normally, calling Global.getSector() in ModPlugin.onApplicationLoad() returns null. However, you can force a sector to exist by calling SettingsAPI.doesVariantExist:

Code: java
	@Override
public void onApplicationLoad() throws Exception {
Global.getLogger(this.getClass()).info("Sector is " + Global.getSector());
Global.getSettings().doesVariantExist("foobar");
Global.getLogger(this.getClass()).info("Sector is " + Global.getSector());
}
21653 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Sector is null
21728 [Thread-3] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/particlealpha32sq.png (using cast)
21754 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Sector is com.fs.starfarer.campaign.CampaignEngine@7bdde97d

The reason it came up: Apparently someone else's mod was crashing on app load if Nexerelin wasn't enabled, because getSector returned null
(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)
Logged

Schaf-Unschaf

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8800 on: June 02, 2022, 06:30:56 AM »

The reason it came up: Apparently someone else's mod was crashing on app load if Nexerelin wasn't enabled, because getSector returned null
(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)

Yep, that's exactly the reason why i called it onApplicationLoad() (correcting imported faction strings). Now i'm doing it onGameLoad() instead.
Never noticed that.. who even is playing modded without Nex? xD
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8801 on: June 02, 2022, 07:09:12 AM »

> Never noticed that.. who even is playing modded without Nex? xD

I do.

When I removeIntel() from intel manager, will the implementation also removeScript(this) internally, or should I remove both intel and script myself? What if the intel was added as transient script?

Can I change currently selected intel programmatically, without showing Intel UI? Ideally, I'd like to reset it to unselected state.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8802 on: June 02, 2022, 11:51:25 AM »

Also, do I have your blessing to distribute the following obfuscated code magic? 

I have created a proxy class for that obfuscated ooOOOOOOOO... class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for beam weapons, with a method handle for each obfuscated method of a non-obfuscated type (alongside identical code for the methods of obfuscated types commented-out in-place).  I created it because I needed to call the obfuscated setBeamSpeed method of this obfuscated class to programmatically change the speed of beams.  I also want to complete my existing proxy for that obfuscated class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for projectile weapons.

I would *much* rather get a request for API improvements - that's a more sustainable way going forward, and it won't break when a new version is out.

(Just added WeaponSpecAPI.setBeamSpeed(), btw.)

(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)

Interesting. Definitely not a "valid" usage - at least in terms of "usage that's expected to work", though; calling getSector() outside the campaign may return null. Or an old campaign. Or whatever else. The getAllFactions() method can't work outside the campaign, though, since factions have a bunch of data that is persistent (such as additional known hulls etc). There is a (not exposed with the API) FactionSpec class under the hood, though, and *that* could be made visible with a FactionSpecAPI interface... hmm.

When I removeIntel() from intel manager, will the implementation also removeScript(this) internally, or should I remove both intel and script myself? What if the intel was added as transient script?

You need to removeScript() yourself - it has no idea where you might've added it as a script. (The sector, a location, some kind of entity...)

For a transient script you'd want to remove it anyway - it'll go away on save load, but it seems like you would not want it to keep being advance()'ed after removal.

Can I change currently selected intel programmatically, without showing Intel UI? Ideally, I'd like to reset it to unselected state.

I don't think so, let me make a note!
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8803 on: June 02, 2022, 12:49:17 PM »

I would *much* rather get a request for API improvements - that's a more sustainable way going forward, and it won't break when a new version is out.

(Just added WeaponSpecAPI.setBeamSpeed(), btw.)

Eek!  Will do!  :-[ 

Thanks so much for the API extension, Alex! :D  The fewer proxies, the better, and a richer API enables deeper modding!

And speaking of the API, my mod entails the following proxy methods, which I would be grateful to see added to the API sometime.

Code
public class ProjectileWeaponSpecProxy {
    public static void setEnergyPerShot(float energyPerShot) {}
    public static void setRefireDelay(float refireDelay) {}
    public static void setBurstDelay(float burstDelay) {}
    public static void setBurstSize(float burstSize) {}
    public static void setMaxAmmo(int maxAmmo) {}
    public static void setAmmoPerSecond(float ammoPerSecond) {}
    public static void setReloadSize(float reloadSize) {}
}

Until then, at least throwables from my proxies (and the tools that create them) are handled safely and logged clearly.

My mod combines these proxies to give ballistic weapons the following real-life attributes:
  • negligible energy consumption
  • very low fire rates for large-caliber, fast fire rates for medium caliber, and very fast fire rates for small-caliber weapons
  • fully automatic fire not limited to bursts
  • little ready ammo
  • much reserve ammo
  • slow reloads from reserve ammo, especially for high-caliber ammo
« Last Edit: June 02, 2022, 01:01:32 PM by Liral »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8804 on: June 02, 2022, 06:23:30 PM »

(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)

Interesting. Definitely not a "valid" usage - at least in terms of "usage that's expected to work", though; calling getSector() outside the campaign may return null. Or an old campaign. Or whatever else. The getAllFactions() method can't work outside the campaign, though, since factions have a bunch of data that is persistent (such as additional known hulls etc). There is a (not exposed with the API) FactionSpec class under the hood, though, and *that* could be made visible with a FactionSpecAPI interface... hmm.
Well I was thinking a SettingsAPI method could return a list of faction IDs, and the mod calls SettingsAPI.createBaseFaction if it needs data from a particular faction (according to createBaseFaction's javadoc, this is indeed what it's for).
Logged
Pages: 1 ... 585 586 [587] 588 589 ... 706