Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 439 440 [441] 442 443 ... 710

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

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6600 on: July 01, 2020, 03:42:45 PM »

You should be able to create your own OfficerManagerEvent object to use without side effects. Just make sure you init() it.
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 840
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6601 on: July 01, 2020, 03:49:41 PM »

I've been staring at this too long and am losing my mind over what is, presumably, simple.

Currently re-creating the steps to make Officers and add them to comms for the player to hire, but am falling down at this line of code originally from the OfficerManagerEvent:

     officer.person.getMemoryWithoutUpdate().set("$ome_eventRef", this);

So 'this' needs to be the reference to the callable event, but I cannot work out how to pass a callable event reference here.  So, any officers I make cannot trigger it, and cannot be hired or display their attributes.

Am I making sense, or is there a way to use OfficerManagerEvent I should know about?

Industrial.Evolution Academy does exactly that, feel free to take a look at the code.
Logged

Cabbs

  • Ensign
  • *
  • Posts: 24
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6602 on: July 02, 2020, 06:51:03 AM »

You should be able to create your own OfficerManagerEvent object to use without side effects. Just make sure you init() it.
Industrial.Evolution Academy does exactly that, feel free to take a look at the code.

Thanks for this! its exactly what I needed.
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 683
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6603 on: July 03, 2020, 04:32:18 AM »

Just a quick one: I have a ship that has an engine boosting system, and an engine module. I'd like to disable the ship system if the module is missing, however I'm not sure how to check if a ship has a module. May I ask how to do this, if it's possible at all?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24116
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6604 on: July 03, 2020, 08:42:26 AM »

See: ShipAPI.getChildModulesCopy()
Logged

powerlunatic

  • Ensign
  • *
  • Posts: 3
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6605 on: July 03, 2020, 03:10:22 PM »

Is it possible to split the descriptions.csv into several more .csv files and load them manually via my mod's base plugin? Or is it possible to read them via SettingsAPI's loadCSV then inject it into the database, somehow? If possible, an example or pointer to relevant documentation would be neat!
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6606 on: July 03, 2020, 04:34:20 PM »

Is it possible to split the descriptions.csv into several more .csv files and load them manually via my mod's base plugin? Or is it possible to read them via SettingsAPI's loadCSV then inject it into the database, somehow? If possible, an example or pointer to relevant documentation would be neat!
Even if there was... why would you want to?

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6607 on: July 03, 2020, 04:45:20 PM »

Here's an example of how I read the fleet dialogue csv for a reference to how to read .csv files in general:

Spoiler
public class FDialogue_factionTextLoader {

    /**
     *   Spreadsheet data.
     */
    // The file directory that contains the dialogue options based upon faction id. Each response dialogue category is optional as a default exists.
    private static final String FILE = "data/config/FleetDialogue/factions/FleetDialogue_factionText.csv";
    // End file data.

    // Column ids in FleetDialogue_factionText.csv.
    // Default faction id under "id" column.
    private static String DEFAULT_ID = "default";
    // Additional faction ids can implement any number of dialogue column ids to provide custom responses for the faction.

    // Dialogue column ids.
    // Imports faction dialogue matching any dialogue column ids which are defined here.
    // Responses for each column are based upon an existing faction id in the "id" column.
    // If no faction id exists for a dialogue column, or the corresponding dialogue cell to the faction id is empty, the default response is used instead.
    private static String COMMODITY_REQUEST_DESCRIPTION = "commodityRequestDescription";
    private static String COMMODITY_SUPPLY_REQUEST_DESCRIPTION = "commoditySupplyRequestDescription";
    private static String COMMODITY_FUEL_REQUEST_DESCRIPTION = "commodityFuelRequestDescription";
    private static String COMMODITY_DEMAND_DESCRIPTION = "commodityDemandDescription";
    private static String COMMODITY_REQUEST_PLAYER_UNKNOWN = "commodityRequestPayerUnknown";
    private static String COMMODITY_REQUEST_SUCCESS = "commodityRequestSuccess";
    private static String COMMODITY_REQUEST_SUCCESS_FRIENDLY = "commodityRequestSuccessFriendly";
    private static String COMMODITY_REQUEST_SUCCESS_EXALTED = "commodityRequestSuccessExalted";
    private static String COMMODITY_REQUEST_SUCCESS_SUSPICIOUS = "commodityRequestSuccessSuspicious";
    private static String COMMODITY_REQUEST_SUCCESS_ANNOYED = "commodityRequestSuccessAnnoyed";
    private static String COMMODITY_REQUEST_SUCCESS_HAVETOPAY = "commodityRequestSuccessHaveToPay";
    // End column ids.

    /**
     *   Class data.
     */
    // Logger data. For use in troubleshooting logging only.
    private static final Logger LOG = Global.getLogger(FDialogue_factionTextLoader.class);
    private static final String FACTION_ID_PREFIX = "Faction id: ";
    private static final String NO_VALID_DIALOGUE_COLUMN = " - was found in FleetDialogue_factionText.csv, but no valid entry was found for: ";
    private static final String VALID_DIALOGUE_COLUMN = " - was found in FleetDialogue_factionText.csv, and a valid entry was found for: ";
    private static final String USE_DEFAULT_RESPONSE_FOR_CATEGORY = "Using default dialogue response for: ";
    private static final String CUSTOM_FACTION_ID_PREFIX = "Using custom faction: ";
    private static final String RESPONSE_CATEGORY_PREFIX = " - dialogue response for: ";
    private static final String CUSTOM_FACTION_ID_NOT_FOUND = " - was not found in FleetDialogue_factionText.csv.";
    // End Logger data.
    private static Map<String, Map> FACTION_DIALOGUE = new HashMap<>();
    private static Object CELL_DATA;
   
    public static void readDialogueFile(){
        FACTION_DIALOGUE.clear();
        // Attempt to read the file row by row and store all factions ids in a map containing a nested map of all possible dialogue responses by faction id.
        // Each faction id is the map key to the nested map of possible dialogue implementations for each faction - also contained in a map.
        try {
            JSONArray StringData = Global.getSettings().getMergedSpreadsheetDataForMod("id", FILE, "fleetdialogue_morro");
            for(int i = 0; i < StringData.length(); i++) {
                JSONObject row = StringData.getJSONObject(i);
                Map<String, String> responses = new HashMap<>();
                responses.clear();
                if(row.getString("id") != null){
                    // Set up dialogue response map. Response category keys are hardcoded and called in the various get methods implemented below.
                    // Also checks for missing or empty dialogue responses as a safeguard.
                    if (row.getString(COMMODITY_REQUEST_DESCRIPTION) != null && !row.getString(COMMODITY_REQUEST_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_DESCRIPTION, row.getString(COMMODITY_REQUEST_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_SUPPLY_REQUEST_DESCRIPTION) != null && !row.getString(COMMODITY_SUPPLY_REQUEST_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_SUPPLY_REQUEST_DESCRIPTION, row.getString(COMMODITY_SUPPLY_REQUEST_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_FUEL_REQUEST_DESCRIPTION) != null && !row.getString(COMMODITY_FUEL_REQUEST_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_FUEL_REQUEST_DESCRIPTION, row.getString(COMMODITY_FUEL_REQUEST_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_DEMAND_DESCRIPTION) != null && !row.getString(COMMODITY_DEMAND_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_DEMAND_DESCRIPTION, row.getString(COMMODITY_DEMAND_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_REQUEST_PLAYER_UNKNOWN) != null && !row.getString(COMMODITY_REQUEST_PLAYER_UNKNOWN).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_PLAYER_UNKNOWN, row.getString(COMMODITY_REQUEST_PLAYER_UNKNOWN));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS) != null && !row.getString(COMMODITY_REQUEST_SUCCESS).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS, row.getString(COMMODITY_REQUEST_SUCCESS));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_FRIENDLY) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_FRIENDLY).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_FRIENDLY, row.getString(COMMODITY_REQUEST_SUCCESS_FRIENDLY));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_EXALTED) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_EXALTED).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_EXALTED, row.getString(COMMODITY_REQUEST_SUCCESS_EXALTED));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS, row.getString(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_ANNOYED) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_ANNOYED).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_ANNOYED, row.getString(COMMODITY_REQUEST_SUCCESS_ANNOYED));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_HAVETOPAY) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_HAVETOPAY).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_HAVETOPAY, row.getString(COMMODITY_REQUEST_SUCCESS_HAVETOPAY));
                    }
                    // Add nested map to the faction map under the faction id.
                    FACTION_DIALOGUE.put(row.getString("id"), responses);
                }
            }

            // Log error if dialogue file cannot be parsed correctly.
        } catch (IOException | JSONException ex) {
            LOG.error("unable to read " + FILE);
        }
    }
[close]

 - this stores all your relevant strings from the file in a map which you can use for whatever you want.

An example entry from the file it's reading (screenshot):
Spoiler

[close]

As far as actually adding those strings to descriptions for hulls, I actually doubt that is possible but Alex would have to chime in. I think it is handled on the game load only.

If it's containted in the persistant data, though, then maybe something like:

Spoiler
        JSONObject descriptions = (JSONObject) Global.getSector().getPersistentData().get("descriptions");
        Object yourID = "hullID";
        Object yourType = "SHIP";
        Object yourDescription = "description";
        Object yourRole = "role";
        try {
            descriptions.put("id", yourID);
            descriptions.put("type", yourType);
            descriptions.put("text1", yourDescription);
            descriptions.put("text2", yourRole);
        } catch (JSONException e) {
            LOG.error(e);
        }
        Global.getSector().getPersistentData().put("descriptions", descriptions);
[close]

*Might* work, but it depends upon the format it is kept in and I don't think that is documented anywhere.
Logged

Professor Pinkie

  • Ensign
  • *
  • Posts: 23
  • Best cupcakes in a sector!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6608 on: July 04, 2020, 07:32:09 AM »

So, I made a simple hullmod. And it works as it should. How do i make it incompatible with specific hullmod (efficiency overhaul)? I can always:
Code
@Override
public boolean isApplicableToShip(ShipAPI ship) {
return !ship.getVariant().getHullMods().contains("efficiency_overhaul");
}

public String getUnapplicableReason(ShipAPI ship) {
if (ship.getVariant().getHullMods().contains("efficiency_overhaul")) {
return "Incompatible with Efficiency Overhaul";
}

That will prevent my mod to be used with Efficiency Overhaul, but it will not prevent Efficiency Overhaul to be installed if my mod is built-in.

Shall I add some strings to EfficiencyOverhaul.java somehow? Or even overwrite it? There should be an easier way.

Also, which is the best way to make randomly generated NPC variants obey that rule?
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 840
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6609 on: July 04, 2020, 08:38:40 AM »

the newest version of MagicLib has a pre made Hullmod incompatibility feature. I'd suggest you check it out, saves time and problems with bugs in the future!
Logged

Professor Pinkie

  • Ensign
  • *
  • Posts: 23
  • Best cupcakes in a sector!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6610 on: July 04, 2020, 09:38:39 AM »

I don’t want to offend Mr.Tartiflette in any way, but every time I try to figure out his scrolls, I want to cry.

Not because the library is bad, but because I know Java so well, that I make two mistakes when I just write "Java". Glory to the spell checker!

In this particular example, I can only guess what needs to be done. My best guess is:

1.Add this to the title:
Code
import data.scripts.util.MagicIncompatibleHullmods;
import data.scripts.util.MagicTxt;
import static data.scripts.util.MagicTxt.getString;

2. And this to the body:
Code
if(stats.getVariant().getHullMods().contains("efficiency_overhaul")){

   MagicIncompatibleHullmods.removeHullmodWithWarning(stats.getVariant(), "efficiency_overhaul", "my_hullmod_name");

}

And it ain't work... And I am not surprised. ;D

Vanilla scripts, made by Alex are more intuitive to me for <profanity> reverse engineering.
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 #6611 on: July 04, 2020, 10:22:17 AM »

So, I made a simple hullmod. And it works as it should. How do i make it incompatible with specific hullmod (efficiency overhaul)? I can always:
Spoiler
Code
@Override
public boolean isApplicableToShip(ShipAPI ship) {
return !ship.getVariant().getHullMods().contains("efficiency_overhaul");
}

public String getUnapplicableReason(ShipAPI ship) {
if (ship.getVariant().getHullMods().contains("efficiency_overhaul")) {
return "Incompatible with Efficiency Overhaul";
}
[close]

That will prevent my mod to be used with Efficiency Overhaul, but it will not prevent Efficiency Overhaul to be installed if my mod is built-in.

Shall I add some strings to EfficiencyOverhaul.java somehow? Or even overwrite it? There should be an easier way.

Also, which is the best way to make randomly generated NPC variants obey that rule?

It is interesting to me that the built in part of this matters. Rather, can you not equip your hullmod first and then be able to equip efficiency overhaul because it doesn't contain a check for your hullmod? If you can't, it might be related to the utility mod cap and that is why it seems to need to be built in, I'd think, though I could be wrong.

Anyway, you would have to override the efficiency overhaul mod itself to prevent that from being installed afterwards by adding the reverse of your check to it, if so. Assuming you can't get MagicLib to work.

(I'm not familiar with MagicLib but are you sure you have the parameters in the correct order? That's one thing that could be going wrong. Does the log say anything?)
Logged

Professor Pinkie

  • Ensign
  • *
  • Posts: 23
  • Best cupcakes in a sector!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6612 on: July 04, 2020, 11:03:14 AM »

Quote
(I'm not familiar with MagicLib but are you sure you have the parameters in the correct order? That's one thing that could be going wrong. Does the log say anything?)

I am sure that the order is wrong. Other would be strange. I did not save the log.

Quote
It is interesting to me that the built in part of this matters. Rather, can you not equip your hullmod first and then be able to equip efficiency overhaul because it doesn't contain a check for your hullmod? If you can't, it might be related to the utility mod cap and that is why it seems to need to be built in, I'd think, though I could be wrong.

Built-in matters. If I add my hullmod first (not built-in), and then efficiency overhaul, my hullmod removes itself from the build and can not be equipped until efficiency overhaul is removed. In this state, the rule is fulfilled, although in one direction. But if I made my hullmod built-in, it is possible to add efficiency overhaul, while my hullmod remain active (can not be removed?).

I can’t add lines to the vanilla code. and rewrite it completely - create compatibility issues.
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 #6613 on: July 04, 2020, 11:46:37 AM »

I can’t add lines to the vanilla code. and rewrite it completely - create compatibility issues.

It doesn't necessarily have to, just fyi.

1) Copy the hullmod from the source into your own hullmods folder. Add your check to the code. Give it a unique name.

2) Copy the line from hullmods.csv and in the script column point to your unique one instead of the vanilla one. Leave everything else unchanged.

3) For your mod id, add some "??" before it.

csv files merge and any duplicate entries of vanilla ids outside of vanilla (so from other mods trying to edit this as well - vanilla will be overridden in any case) are loaded and overridden reverse-alphabetically. Adding the "??" ensures that you will be the first one loaded and so the first one overridden if another mod also edits it.

That should handle any incompatibility with other mods - though it will in-turn allow the user to equip both hullmods when it is built-in in the case that another mod does override your check so be aware of that for troubleshooting purposes.

Having MagicLib work is likely a more ideal solution, but just letting you know you have options.  :)
« Last Edit: July 04, 2020, 11:49:35 AM by Morrokain »
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 #6614 on: July 04, 2020, 12:15:13 PM »

Sorry if I have asked this in the past I honestly can't remember. Is there anything in the weapon file json that supports preventing the ship from active venting while the weapon is firing a burst? (Specifically beams)

My Tachyon Lance version has a long cooldown and is active for ~2.5 seconds and sometimes the AI starts it and only lets it burst for .5 to 1 second then immediately vents to keep the low flux boost. Even frontloading the damage still wastes the cooldown to a large degree. (Not to mention cutting off a rather cool sound effect if I do say so myself  :D )

I can handle this with AI variants by ensuring they have enough flux cap and dissipation to not do this, but many users might not be aware of why this is happening and I'd rather just disable the behavior all together if possible so that it is more obvious (due to a maxed flux bar on firing or no firing at all) to the user what the problem with their loadout is.

If a combat script is required, any examples to reference would be great! Thanks.
Logged
Pages: 1 ... 439 440 [441] 442 443 ... 710