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 ... 352 353 [354] 355 356 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5295 on: October 03, 2019, 06:50:55 PM »

Yep!
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5296 on: October 03, 2019, 11:39:07 PM »

Which integer represents which side in CombatEntityAPI.getOwner()? Is it 0, 1, -100 for player, opponent, neutral?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5297 on: October 04, 2019, 08:23:48 AM »

0 = player/ally, 1 = enemy, 100 = neutral.
Logged

outdated

  • Lieutenant
  • **
  • Posts: 58
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5298 on: October 04, 2019, 02:05:50 PM »

Can you stick a hullmod on a fighter and would ground support hullmod work, or does a fighter effectively not exist before it's carrier is deployed?
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5299 on: October 04, 2019, 04:12:17 PM »

does a fighter effectively not exist before it's carrier is deployed?
I'm afraid that is the case, yeah. If you want fighters to confer ground-support-like bonuses, you're probably better off not involving hullmods.

If you get stumped and can put a minimal mod together to reproduce this, I can take a look.
I decided to take you up on this. Mini-mod is attached. It shows a recovery dialog any time reportShownInteractionDialog is called. The recovery dialog works without issue if I feed it the player flagship, but not a newly created one, so I must be failing to properly initialize the ship. However, I can't find anything that ShipRecoverySpecial is doing that I'm not, so I don't know what I'm missing. Again, thanks for the help!

[attachment deleted by admin]

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5300 on: October 04, 2019, 05:03:11 PM »

Aha!

See the last couple of lines here:

Code
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;

Random rand = new Random();

ship.setOwner(1);
ship.getStatus().setRandom(rand);
ship.getStatus().setHullFraction(0.1f);
ship.getRepairTracker().setCR(0f);

ShipVariantAPI variant = ship.getVariant();
variant = variant.clone();
variant.setOriginalVariant(null);

int dModsAlready = DModManager.getNumDMods(variant);
int dmods = Math.max(0, 5 - dModsAlready);
DModManager.setDHull(variant);
ship.setVariant(variant, false, true);

DModManager.addDMods(ship, true, dmods, rand);

float retain = 0.5f;
FleetEncounterContext.prepareShipForRecovery(ship, false, false, retain, retain, rand);
ship.getVariant().autoGenerateWeaponGroups();
           
CampaignFleetAPI recoverable = Global.getFactory().createEmptyFleet(Factions.NEUTRAL, FleetTypes.PATROL_SMALL, true);
recoverable.getFleetData().addFleetMember(ship);

Looks like you need to add the FleetMemberAPI to a faked-up AI fleet - otherwise, it's considered to have no crew and thus zero recovery rate. ShipRecoverySpecial does this but your code wasn't; tried the above change and it works.

Thank you for making this easy to test - especially having the code in loose scripts was really handy to be able to verify the change actually working.
Logged

Sundog

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

Ah, excellent. Thank you! I thought those lines were irrelevant since the fleet instance is only used locally for something unrelated. I didn't consider what the fleet might be doing to the ship once added.

Thank you for making this easy to test - especially having the code in loose scripts was really handy to be able to verify the change actually working.
Heh. You saved me a great deal of time by taking a look at this. The least I could do is make it easier for you to help me  ;)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5302 on: October 04, 2019, 07:08:02 PM »

Glad that's sorted, sorry it turned out to be so arcane! I was scratching my head for a bit when I saw the "normal" recovery FleetMember referring to a "neutral small patrol" :)
Logged

captinjoehenry

  • Commander
  • ***
  • Posts: 100
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5303 on: October 04, 2019, 07:15:12 PM »

How do I add a military market to an non player market?  I'm asking as there are no independent military markets in game that I can find and I feel like there really probably should be one so I'm wondering how I can add one in. 
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5304 on: October 04, 2019, 07:35:18 PM »

Glad that's sorted, sorry it turned out to be so arcane!
Heh. No worries. If it weren't something arcane I'd be kicking myself for missing it  :)

How do I add a military market to an non player market?  I'm asking as there are no independent military markets in game that I can find and I feel like there really probably should be one so I'm wondering how I can add one in. 
I don't know how to do that off the top of my head, but you should visit Nortia in Askonia, which has a size 4 independent military market. Not sure if there are others.

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5305 on: October 04, 2019, 07:40:50 PM »

I updated a mod that adds some ships (prv Starworks, specifically). Now, in my existing save, the list
Code: java
List<ShipVariantAPI> targets = Global.getSector().getAutofitVariants().getTargetVariants(ship.getHullId());
can contain entries that are null, for some of the ships in the updated mod.
The null entries don't appear to exist in a new game.

How do I make the null variants go away?

How do I add a military market to an non player market?  I'm asking as there are no independent military markets in game that I can find and I feel like there really probably should be one so I'm wondering how I can add one in. 
To add a military market one-time in current game: Console while docked at the planet/station, then undock and redock
Code
runcode Global.getSector().getCampaignUI().getCurrentInteractionDialog().getInteractionTarget().getMarket().addSubmarket("generic_military")
To apply this to every future game, open [starsector-core]/data/campaign/econ/<systemname>.json and add a "militarybase" to the industries table of the relevant planet or station.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5306 on: October 04, 2019, 08:18:07 PM »

I updated a mod that adds some ships (prv Starworks, specifically). Now, in my existing save, the list
Code: java
List<ShipVariantAPI> targets = Global.getSector().getAutofitVariants().getTargetVariants(ship.getHullId());
can contain entries that are null, for some of the ships in the updated mod.
The null entries don't appear to exist in a new game.

How do I make the null variants go away?

I don't think you can - looking at the code, if they're null, it's a stock variant that's no longer present. But this is a more generally troublesome condition - i.e. if there's a fleet that has one of these, or a derelict that's based on one of them, etc, those could all crash the game at some point.
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5307 on: October 05, 2019, 12:29:25 AM »

How would I just detect when the player fleet undocks from a market or docks into a market then deduct him a $1 credit every time for each ship in his fleet he tries to dock and undock?
« Last Edit: October 05, 2019, 11:26:57 AM by Techpriest »
Logged

Dwarden

  • Commander
  • ***
  • Posts: 196
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5308 on: October 05, 2019, 10:18:56 AM »

q, is there way how simply change the star-system grid max-size (for me it seems it's 26k x 26k ) ?

for custom (new) star-system ofc
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5309 on: October 05, 2019, 11:43:57 AM »

How would I just detect when the player fleet undocks from a market or docks into a market then deduct him a $1 credit every time for each ship in his fleet he tries to dock and undock?

See: CampaignEventListener.reportPlayerOpenedMarket() and SectorAPI.addListener()

q, is there way how simply change the star-system grid max-size (for me it seems it's 26k x 26k ) ?

<checks> looks like that's suuuuper hardcoded, sorry!
Logged
Pages: 1 ... 352 353 [354] 355 356 ... 706