Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 501 502 [503] 504 505 ... 710

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

michail

  • Lieutenant
  • **
  • Posts: 88
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7530 on: June 06, 2021, 12:36:16 PM »

I'm taking this waaaay to seriously, but: I'd like to set up a gitlab CI pipeline for a silly mod I'm making. It needs the API jar to compile, of course. Am I correct assuming that the terms of LICENSE.txt make it's a no-go?
You are fine, already asked Alex for that, and he said OK: https://fractalsoftworks.com/forum/index.php?topic=5061.msg298924#msg298924

Also, I have some pipelines set up in my template (uses Gradle, fetches all deps automatically and bundles starsector.api.jar): https://github.com/jaghaimo/starsector-mod

Awesome, thank you. I can't use your template because I'm using a different build tool (just... couldn't bring myself to use gradle in my spare time), but will snatch dependencies' versions from it.

(Oh, I missed this one - apologies!)

It'd be very wrong of me to complain.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7531 on: June 06, 2021, 12:38:13 PM »

Thanks! Final final question: Adding story points, possible?
(All together, this should give me a way to refund story points for "uninstalled" hullmods of mine that had been S-Mod'd.)

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7532 on: June 06, 2021, 01:35:32 PM »

A hullmod that removes itself is easy. Getting a hullmod to add itself, now that would be a clever trick.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7533 on: June 06, 2021, 01:41:14 PM »

Well I'm aiming for a particularly clever trick myself:
A content mod that you can, to the surface user, disable without breaking saves!

S-Mods are just the last hurdle.

EDIT: Right, so what I got is this:
Code
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.rulecmd.AddStoryPoints;

public class YunruDummy extends BaseHullMod {

    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
        if (ship.getVariant().hasHullMod("YunruDummy")) {
            if (ship.getVariant().getSMods().contains("YunruDummy")) {
                AddStoryPoints(1);
            }
            ship.getVariant().removeMod("YunruDummy");
        }
    }
But VSCode is telling me this:
"The method AddStoryPoints(int) is undefined for the type"

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7534 on: June 06, 2021, 04:06:58 PM »

Use:
Code: java
Global.getSector().getPlayerStats().addStoryPoints(1);
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 #7535 on: June 06, 2021, 04:26:54 PM »

But VSCode is telling me this:
"The method AddStoryPoints(int) is undefined for the type"

Also, if you need to use a rule command in code at any point in the future, it's a bit more complicated.

This:

Code
AddStoryPoints(1);

Should be:

Code
AddStoryPoints addStoryPoints = new AddStoryPoints();
addStoryPoints.execute();

"execute()" requires a ruleId String, the dialogue interaction's InteractionDialogueAPI (which can be null I think if nothing in the rule uses it), the List<Token> of whatever parameters you would put into the rule call (This will vary by the rule itself. Some have none.), and finally, it also requires the memory map from the interaction dialogue (iirc that's where you can get it).

So example assuming you don't need the interaction dialogue or memory map:

Code
                List<Misc.Token> list = new LinkedList<>();
                Misc.Token token = new Misc.Token("1", Misc.TokenType.LITERAL);
                list.add(0, token);
                addStoryPoints.execute("id", null, list, null);
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7536 on: June 06, 2021, 06:19:42 PM »

A much more concise example of using a rule command in code:

Code: java
new EndConversation().execute(null, dialog, Misc.tokenize("NO_CONTINUE"), memoryMap);

Most commands require a dialog and a memory map or they will NPE
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7537 on: June 06, 2021, 10:57:52 PM »

I'm afraid all of that went right over my head, especially given the differing complexities of the answers received.

EDIT:
I've also discovered something confusing going on. Here is my code:
Code: java
package data.scripts;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class YunruDummyRefinedPropellant extends BaseHullMod {

    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
        if (ship.getVariant().hasHullMod("yunru_refined_propellant")) {
            if (ship.getVariant().getSMods().contains("yunru_refined_propellant")) {
                Global.getSector().getPlayerStats().addStoryPoints(1);
            }
            ship.getVariant().removeMod("yunru_refined_propellant");
            ship.getVariant().removePermaMod("yunru_refined_propellant");
            ship.getVariant().removeSuppressedMod("yunru_refined_propellant");
        }
    }
   
    @Override
    public String getDescriptionParam(int index, HullSize hullSize) {
        if (index == 0) return "";
        return null;
    }
}
And yet, when it runs, I end up with three extra story points instead of one?

Harpuea

  • Lieutenant
  • **
  • Posts: 59
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7538 on: June 07, 2021, 05:41:41 AM »

How do I make a ship disappear from the player fleet on the campaign map? The ship is a shuttle that should be stored within the carrier, therefore it shouldn't show to be cruising around along with the player fleet.

I tried using mod plugin and set alpha color to 0, but that didn't work. There's also the issue of the engine trail too.

Code
public class cdm_modplugin
  extends BaseModPlugin{

public PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship) {    
    if (ship.getVariant().hasHullMod("combat_docking_module")) {
    ship.setAlphaMult(0f); //Invisible?
      return new PluginPick<ShipAIPlugin>(new combat_docking_AI(ship), CampaignPlugin.PickPriority.MOD_GENERAL);
    }
    return super.pickShipAI(member, ship);
  }
}
Logged

Kenshkrix

  • Ensign
  • *
  • Posts: 46
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7539 on: June 07, 2021, 12:08:17 PM »

EDIT:
I've also discovered something confusing going on. Here is my code:
SNIP
And yet, when it runs, I end up with three extra story points instead of one?
In the API, applyEffectsAfterShipCreation says:
 Effects applied here should NOT affect ship stats as this does not get called from the campaign. Apply stat changes in applyEffectsBeforeShipCreation() instead, as that does affect the campaign.

So maybe try putting it in applyEffectsBeforeShipCreation instead?
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 #7540 on: June 07, 2021, 02:19:00 PM »

I'm afraid all of that went right over my head, especially given the differing complexities of the answers received.

SafariJohn's example is the best for your use case. I was more breaking it down part by part for learning purposes.

(Well, that and it gets more appealing to build the list the more parameters needed for the rule, but iirc most vanilla rules have only one parameter anyway. I have one that has like 7 or 8 and for that the concise way would not be very readable.)
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7541 on: June 07, 2021, 05:18:57 PM »

The 3 SP being added issue is because a hullmod's apply methods are called 3 or more times when a ship is created to make sure everything is in order. You need to use some sort of check to make sure that code is only executed once. I don't have time to provide an example right now, sorry.
Logged

Sutopia

  • Admiral
  • *****
  • Posts: 1005
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7542 on: June 07, 2021, 05:32:49 PM »

How do I get wing's base speed from FighterWingSpecAPI?
Logged


Since all my mods have poor reputation, I deem my efforts unworthy thus no more updates will be made.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7543 on: June 07, 2021, 06:06:30 PM »

How do I make a ship disappear from the player fleet on the campaign map? The ship is a shuttle that should be stored within the carrier, therefore it shouldn't show to be cruising around along with the player fleet.

I tried using mod plugin and set alpha color to 0, but that didn't work. There's also the issue of the engine trail too.

Code
public class cdm_modplugin
  extends BaseModPlugin{

public PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship) {    
    if (ship.getVariant().hasHullMod("combat_docking_module")) {
    ship.setAlphaMult(0f); //Invisible?
      return new PluginPick<ShipAIPlugin>(new combat_docking_AI(ship), CampaignPlugin.PickPriority.MOD_GENERAL);
    }
    return super.pickShipAI(member, ship);
  }
}

The code you're running there would affect the in-combat ship. The ship is a fighter in a fighter bay, right? I don't think there's any way to hide those in the campaign, at least not that I can think of, unfortunately.

How do I get wing's base speed from FighterWingSpecAPI?

Something like wing.getVariant().getHullSpec(). ... huh, it doesn't look like that's actually exposed there! Let me add a .getEngineSpec() method.

That wouldn't give you the true in-combat speed necessarily, though, if it was modified for that variant via a hullmod. If you're doing this in combat, you'd want to ultimately get hold of a ShipAPI for one of the fighters and get it from that.

Logged

alaricdragon

  • Commander
  • ***
  • Posts: 163
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7544 on: June 07, 2021, 09:54:01 PM »

hey i was trying to do something crazy with hull mods.
in fact i was trying to do a few things.
dose anyone know how to:
make a hullmod place other hullmods on a ship when it is install.
    -i saw a mod that added a hullmod, forget its name, that only installed when equipping a gun on ship, so i know this is possable. no idea were to find it though, so i cant use it as a base
tell when a given hullmod is 'built in' (with story points) on a ship.

make a hullmod interface with a fleet to add crew to it (for calculating things like planet surveys, or salvaging), but not be real crew?

plz don't tell me its a bad idea. life is a bad idea but I'm going to do it anyway. i just wanna roll play, and i dont have the imagination to pretend that the crew im doing everything with is not crew
« Last Edit: June 07, 2021, 10:08:44 PM by alaricdragon »
Logged
Pages: 1 ... 501 502 [503] 504 505 ... 710