Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 442 443 [444] 445 446 ... 710

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

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6645 on: July 13, 2020, 12:22:03 AM »

In BattleCreationContext, what's the difference between aiRetreatAllowed and fightToTheLast?
Logged

Mayu

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6646 on: July 13, 2020, 12:29:43 AM »

change
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
to
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id, -2);
"" denotes a string (also called text) in java. You just modified the id by adding a "-2" to it, while the actual modifier was 0.
consider using an IDE; it will make your life easier.

It worked nicely, thank you very much Sir Hartley! Also, I'll follow your advice about using IDE.  :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6647 on: July 13, 2020, 09:14:44 AM »

In BattleCreationContext, what's the difference between aiRetreatAllowed and fightToTheLast?

"fightToTheLast" will make the AI give "full assault" orders at a time when it would usually give full retreat orders. So it might still retreat a ship or two piecemeal before that point, unless "aiRetreatAllowed" is also set.

(Not the best or cleanest of distinctions, to be perfectly honest, I think I wasn't thinking about "aiRetreatAllowed" existing when adding "fightToTheLast", and that was part of a multi-pronged approach to help solve a specific problem - cleanup of the last few ships being tedious - so it's just pretty narrow and specific.)
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 #6648 on: July 14, 2020, 02:45:03 PM »

Been digging around the API, and though I know I can clear known hullmods from factions (to replace them with custom versions), I can't seem to find a way to set a vanilla hullmod to HIDDEN (so it won't spawn in markets) through code instead of the csv file. Is this possible, or is this even necessary? Does removing them from variants and the known hullmods list prevent them from showing up in markets? I know it prevents them from showing up in autofit fleets, but I wasn't sure about the market part.

Also, if the above is true, do they ever spawn randomly in loot?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6649 on: July 14, 2020, 03:21:14 PM »

Isn't there a HullModSpecAPI.setHidden() method? Might not be in the current release, hmm.

IIRC the stuff for sale is from the faction's known hullmods. As far as drops, yeah, they could drop if they're not hidden, since drops are based on tags. I *think* if you add a no_drop tag to the hullmod it won't drop but I'm not 100% sure that in the currently-released version all the drop groups respect the tag.
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 #6650 on: July 14, 2020, 03:35:30 PM »

Isn't there a HullModSpecAPI.setHidden() method? Might not be in the current release, hmm.

IIRC the stuff for sale is from the faction's known hullmods. As far as drops, yeah, they could drop if they're not hidden, since drops are based on tags. I *think* if you add a no_drop tag to the hullmod it won't drop but I'm not 100% sure that in the currently-released version all the drop groups respect the tag.

There might be but I can't verify because: The problem is that I can't seem to find a way to get the list of all HullModSpecAPIs from Global. I haven't thoroughly checked, to be sure, but I can't find anything that actually returns that object. Maybe it is in persistentData? If so, what is the key and return value? List, Map, Set, etc?

If I can get access to those I can both add that tag and set them as hidden and hope for the best! And that way I can set it up to be configurable in settings. Otherwise I just have to use the csv override, but it's better than nothing!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6651 on: July 14, 2020, 03:41:04 PM »

Ah - SettingsAPI has:
List<HullModSpecAPI> getAllHullModSpecs();

I highly recommend checking the javadoc, here:
http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

In this case for example you could open up the page for SettingsAPI (which has all this kind of stuff) and search for "hullmod".
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 #6652 on: July 14, 2020, 03:46:41 PM »

Ah - SettingsAPI has:
List<HullModSpecAPI> getAllHullModSpecs();

I highly recommend checking the javadoc, here:
http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

In this case for example you could open up the page for SettingsAPI (which has all this kind of stuff) and search for "hullmod".

Ah thanks! Most helpful! Never would have thought it would be under settings. I don't check that doc as often as I should. I generally assume the IDE can handle the searching, but keyword searching from the doc is much better here if I have no clue where to start. Good point!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6653 on: July 14, 2020, 03:47:43 PM »

(Yeah, SettingsAPI is the place for almost everything that's not specific to a particular savegame.)
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 #6654 on: July 14, 2020, 05:26:10 PM »

(Yeah, SettingsAPI is the place for almost everything that's not specific to a particular savegame.)

Ah, interesting. I'll try to remember that.
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 #6655 on: July 15, 2020, 01:13:44 PM »

When using the boolean = removeAll(Collection), does it assume that each value in the collection actually exists in the set in question?

I'm using:

Code
        Iterator<FactionAPI> allFactions = Global.getSector().getAllFactions().iterator();
        Map<String, String> vanillaFactions = vanillaIDsDatabase.getFactionIDs();
        while (allFactions.hasNext()) {
            if (vanillaFactions.containsKey(allFactions.next().getId())) {
                if (!allFactions.next().getKnownFighters().removeAll(vanillaIDsDatabase.getOverriddenFighterWingIDs().values())) {
                    LOG.error("Could not remove all overridden vanilla fighter wings from " + allFactions.next().getId());
                }
                if (!allFactions.next().getPriorityFighters().removeAll(vanillaIDsDatabase.getOverriddenFighterWingIDs().values())) {
                    LOG.error("Could not remove all overridden priority vanilla fighter wings from " + allFactions.next().getId());
                }
            }
        }

This:
- Checks to make sure the faction is a vanilla one.
- Uses the values() method of a map containing the fighter wing ids for each vanilla fighter to remove them all from known fighters and priority fighters.
- Logs if this wasn't successful. Not sure if it logs if one isn't removed or only if all aren't removed.

Log:
Spoiler
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla hullmods from remnant
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla hullmods from hegemony
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from poor
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from independent
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla fighter wings from persean
42158 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from knights_of_ludd
42158 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla fighter wings from adamantine_consortium
42158 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from tritachyon
[close]

Annnd looking at this... why the heck is it trying to do that for admantine_consortium?? That's not even in the ids map and should have failed the containsKey() check!  Arrgh that... doesn't make any sense! >:(

*EDIT*
Wait a minute, trying to think back to college but I think I understand what's going on now. I need to assign the Iterator.next() to a FactionAPI instead and use that when I need to check multiple things.

It's not failing the containsKey() it's just going to the next FactionAPI every time I call the next() method! *Feels dumb*

Anyway the initial question remains. Would it be better to iterate through the values, check for them to exist in the set and them remove them one by one? Or should passing in the collection do the job? Thanks!

Map contents:
Spoiler
public class VanillaIDsDatabase {

    private static final Map<String, String> FACTION_IDS = new HashMap<>();
   private static final Map<String, String> HULLMOD_IDS = new HashMap<>();
    private static final Map<String, String> FIGHTER_SHIP_IDS = new HashMap<>();
   private static final Map<String, String> FIGHTER_WING_IDS = new HashMap<>();

   public void initMaps() {

       // Vanilla faction ids.
        FACTION_IDS.put("hegemony", "hegemony");
        FACTION_IDS.put("luddic_church", "luddic_church");
        FACTION_IDS.put("luddic_path", "luddic_path");
        FACTION_IDS.put("sindrian_diktat", "sindrian_diktat");
        FACTION_IDS.put("derelict", "derelict");
        FACTION_IDS.put("independent", "independent");
        FACTION_IDS.put("knights_of_ludd", "knights_of_ludd");
        FACTION_IDS.put("lions_guard", "lions_guard");
        FACTION_IDS.put("persean_league", "persean_league");
        FACTION_IDS.put("pirates", "pirates");
        FACTION_IDS.put("remnant", "remnant");
        FACTION_IDS.put("scavengers", "scavengers");
        FACTION_IDS.put("tritachyon", "tritachyon");

        // Currently overridden vanilla hullmod ids.
       HULLMOD_IDS.put("advancedoptics", "advancedoptics");
       HULLMOD_IDS.put("turretgyros", "turretgyros");
       HULLMOD_IDS.put("magazines", "magazines");
       HULLMOD_IDS.put("missleracks", "missleracks");
       HULLMOD_IDS.put("extendedshieldemitter", "extendedshieldemitter");
       HULLMOD_IDS.put("frontemitter", "frontemitter");
        HULLMOD_IDS.put("fluxcoil", "fluxcoil");
        HULLMOD_IDS.put("fluxdistributor", "fluxdistributor");
        HULLMOD_IDS.put("converted_hangar", "converted_hangar");
        HULLMOD_IDS.put("operations_center", "operations_center");
        HULLMOD_IDS.put("frontshield", "frontshield");
        HULLMOD_IDS.put("heavyarmor", "heavyarmor");
        HULLMOD_IDS.put("targetingunit", "targetingunit");
        HULLMOD_IDS.put("adaptiveshields", "adaptiveshields");
        HULLMOD_IDS.put("safetyoverrides", "safetyoverrides");
        HULLMOD_IDS.put("stabilizedshieldemitter", "stabilizedshieldemitter");
        HULLMOD_IDS.put("dedicated_targeting_core", "dedicated_targeting_core");
        HULLMOD_IDS.put("augmentedengines", "augmentedengines");
        HULLMOD_IDS.put("expanded_deck_crew", "expanded_deck_crew");
        HULLMOD_IDS.put("unstable_injector", "unstable_injector");
        HULLMOD_IDS.put("armoredweapons", "armoredweapons");
        HULLMOD_IDS.put("autorepair", "autorepair");

        // Add vanilla fighter ship definition ids.
        FIGHTER_SHIP_IDS.put("talon", "talon");
        FIGHTER_SHIP_IDS.put("dagger", "dagger");
        FIGHTER_SHIP_IDS.put("wasp", "wasp");
        FIGHTER_SHIP_IDS.put("xyphos", "xyphos");
        FIGHTER_SHIP_IDS.put("broadsword", "broadsword");
        FIGHTER_SHIP_IDS.put("piranha", "piranha");
        FIGHTER_SHIP_IDS.put("trident", "trident");
        FIGHTER_SHIP_IDS.put("longbow", "longbow");
        FIGHTER_SHIP_IDS.put("mining_drone", "mining_drone");
        FIGHTER_SHIP_IDS.put("gladius", "gladius");
        FIGHTER_SHIP_IDS.put("warthog", "warthog");
        FIGHTER_SHIP_IDS.put("thunder", "thunder");
        FIGHTER_SHIP_IDS.put("claw", "claw");
        FIGHTER_SHIP_IDS.put("hoplon", "hoplon");
        FIGHTER_SHIP_IDS.put("spark", "spark");
        FIGHTER_SHIP_IDS.put("lux", "lux");
        FIGHTER_SHIP_IDS.put("flash", "flash");
        FIGHTER_SHIP_IDS.put("perdition", "perdition");
        FIGHTER_SHIP_IDS.put("cobra", "cobra");

        // Add vanilla fighter wing ids.
        FIGHTER_WING_IDS.put("talon_wing", "talon_wing");
        FIGHTER_WING_IDS.put("xyphos_wing", "xyphos_wing");
        FIGHTER_WING_IDS.put("gladius_wing", "gladius_wing");
        FIGHTER_WING_IDS.put("warthog_wing", "warthog_wing");
        FIGHTER_WING_IDS.put("thunder_wing", "thunder_wing");
        FIGHTER_WING_IDS.put("claw_wing", "claw_wing");
        FIGHTER_WING_IDS.put("wasp_wing", "wasp_wing");
        FIGHTER_WING_IDS.put("dagger_wing", "dagger_wing");
        FIGHTER_WING_IDS.put("piranha_wing", "piranha_wing");
        FIGHTER_WING_IDS.put("trident_wing", "trident_wing");
        FIGHTER_WING_IDS.put("perdition_wing", "perdition_wing");
        FIGHTER_WING_IDS.put("cobra_wing", "cobra_wing");
        FIGHTER_WING_IDS.put("longbow_wing", "longbow_wing");
        FIGHTER_WING_IDS.put("mining_drone_wing,", "mining_drone_wing,");
        FIGHTER_WING_IDS.put("flash_wing", "flash_wing");
        FIGHTER_WING_IDS.put("spark_wing", "spark_wing");
        FIGHTER_WING_IDS.put("lux_wing", "lux_wing");
   }

    public Map<String, String> getFactionIDs() {
        return FACTION_IDS;
    }

   public Map<String, String> getOverriddenHullmodIDs() {
        return HULLMOD_IDS;
    }

    public Map<String, String> getOverriddenFighterShipIDs() {
        return FIGHTER_SHIP_IDS;
    }

    public Map<String, String> getOverriddenFighterWingIDs() {
        return FIGHTER_WING_IDS;
    }
}

[close]

*EDIT 2*

Ahh, nvm - missed this part of the interface documentation:     * @return <tt>true</tt> if this set changed as a result of the call

I only read the description at first and that part didn't seem clear. Should of kept reading. ::)
Hmm, now I'm wondering why the call is returning false so often. The set should have changed. Sigh, back to the drawing board.
« Last Edit: July 15, 2020, 03:07:45 PM by Morrokain »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6656 on: July 15, 2020, 05:42:30 PM »

I feel like the check here is actually unnecessary. You're removing stuff and it's going to remove stuff. The only reason you'd care about the return value is if you need to know whether all the things you passed in were present and removed, or not.

But regardless of that, the outcome is that the set you're removing things from will not have *any* of the things passed in to removeAll() - so unless I'm missing something, I don't think you need to check.
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 #6657 on: July 15, 2020, 05:58:26 PM »

I feel like the check here is actually unnecessary. You're removing stuff and it's going to remove stuff. The only reason you'd care about the return value is if you need to know whether all the things you passed in were present and removed, or not.

But regardless of that, the outcome is that the set you're removing things from will not have *any* of the things passed in to removeAll() - so unless I'm missing something, I don't think you need to check.

Agreed yeah. I wasn't understanding the method correctly until I caught that part of the interface doc. At one point IntelliJ weirdly wanted me to apply the method to a boolean.. but it's not now. Not sure why it was at the time. I've removed the check and logged the necessary sets after the call was made, and so far they all work correctly.

Once I verify each facet of the override is doing what it should, I'll probably remove the logging altogether- with the exception for when a spec is returned null by its id- just in case it ever changes for some reason.
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6658 on: July 17, 2020, 10:14:09 AM »

Is it possible to get a hullmod to remove/unequip specific fighter wings on the refit screen when certain conditions are met? I am able to remove fighter bays, but the fighters stay equipped and hidden, taking up OP.
Logged

Mondaymonkey

  • Admiral
  • *****
  • Posts: 777
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6659 on: July 17, 2020, 10:22:47 AM »

Is it possible to get a hullmod to remove/unequip specific fighter wings on the refit screen when certain conditions are met? I am able to remove fighter bays, but the fighters stay equipped and hidden, taking up OP.

stats.getVariant().clear();

Spoiler
Joke
[close]
Logged
I dislike human beings... or I just do not know how to cook them well.
Pages: 1 ... 442 443 [444] 445 446 ... 710