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: Hostile Activity (09/01/22)

Pages: 1 ... 600 601 [602] 603 604 ... 613

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

AccuracyThruVolume

  • Lieutenant
  • **
  • Posts: 94
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9015 on: August 11, 2022, 06:59:05 PM »

Is is possible to have a ship spawn other ships when it is deployed into battle?   I'm looking to make a ship that spawns a few special ships (small frigates that are then basically frigates) and also have carrier wings.   

As an alternate can a ship spawn ships when deployed and also have them treated as its fighters if it has other fighter wings already?
« Last Edit: August 12, 2022, 07:38:36 AM by AccuracyThruVolume »
Logged

Mr_Castinfon

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9016 on: August 12, 2022, 08:21:10 AM »

I asked reddit, I made thread on the forum and no one answered my questions please just help me I wanna learn
Here's the copy paste of my questions:


I have an idea for a cool mod that I wanna try making and I wanna see if certain things are even possible to do. So here they are.

Can I remove the original factions?
The mod is set outside the Perseus sector and, logically, the hegemony, luddics, sindria and the other guys aren't gonna exist there, so how can I remove them for my custom factions?

How do I remove the core worlds?
My sector won't be centralized, i.e., there is no core worlds and it's just a big cluster of stars. Is there a way to alter the generation to get that kind of effect? I was told on reddit to look at how Nexerelin handles random core worlds, so if anyone can explain the details?

How do I add my own derelicts
Different sector, different lore. So, how can I add something like the gates or probes In vanilla and have my own ways of how to interact with them.

How do I change something for the base game?
There are a few things in vanilla that I wanna keep, but slightly altered. Like, for example, if I think the Kite shuttle looks *** and I wanna change its look, how can I do that while keeping it's stats.

Please, if anyone can answer anything I'll be so grateful
Logged

Histidine

  • Admiral
  • *****
  • Posts: 3972
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9017 on: August 12, 2022, 07:36:46 PM »

I asked reddit, I made thread on the forum and no one answered my questions please just help me I wanna learn
Here's the copy paste of my questions:


I have an idea for a cool mod that I wanna try making and I wanna see if certain things are even possible to do. So here they are.

Can I remove the original factions?
The mod is set outside the Perseus sector and, logically, the hegemony, luddics, sindria and the other guys aren't gonna exist there, so how can I remove them for my custom factions?

How do I remove the core worlds?
My sector won't be centralized, i.e., there is no core worlds and it's just a big cluster of stars. Is there a way to alter the generation to get that kind of effect? I was told on reddit to look at how Nexerelin handles random core worlds, so if anyone can explain the details?

How do I add my own derelicts
Different sector, different lore. So, how can I add something like the gates or probes In vanilla and have my own ways of how to interact with them.

How do I change something for the base game?
There are a few things in vanilla that I wanna keep, but slightly altered. Like, for example, if I think the Kite shuttle looks *** and I wanna change its look, how can I do that while keeping it's stats.

Please, if anyone can answer anything I'll be so grateful
Okay, my actual first advice is to start small. Make a mod that changes one of the things you want (say adds a new derelict type or generates a star system), then implement another change in it, and so on.
If you haven't already seen it, the Intro to Modding page on wiki is a helpful resource.

Short answers to the specific questions:
Spoiler
Removing vanilla factions
The most direct way is to have your mod be a total conversion and override the faction list, but this kills compatibility with other mods, so it's not desirable. That said, you can make a faction basically not be there if it has no colonies and is hidden from the intel screen. We'll cover not spawning a faction in the next point.
(I'm not sure how best to make vanilla blueprints not appear in salvage, figure that out later)

Don't spawn vanilla sector
Nexerelin's settings.json contains this table:
Code: json
	"plugins":{
"coreLifecyclePlugin":"exerelin.plugins.NexCoreLifecyclePlugin",
"newGameCreationEntryPoint":"exerelin.world.ExerelinNewGameSetup",

"nex_restoreCommanderPlugin":"exerelin.combat.RestoreCommanderPlugin",
},
The relevant plugin is the newGameCreationEntryPoint one.
The important code of that plugin starts here, but the key point is you generate your own stars instead of the vanilla ones (how to generate stars is a separate exercise).

Discoverable stuff
Look in the game's API* (you can find the source in starsector-core/starfarer.api.zip) for com.fs.starfarer.api.impl.campaign.procgen.themes.SectorThemeGenerator.

Code: java
	public static List<ThemeGenerator> generators = new ArrayList<ThemeGenerator>();

static {
generators.add(new DerelictThemeGenerator());
generators.add(new RemnantThemeGenerator());
generators.add(new RuinsThemeGenerator());
generators.add(new MiscellaneousThemeGenerator());
}
You can add/remove generators to the list from an external mod script. Look at each of the generators to see how they work.

Changing vanilla stuff
Your mod can modify non-code vanilla files, e.g. you could replace the Kite sprite, or change its stats in the .ship file or ship_data.csv row.

JSON-type definition files (like .ship and .weapon) have merging between vanilla and all running mods, so your mod file only needs to include the values that have changed.
For CSVs, you'll need to replace the whole row.
[close]
Logged

Histidine

  • Admiral
  • *****
  • Posts: 3972
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9018 on: August 12, 2022, 07:40:17 PM »

Is is possible to have a ship spawn other ships when it is deployed into battle?   I'm looking to make a ship that spawns a few special ships (small frigates that are then basically frigates) and also have carrier wings.   

As an alternate can a ship spawn ships when deployed and also have them treated as its fighters if it has other fighter wings already?
I think you could put the frigates on the mothership as modules, and make them detach when the ship is deployed.

To manually spawn ships directly, here's an example from SWP's Arcade mission.
Code: java
            FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variant);
            member.getRepairTracker().setCR(0.7f);
            member.getRepairTracker().setMothballed(false);
            member.getRepairTracker().setCrashMothballed(false);
            member.getCrewComposition().setCrew(member.getMinCrew());
            ship = engine.getFleetManager(side).spawnFleetMember(member, tempLoc, -90, 0);
            ship.getLocation().set(tempLoc);
            ship.setOriginalOwner(side.ordinal());
            ship.setOwner(side.ordinal());
            variantId = variant.getHullVariantId();
Logged

Ruddygreat

  • Commander
  • ***
  • Posts: 244
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9019 on: August 13, 2022, 05:53:02 AM »

Is is possible to have a ship spawn other ships when it is deployed into battle?   I'm looking to make a ship that spawns a few special ships (small frigates that are then basically frigates) and also have carrier wings.   

As an alternate can a ship spawn ships when deployed and also have them treated as its fighters if it has other fighter wings already?

CombatFleetManagerAPI has SpawnShipOrWing (and lazylib has SpawnShipOrWingDirectly in it's combatUtils), you can use either of those to spawn ships whenever you want

here's an example piece of code from something I've used it for in a system
Code

if (!doneOnce) {

            FleetSide cloneSide = FleetSide.ENEMY; //probably a better way of doing this but this works
            if (ship.getOriginalOwner() == 0) {
                cloneSide = FleetSide.PLAYER;
            }

            fleetManager.setSuppressDeploymentMessages(true); //hides the "incoming ship" message
            ShipAPI otherShip = spawnShipOrWingDirectly(
                    varID,
                    FleetMemberType.SHIP,
                    cloneSide,
                    ship.getCurrentCR(),
                    safeLoc,
                    ship.getFacing() + Misc.getAngleInDegrees(safeLoc, loc)
            );
            fleetManager.setSuppressDeploymentMessages(false); //turns it back on
            doneOnce = true; //can only spawn one ship per system activation

            ship.setCustomData(PairKey, otherShip.getId()); //tells the parent ship what it's child ship is, you'll want a different method (probs hashmap?) to keep track of what spawned what if you're doing multiple child ships
        }

Timid

  • Admiral
  • *****
  • Posts: 535
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9020 on: August 16, 2022, 07:14:08 AM »

is there a vanilla method that checks whether a faction is heavy-industry less that they have to rely on shipimporting or would I make one to iterate thru all markets that have a non-disrupted heavy industry?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20790
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9021 on: August 16, 2022, 07:27:17 AM »

Hmm. Something like:

ShipQuality.getInstance().getQualityData(market).quality.getFlatBonuses().containsKey("no_prod_penalty")

Might do it, but it requires a market rather than a faction and is a bit dodgy so all in all I'd suggest just iterating over the markets.
Logged

alaricdragon

  • Lieutenant
  • **
  • Posts: 51
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9022 on: August 16, 2022, 05:42:55 PM »

hey all, random silly question:
is there a way to run code directly after an market calculates all its data? I was using an market condition to run code like this, but it only ran after most of the other code, and was causing issues with not being able to change certain data because it didn't exist yet (mostly things that ran in other market conditions). and that was frustrating to put it simply.
i guess what I'm asking is: can i run code after everything in an market has been calculated? or if that's not possible, is there a way to run my market condition last?
thank you for the help all.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20790
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9023 on: August 17, 2022, 08:14:17 AM »

Hmm - depending on what you need, you might look at EconomyUpdateListener or EconomyTickListener. It wouldn't be exactly what you're asking, but using one of these, you could make sure that your code 1) runs periodically and 2) runs before the player interacts with the colony screen.
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 117
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9024 on: August 17, 2022, 08:53:10 AM »

something about showing interaction dialog using Global.getSector().getCampaignUI().showInteractionDialog clears the player fleet's (or maybe it's any SectorEntityToken) active person (set using Global.getSector().getPlayerFleet().setActivePerson(PersonAPI)). i got around it with a subclass of the rule based interaction dialog plugin that just sets the active person on init, but i was wondering if this was intended
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20790
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9025 on: August 17, 2022, 09:39:20 AM »

Yes, it's intended - the active person is not meant to be a persistent value.
Logged

Timid

  • Admiral
  • *****
  • Posts: 535
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9026 on: August 17, 2022, 05:06:12 PM »

A user report concluded that this type of nullcheck can't be used for any of the Spec getters mainly because...
Code
if (Global.getSettings().getHullSpec("swp_alastor_xiv") != null) {}
even if swp_alastor_xiv didn't or did exist, it would never return null.

Would it be possible for it to return null if it didn't exist? I don't know how else I could be able to do a nullcheck for modded hull and weapons with this current version.

SafariJohn

  • Admiral
  • *****
  • Posts: 2592
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9027 on: August 17, 2022, 05:13:36 PM »

You could use try-catch if you really needed to.
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 117
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9028 on: August 18, 2022, 11:00:12 PM »

is there a way to get access to the skill level descriptions (LevelBasedEffect i think) used by skill tooltips so that i can create them in a custom panel?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20790
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9029 on: August 19, 2022, 07:30:24 AM »

Aside from running the code directly, I don't think so. I mean, the descriptions are in code, and put together with code, so I'm not really sure what you're asking.
Logged
Pages: 1 ... 600 601 [602] 603 604 ... 613