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 ... 600 601 [602] 603 604 ... 706

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

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9015 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

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9016 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: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9017 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9018 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

  • Commander
  • ***
  • Posts: 145
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9019 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9020 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: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9021 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9022 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: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9023 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: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9024 on: August 17, 2022, 05:13:36 PM »

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

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9025 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9026 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

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9027 on: August 19, 2022, 10:15:07 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.

i'm listing skills from officers. i was asking if there's a way to get a list of the LevelBasedEffect that each SkillSpecAPI level has, which are defined by the effectGroups in the JSON files, instead of needing to write a map into my mod with all vanilla and modded skills. as far as i can tell there's no way to get them without hardcoding it. maybe i could read the skill JSON files myself? not sure.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9028 on: August 19, 2022, 10:43:38 AM »

Ahh, I see - yeah, reading the json files might be your best bet.

Alternatively, you might use TooltipMakerAPI.addSkillPanel() - the skills should have full tooltips there.
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9029 on: August 19, 2022, 11:03:26 AM »

Alternatively, you might use TooltipMakerAPI.addSkillPanel() - the skills should have full tooltips there.

i will have to read JSON then, as the addSkillPanel methods i have access to all have name labels which i don't think i can remove. thanks!
Logged
Pages: 1 ... 600 601 [602] 603 604 ... 706