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 ... 566 567 [568] 569 570 ... 706

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

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8505 on: February 11, 2022, 08:17:23 AM »



<my post>


Hmm - mainly I'm amazed that this works at all, not that it breaks somewhat. Once a ship exists, changes to the variant are not going to be reflected in the ship - all of the weapons etc for the ship have been created, so changing the variant should have at best no effect. Or, at worst, it might break things if some ship code expects the variant to still match what the ship was created from.

You were right to be amazed that it worked, it straight up didn't lmao
I've got the base sprite being replaced and I completely forgot to make sure the weapons were actually getting replaced, after checking for that I found out that the slots would get cleared but not refilled by addweapon().
It seems odd that addweapon() works for the thing that inspired this venture (apex design collective's variable warheads) and not this, the "only" differences I can see are a normal weap vs a deco weap being replaced & the slot initially being empty in the .ship file (this is where I think its going wrong - I did a test w/ replacing all weaps and it would clear the builtin but not add it back)

at the same time as all this I moved all the swapping into applyEffectsBeforeShipCreation() (due to probably misunderstanding your comment) and it seems to work the same, right down to not working in the same way :')

before creation deco swapper
Code
        ShipVariantAPI variant = stats.getVariant();
        ShipVariantAPI variantClone = variant.clone();

        for (WeaponSlotAPI slot : variantClone.getHullSpec().getAllWeaponSlotsCopy()) {

            String slotid = slot.getId();
            String replacementWeapId = variantClone.getWeaponId(slotid);

            if (replacementWeapId == null) {
                continue;
            }

            boolean hasSwapped = !replacementWeapId.contains(prefix);

            boolean isBlinker = !replacementWeapId.contains("blinker"); //checks for "not armour deco" stuff start
            boolean isGlow = !(replacementWeapId.contains("glow") || replacementWeapId.contains("light"));
            boolean isEmpCore = !replacementWeapId.contains("empcore");
            boolean isShadow = !replacementWeapId.contains("shadow");

            if (slot.isDecorative() && hasSwapped && isBlinker && isGlow && isEmpCore && isShadow) {
                variant.clearSlot(slotid);
                variant.addWeapon(slotid, prefix + replacementWeapId);
            }
        }
[close]
hopefully this makes sense, I've been bashing my head against this for a bit and I'm not sure if I'm getting anywhere

AccuracyThruVolume

  • Commander
  • ***
  • Posts: 133
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8506 on: February 12, 2022, 04:40:57 PM »

I have a hullmod that boosts the range of energy weapons.   I want to also give a chance of causing a flameout on each engine when firing any large energy weapon when flux is above 50%.   How is the best way to implement this?  Can it be done as part of the hullmod or does it need to be linked to something else that captures when a large energy weapon is fired by a ship that has this hullmod?

Logged

itBeABruhMoment

  • Commander
  • ***
  • Posts: 157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8507 on: February 13, 2022, 09:04:44 AM »

Currently I'm using the code below to add a hull of a specific variant to AI fleets. "variantId" always correspond to some variant specified in a .variant file somewhere. Is cloning the variantAPI necessary here? Also, ships added using this method have missing cr, is there any way to ensure they have an appropriate amount of cr after they get added?

Code
private static void createAndAddVariant(CampaignFleetAPI fleetAPI, String variantId)
{
    System.out.println(variantId);
    FleetMemberAPI ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, Global.getSettings().getVariant(variantId).clone());
    fleetAPI.getFleetData().addFleetMember(ship);
}

Edit: If you're using a script run by reportFleetSpawned from BaseCampaignEventListener you can do fleet.setInflated(true) to prevent autofit. This method appears to be called before the inflater is applied. Something like this
Code
@Override
    public void reportFleetSpawned(CampaignFleetAPI fleet) {
       fleet.setInflated(true);
    }
« Last Edit: February 22, 2022, 06:04:11 PM by itBeABruhMoment »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8508 on: February 13, 2022, 10:24:04 AM »

You were right to be amazed that it worked, it straight up didn't lmao
I've got the base sprite being replaced and I completely forgot to make sure the weapons were actually getting replaced, after checking for that I found out that the slots would get cleared but not refilled by addweapon().
It seems odd that addweapon() works for the thing that inspired this venture (apex design collective's variable warheads) and not this, the "only" differences I can see are a normal weap vs a deco weap being replaced & the slot initially being empty in the .ship file (this is where I think its going wrong - I did a test w/ replacing all weaps and it would clear the builtin but not add it back)

at the same time as all this I moved all the swapping into applyEffectsBeforeShipCreation() (due to probably misunderstanding your comment) and it seems to work the same, right down to not working in the same way :')
...
hopefully this makes sense, I've been bashing my head against this for a bit and I'm not sure if I'm getting anywhere[/s]

Hmm. It's actually kind of hard to say - there could be some internal reasons why this can't work, but they're not coming to mind right now.

I'd suggest doing something *super* simple - like hardcoding the mod to replace one deco weapon in a specific slot with another - to see if that works at all and if the culprit is somewhere in the replacement logic, or something more fundamental.


I have a hullmod that boosts the range of energy weapons.   I want to also give a chance of causing a flameout on each engine when firing any large energy weapon when flux is above 50%.   How is the best way to implement this?  Can it be done as part of the hullmod or does it need to be linked to something else that captures when a large energy weapon is fired by a ship that has this hullmod?

You probably want to modify the engine flameout chance in your implementation of the HullModEffect.advanceInCombat() method, based on whether any large weapons are firing/flux state/etc. Something along those lines, anyway!


Currently I'm using the code below to add a hull of a specific variant to AI fleets. "variantId" always correspond to some variant specified in a .variant file somewhere. Is cloning the variantAPI necessary here? Also, ships added using this method have missing cr, is there any way to ensure they have an appropriate amount of cr after they get added?

Code
private static void createAndAddVariant(CampaignFleetAPI fleetAPI, String variantId)
{
    System.out.println(variantId);
    FleetMemberAPI ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, Global.getSettings().getVariant(variantId).clone());
    fleetAPI.getFleetData().addFleetMember(ship);
}

Why not use the alternate version of FactoryAPI.createFleetMember() that takes a variantId as the second parameter?

For CR: you'd need to set it using FleetMemberAPI.getRepairTracker().
Logged

hqz

  • Lieutenant
  • **
  • Posts: 73
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8509 on: February 16, 2022, 04:14:50 AM »

Is there a way to mod the list of starting ships options when starting a new game?

And is there a way to disable (or mod away) the slipstreams? I found a reference to com.fs.starfarer.api.impl.campaign.velfield.SlipstreamTerrainPlugin2 in data/campaing/terrain.json but I'm not sure how this works.
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 #8510 on: February 17, 2022, 11:30:43 AM »

Is there a way to mod the list of starting ships options when starting a new game?

Look at data/campaign/rules.csv under the "new game options" portion and also be sure to reference the scripts it calls. I know its either in rules itself or in one of the scripts that rules calls. I'm 80% sure its in rules itself though.

You can add a rule by the same name with a higher score to override the vanilla rule and then set what ships you want. Keep in mind that this won't work when running Nex.

I highly recommend SafariJohn's Rule Tool if you are going to mess with rules in any capacity.
Logged

hqz

  • Lieutenant
  • **
  • Posts: 73
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8511 on: February 17, 2022, 04:20:25 PM »

Look at data/campaign/rules.csv under the "new game options" portion and also be sure to reference the scripts it calls. I know its either in rules itself or in one of the scripts that rules calls. I'm 80% sure its in rules itself though.

You can add a rule by the same name with a higher score to override the vanilla rule and then set what ships you want. Keep in mind that this won't work when running Nex.

I highly recommend SafariJohn's Rule Tool if you are going to mess with rules in any capacity.

Thanks. This is super helpful.
Logged

itBeABruhMoment

  • Commander
  • ***
  • Posts: 157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8512 on: February 17, 2022, 06:06:34 PM »

I'm trying to disable autofit for ai fleets. First of all, is there a simple way of doing this (ie calling some method)? If not, when do ships in ai fleets get autofit applied to them? I'm using this method to build fleets and they still end up with autofit.

Code

private static void createAndAddVariant(CampaignFleetAPI fleetAPI, String variantId)
{
      FleetMemberAPI ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variantId);
      fleetAPI.getFleetData().addFleetMember(ship);
}

Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8513 on: February 18, 2022, 09:30:48 AM »

And is there a way to disable (or mod away) the slipstreams? I found a reference to com.fs.starfarer.api.impl.campaign.velfield.SlipstreamTerrainPlugin2 in data/campaing/terrain.json but I'm not sure how this works.

IIRC you'd want to remove the SlipstreamManager via something like Global.getSector().removeScriptsOfClass(SlipstreamManager.class)

(Probably not exactly, just typing this from memory.)

You'd need to do it onGameLoad().


I'm trying to disable autofit for ai fleets. First of all, is there a simple way of doing this (ie calling some method)? If not, when do ships in ai fleets get autofit applied to them? I'm using this method to build fleets and they still end up with autofit.

I think it should be as simple as:
fleet.setInflater(null);
Logged

default

  • Lieutenant
  • **
  • Posts: 80
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8514 on: February 18, 2022, 11:08:20 AM »

I was looking through mod files to see how different mods are organized and function so I can get an idea of how I want mine to be set up, and I have a few questions.
First, why do some mods have a "shaders" folder with a material, normal, and surface folder which have different looking images? The "normal" ones look very odd. Is there a function reason for this, or is it preference?
Second, How would I go about making my own engine style? I know other mods have their own engine flare colors/styles, but I can't seem to find where any of them are in mod files so I would be able to infer what to do or what to name the image. Then after the new engine style is created, what would I have to do in the ship editor to actually apply it to my ships?
Logged
"There's nothing like a trail of blood to find your way back home."

shoi

  • Admiral
  • *****
  • Posts: 650
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8515 on: February 20, 2022, 12:36:12 AM »

Say there's a battle where you deploy a ship several times over multiple engagements. Is there a way to determine how many times you did so?
Is reportPlayerEngagement basically this as far as returning individual engagements during a battle?
yep thats it, hurray for experimentation
« Last Edit: February 20, 2022, 01:06:59 AM by shoi »
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8516 on: February 20, 2022, 05:33:21 AM »

I was looking through mod files to see how different mods are organized and function so I can get an idea of how I want mine to be set up, and I have a few questions.
First, why do some mods have a "shaders" folder with a material, normal, and surface folder which have different looking images? The "normal" ones look very odd. Is there a function reason for this, or is it preference?
Second, How would I go about making my own engine style? I know other mods have their own engine flare colors/styles, but I can't seem to find where any of them are in mod files so I would be able to infer what to do or what to name the image. Then after the new engine style is created, what would I have to do in the ship editor to actually apply it to my ships?

Material, normal, and surface maps are used by the GraphicsLib mod's shader engine. Normal maps let a flat surface pretend to be 3D when calculating lighting.

Engine styles are defined in data/config/engine_styles.json. I have always found it easier to manually set custom engine styles, but I think you can load them into the ship editor using Load Custom (M)od Data and then set each engine to your style by editing its de(T)ails.
Logged

default

  • Lieutenant
  • **
  • Posts: 80
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8517 on: February 20, 2022, 08:57:46 AM »

Material, normal, and surface maps are used by the GraphicsLib mod's shader engine. Normal maps let a flat surface pretend to be 3D when calculating lighting.

So it's not something that has to be done, it's just if you want things to look better?
Logged
"There's nothing like a trail of blood to find your way back home."

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8518 on: February 20, 2022, 09:21:05 AM »

Correct. I usually use ModLab to quickly generate my normal maps. https://store.steampowered.com/app/768970/ModLab/
Logged

itBeABruhMoment

  • Commander
  • ***
  • Posts: 157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8519 on: February 21, 2022, 11:43:07 AM »

Is there any way to set an unofficered ship's personality before battle? The ai of unofficered ships get set "in combat" so any changes made using setPersonality on unofficered ships before battle seems to get overridden. If not, would a every frame combat script that run setPersonality on the PersonAPI's of relevant ships work? CombatFleetManagerAPI setDefaultCommander also seems promising.
« Last Edit: February 21, 2022, 11:51:29 AM by itBeABruhMoment »
Logged
Pages: 1 ... 566 567 [568] 569 570 ... 706