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 ... 379 380 [381] 382 383 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5700 on: November 20, 2019, 10:02:42 AM »

Is it possible to change the default empty weapon slot mount sprite of a ship through hullmod? would need to be something that works on all ships, not just mine, so no deco weapons workarounds.

I don't believe so. The slot cover sprites are set in the hullstyle, while the actual mount sprites (which I suspect you're *not* referring to) are baked into the hull sprite.


Behaving weirdly how? I suspect that fleets normally won't inflate until you interact with them directly, which means they won't be stripped of Shikomes until the earliest timer elapse after inflation. That could lead to, for example, hovering over a fleet and seeing its shikomes transform to skinwalkers in the fleet tooltip after a brief delay. I was thinking about this problem earlier, and I think I might've thought of a solution (assuming my guess about what's causing the problem in the first place is correct). Instead of periodically iterating over the nearby fleets in the player's current location, it might be possible to run your code at the exact frame (or maybe the next frame) when the fleet inflates. I'm pretty sure CampaignPlugin.pickFleetInflater() is called each time a fleet is inflated, so if you override that you can add the inflated fleet to a collection to be modified shortly thereafter. In fact, I think I might be able to solve a similar inflation-related display bug in ruthless sector this way, so I'll let you know if it works for me.

Edit: Well, that doesn't seem to work, unfortunately. It seems like inflaters are picked for fleets when they respawn rather than when they inflate.

Ah well; I appreciate you taking the time to help. Guess it's gonna be something to think on.

A possible solution: calling .inflateIfNeeded() on nearby fleets that need this done?
Logged

senhe

  • Ensign
  • *
  • Posts: 1
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5701 on: November 20, 2019, 03:33:16 PM »

Hey all, love Starsector and I'd like to start making a couple mods for it.

What I'd like to do is make the 'Take All' looting option only loot up to your cargo/fuel limit, prioritizing supplies or high-value commodities.

I've skimmed the Starsector API, but I'm not sure if what I want to do is possible.

Appreciate any pointers in the right direction!
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5702 on: November 20, 2019, 04:20:06 PM »

How to check if one month has passsed (a monthly check for a script to fire)?

I know it should extend EveryFrameScript but how to track (roughly) a month. By counting frames? Can I use the same method as the monthly stipend (if I can find it, don't know where it is in the code)?
For example: after implementing EveryFrameScript:
Code
static float months = 0;

@Override
public void advance(float amount) {
    months += Global.getSector().getClock().convertToMonths(amount);
    if (months > 1) {
        /*
        YOUR CODE HERE
        */
        months = 0;
    }
}
"months" probably shouldn't be static. That would make it so it stays the same even if you reload or load a different save. Another option is to override BaseCampaignEventListener.reportEconomyMonthEnd()

A possible solution: calling .inflateIfNeeded() on nearby fleets that need this done?
Right, that should solve the problem, and I might end up doing that for ruthless sector, but that approach isn't ideal since it would undermine the purpose of the inflation system if used on too many fleets. Maybe I'm overestimating the memory impact of fleet inflation?

Hey all, love Starsector and I'd like to start making a couple mods for it.

What I'd like to do is make the 'Take All' looting option only loot up to your cargo/fuel limit, prioritizing supplies or high-value commodities.

I've skimmed the Starsector API, but I'm not sure if what I want to do is possible.

Appreciate any pointers in the right direction!
Have you checked out the new Transfer All Items mod?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5703 on: November 20, 2019, 04:47:29 PM »

Right, that should solve the problem, and I might end up doing that for ruthless sector, but that approach isn't ideal since it would undermine the purpose of the inflation system if used on too many fleets. Maybe I'm overestimating the memory impact of fleet inflation?

If it's only fleets that are in the same location and near the player and of that faction, it should be alright. I mean, as you say, it's undermining it, but probably not by a huge amount. If we're talking like 20 big fleets, though, that would probably be more impactful, both in terms of memory use and savefile size.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5704 on: November 20, 2019, 05:01:19 PM »

I'm learning how to mess with variants in code and am a bit confused. The following code does add a ship to the player fleet, but the changes to the variant (just a few methods chosen at random as tests) aren't taking effect. Anyone know the correct method for changing variants? Do you need to construct a brand new VariantAPI object with all the changes and do a replace?

Code: java
FleetMemberAPI customFleetMember = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "hammerhead_Overdriven");
               
customFleetMember.getVariant().clearHullMods();
customFleetMember.getVariant().setVariantDisplayName("MW 2");

playerFleet.getFleetData().addFleetMember(customFleetMember);
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5705 on: November 20, 2019, 05:17:57 PM »

That's a bit strange, I'm not sure why the changes wouldn't show up.

That said, what you're doing would, I believe, change *all* hammerhead_Overdriven variants in the game.

What you want is roughly something like:

Code: java
ShipVariantAPI copy = customFleetMember.getVariant().clone();
copy.setSource(VariantSource.REFIT);

/* make your changes to the variant here */

customFleetMember.setVariant(copy, false, false);
Logged

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5706 on: November 20, 2019, 05:18:27 PM »

How to use spawnDamagingExplosion? I made a DamagingExplosionSpec, but no matter what values i use it doesn't deal any damage, is it the collision? i tried Ship, Fighter, Ray and some others, nothing works (the explosion is caused by a fighter)
Logged
Check out my ships

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5707 on: November 20, 2019, 05:28:43 PM »

I'm learning how to mess with variants in code and am a bit confused. The following code does add a ship to the player fleet, but the changes to the variant (just a few methods chosen at random as tests) aren't taking effect. Anyone know the correct method for changing variants? Do you need to construct a brand new VariantAPI object with all the changes and do a replace?
Pretty sure that would work for a custom variant, but stock variants are strange. Replacing them with a new variant will indeed allow you to make changes. For example, this code snippet from com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddStandardStartingScript.adjustS tartingHulls()
Code: java
		for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
ShipVariantAPI v = member.getVariant().clone();
v.setSource(VariantSource.REFIT);
v.setHullVariantId(Misc.genUID());
member.setVariant(v, false, false);
@Alex: *shakes fist for beating me to it*

If it's only fleets that are in the same location and near the player and of that faction, it should be alright. I mean, as you say, it's undermining it, but probably not by a huge amount. If we're talking like 20 big fleets, though, that would probably be more impactful, both in terms of memory use and savefile size.
Hmm... right. I hadn't considered that in MShadowy's case only SHI fleets would need to be inflated, which should drastically cut down on the need for it. Still might not be worth it for ruthless sector though, as that would need to inflate each fleet the player might hover the mouse over.

How to use spawnDamagingExplosion? I made a DamagingExplosionSpec, but no matter what values i use it doesn't deal any damage, is it the collision? i tried Ship, Fighter, Ray and some others, nothing works (the explosion is caused by a fighter)
Nothing jumps out at me as a likely cause. Maybe post the code you use to call the method?

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5708 on: November 20, 2019, 05:34:47 PM »


Nothing jumps out at me as a likely cause. Maybe post the code you use to call the method?

Code
DamagingExplosionSpec explosion = new DamagingExplosionSpec(1, 600, 300, 20000, 5000, CollisionClass.SHIP, CollisionClass.FIGHTER, 10, 50, 1, 100, new Color(255, 175, 50, 175), new Color(255, 175, 50, 255));
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation());

This is being called by the ship system of a drone with Fighter collision (dunno if important)
Logged
Check out my ships

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5709 on: November 20, 2019, 05:48:41 PM »

That's a bit strange, I'm not sure why the changes wouldn't show up.

That said, what you're doing would, I believe, change *all* hammerhead_Overdriven variants in the game.

What you want is roughly something like:

Code: java
ShipVariantAPI copy = customFleetMember.getVariant().clone();
copy.setSource(VariantSource.REFIT);

/* make your changes to the variant here */

customFleetMember.setVariant(copy, false, false);

Thanks! (And also thanks to Sundog!) That clears up quite a bit about whats going on.

I'm guessing VariantSource.REFIT is needed to inform the game engine of what created the variant and refit is an appropriate enum for code based changes.

One more question, what do the arguments [boolean withRefit, boolean withStatsUpdate] do? I'm planning on eventually swapping modules via code outside of combat, if it makes any difference to what I need to know.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5710 on: November 20, 2019, 05:51:10 PM »

withRefit makes it apply a CR penalty for an in-space refit. withStatsUpdate forces a fleet member stats update which you generally don't need to do. It'll happen automatically anyway, whenever the player opens the fleet screen and... any number of things, really.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5711 on: November 20, 2019, 05:54:10 PM »

I am counseling the user to try a different path deliminator in order to see if that solves it. I will give more info here, if that is desirable, to determine the exact details of what operating system has this behavior and what path deliminator works for it.

Hopefully this will help everyone else encountering this as well.

Yeah, please let me know! I *thought* this was supposed to be fixed for 0.9.1a, hmm.

Weeelllp, unfortunately I think this info might be lost for the moment.  :(

I received confirmation that one of my potential examples fixed the issue, but no further information was given so I don't know the operating system or which proposed fix worked. Reporting the issue was a first post for the account, so there is a chance that the user won't be on the forums any longer to see the question about what, exactly, worked for them. I'll update if this turns out to not be the case.

Silver lining:

Considering how the error occurred in .9 (from what I remember), I can say with a bit of confidence that I think the issue was mostly fixed with 0.9.1a. I don't receive any reports of random nullpointers from ship files failing to be replaced, for instance, and if this were the case then the user who reported this error would never have made it to the campaign in the first place to see the market error.

This leads me to deduce that the file type still having this issue is specifically JSON files. I hope that can narrow it down at least.

*edit* The solutions are in the thread btw. I'll repost that here too for convenience. Bottom of the first page:

https://fractalsoftworks.com/forum/index.php?topic=17278.0
« Last Edit: November 20, 2019, 06:38:22 PM by Morrokain »
Logged

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5712 on: November 20, 2019, 06:01:11 PM »

The explosion seems to be working now, but i can't tell for sure because it gives me this crash now

Code
138540 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamage(Unknown Source)
at com.fs.starfarer.combat.E.A.O0OO.super(Unknown Source)
at com.fs.starfarer.combat.E.A.super(Unknown Source)
at com.fs.starfarer.combat.E.A.super(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.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$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Logged
Check out my ships

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5713 on: November 20, 2019, 06:04:38 PM »

Thanks!

@Ed I think this came up in another thread just recently: http://fractalsoftworks.com/forum/index.php?topic=17262.0

From that I think you need to call spec.setDamageType()
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5714 on: November 20, 2019, 06:26:17 PM »

The explosion seems to be working now
Did you get it to work by changing
Code
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation());
to
Code
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation(), true);
?

As a courtesy to anyone searching for solutions to the same problem, it's generally a good idea to explain the solution to your question in cases like this.
Pages: 1 ... 379 380 [381] 382 383 ... 706