Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 505 506 [507] 508 509 ... 710

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7590 on: June 16, 2021, 03:01:23 PM »

Local variable? Should be fine. Member variable would be a problem because the hull mod effect script in instantiated once per application run and so is shared between saves.

So, no risk of *save bloat* either way, but high risk of bugs/memory leaks if using a member variable to store that person.

It kind of sounds like you might mean member variable rather than local, just based on it being "pilot = " and not "PersonAPI pilot = "...

So, for clarity: local means declared in the function. Member means declared in the class, i.e. something like "private PersonAPI pilot".
Logged

shoi

  • Admiral
  • *****
  • Posts: 658
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7591 on: June 16, 2021, 03:21:42 PM »

Thanks for the extra info..so just to be sure, is basically how it works?
Code
public class armaa_wingCommander extends BaseHullMod {

private PersonAPI pilot; // Member Variable


@Override
    public void addPostDescriptionSection(TooltipMakerAPI tooltip, ShipAPI.HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
{
   PersonAPI pilot = null; // Local Variable
   pilot = OfficerManagerEvent.createOfficer(Global.getSector().getFaction("player"),1, true);
        }
}

Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7592 on: June 16, 2021, 03:25:52 PM »

Right, yes.

(Note: if you actually had both like that, the result of "createOfficer()" would get assigned to the local variable.)
Logged

alaricdragon

  • Commander
  • ***
  • Posts: 163
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7593 on: June 16, 2021, 09:39:38 PM »

hey all
I find myself wanting to have an industry, that when built, makes AI fleets with a home market that has this industry install a certain hullmod onto all there ships. I have learned how to make industries after mush work, but I have no idea how to effect spawned fleets in this manner.
I would also like to have this industry change the fleet's captions portraits and names, if possible, but the hullmod is the main thing.
thanks to all who chose to help in advance.
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 #7594 on: June 17, 2021, 01:41:50 PM »

Ummm, hey Alex...

Did you make:       

Code
stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_LEVEL * 0.01f);

Now remove the boost when shields are up or fighters are engaged? Like:

Code
stats.getAllowZeroFluxAtAnyLevel()

- If so, you completely broke my mod. Any chance that these can be separated out so the old version of the behavior is still possible?

Huh strange... well nvm this is only occurring on a couple of ships. The majority keep the old behavior. I must be doing something weird on my end though I'm not sure what yet.
« Last Edit: June 17, 2021, 01:52:14 PM by Morrokain »
Logged

shoi

  • Admiral
  • *****
  • Posts: 658
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7595 on: June 17, 2021, 02:55:48 PM »

Right, yes.

(Note: if you actually had both like that, the result of "createOfficer()" would get assigned to the local variable.)

awesome. thanks!
Logged

CrescentQuill

  • Ensign
  • *
  • Posts: 14
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7596 on: June 18, 2021, 03:56:35 PM »

This is probably a smoothbrain question, but how do you add new portraits to the game? I can't find any information on it in any of the modding resource threads, and my attempts to figure it out have only let me replace portraits rather than add them.  ???
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 #7597 on: June 18, 2021, 04:30:03 PM »

This is probably a smoothbrain question, but how do you add new portraits to the game? I can't find any information on it in any of the modding resource threads, and my attempts to figure it out have only let me replace portraits rather than add them.  ???

Look at the faction files. There is a section for portraits. Copy and past the entire line and then change the png name to the name of the portrait you want to add. You can either do this in a mod format or add the portrait to the game's relevant graphics folder if its for personal use.
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7598 on: June 19, 2021, 09:23:29 AM »

i have a hullmod that depends on some FleetMemberAPI values, and to get that i would usually use MutableShipStatsAPI.getFleetMember(). when i added a "affectsOPCosts" override set to true, the method applyEffectsBeforeShipCreation was called twice, and the second time has a MutableShipStatsAPI that doesn't have a fleet member assigned to it. (as a side note: i'm pretty sure this MutableShipStatsAPI object is the one that you can find under ShipVariantAPI.getStatsForOpCosts())

is there a way to easily get the fleetmember that doesn't involve looping through every single ship in a fleet and its variant and all of its modules' variants to look for a specific MutableShipStatsAPI object? if i have the hullmod on a lot of ships (tried with 8 ) the game noticably hitches whenever these hullmods run applyEffectsBeforeShipCreation because of the method.

this is what i needed to do as a result, and what also causes the hitching
Spoiler
Code
if(stats.getFleetMember() != null)
            return stats.getFleetMember();

        if(stats.getEntity() instanceof ShipAPI) {
            ShipAPI ship = (ShipAPI) stats.getEntity();
            if(ship.getFleetMember() != null) {
                return ship.getFleetMember();
            }
        }

        FleetMemberAPI fm = null;
        for(FleetMemberAPI member : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
            if(member.isFighterWing()) continue;

            if(member.getStats() == stats) {
                fm = member;
            } else if (member.getVariant().getStatsForOpCosts() != null) {
                if (member.getVariant().getStatsForOpCosts() == stats) {
                    fm = member;
                } else if (member.getVariant().getStatsForOpCosts().getEntity() != null && member.getVariant().getStatsForOpCosts().getEntity() == stats.getEntity()) {
                    fm = member;
                }
            }

            if(fm != null) break;

            if (member.getVariant().getModuleSlots() != null && !member.getVariant().getModuleSlots().isEmpty()) {
                for(String variantId : member.getVariant().getModuleSlots()) {
                    ShipVariantAPI variant = member.getVariant().getModuleVariant(variantId);
                    if(variant.getStatsForOpCosts() == stats) {
                        fm = member;
                    } else if (member.getVariant().getStatsForOpCosts().getEntity() != null && stats.getEntity() == variant.getStatsForOpCosts().getEntity()) {
                        fm = member;
                    }

                    if(fm != null) break;
                }
            }

            if(fm != null) break;
        }
[close]

i worked around this issue by using a Map that i clear when the player exits the market, but it's still annoying that i had to go through so much effort.
i'm having an issue now where the fleet screen shows i have free OP after applying the hullmod through a dialog, but clicking into the refit screen does not show the free OP
« Last Edit: June 19, 2021, 01:31:02 PM by presidentmattdamon »
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 #7599 on: June 19, 2021, 05:33:31 PM »

I can't find where this is implemented, so:

Is:    public static final String AUXILIARY_EFFECT_ADD_PERCENT = "auxiliary_effect_add_percent";

 - Hardcoded to only work with the vanilla implementation of Militarized Subsystems and the two package hullmods? In other words, if I replaced Militarized Subsystems with my own version, will that character stat not do anything to it?

*EDIT*

I guess the other thing to ask here since I've never done it would be, if the above is true, then if I made the variables of my militarized subsystems public and modified them directly using the skill script would that work?


I swear every time I ask something here I answer my own question 30 seconds after posting it. Ugh lol sorry! I see the relevant part in the militarized subsystems hullmod itself. The problem was my implementation was outdated.
« Last Edit: June 19, 2021, 05:43:13 PM by Morrokain »
Logged

CrescentQuill

  • Ensign
  • *
  • Posts: 14
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7600 on: June 20, 2021, 10:19:41 AM »

This is probably a smoothbrain question, but how do you add new portraits to the game? I can't find any information on it in any of the modding resource threads, and my attempts to figure it out have only let me replace portraits rather than add them.  ???

Look at the faction files. There is a section for portraits. Copy and past the entire line and then change the png name to the name of the portrait you want to add. You can either do this in a mod format or add the portrait to the game's relevant graphics folder if its for personal use.

Thanks!
Logged

keantmp

  • Ensign
  • *
  • Posts: 9
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7601 on: June 20, 2021, 11:49:59 AM »

I have a couple questions -

Is there a listener for when a player opens up a colony management screen?

Are the hullmods really spread out half inside starfarer.api.jar and half in /data/hullmods?

Where is the build-in of modules for story points handled?

And a much dumber question: which .java files can be replaced? I can't just replace any class I want in starfarer.api.jar right?
« Last Edit: June 20, 2021, 11:53:23 AM by keantmp »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7603 on: June 22, 2021, 08:15:52 AM »

Are fighter wing IDs required to end in "_wing"? Asking because of this issue; the IDs are correct as far as I can tell.

Is it possible to set a hullmod such that it can't be S-Mod'd a la Saftey Overrides?
Add the no_build_in tag to the hullmod.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7604 on: June 22, 2021, 12:02:54 PM »

Is there a listener for when a player opens up a colony management screen?

Not specifically, but there's a listener for when the player interacts with the colony, opens some submarkets, etc. You can check the ListenerUtil and CampaignEventListener classes for what's available.

Are the hullmods really spread out half inside starfarer.api.jar and half in /data/hullmods?

Yes. The ones in data/hullmods are mostly back when you couldn't bundle jars with the game and the hullmod code was compiled on startup using Janino.

Where is the build-in of modules for story points handled?

In core code.

And a much dumber question: which .java files can be replaced? I can't just replace any class I want in starfarer.api.jar right?

They can be if they're under data/. Stuff in starfarer.api.zip is just source code provided for reference - usually the way to go there would be to provide your own implementation and plug it in using whatever means is appropriate for that specific bit of code (say, via CampaignPlugin.pickXXXPlugin, or via settings.json, etc - you'd want to check how the thing you're replacing is referenced in order to know how to insert your version of it instead).

Are fighter wing IDs required to end in "_wing"? Asking because of this issue; the IDs are correct as far as I can tell.

Yes! The game needs to know whether a variant is a ship or a wing in a few places just from the string...
Logged
Pages: 1 ... 505 506 [507] 508 509 ... 710