Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 451 452 [453] 454 455 ... 458

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

Morrokain

  • Admiral
  • *****
  • Posts: 1476
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6780 on: September 19, 2020, 03:38:38 PM »

Is there a guide on how to set up Submarkets on existing worlds? I wanna make a special shop that only sell a few specific ships on some core worlds.

I don't think so, but to get you started:

1) Make a new class that extends BaseSubmarketPlugin and create the logic to do what you want. For an example, see: com\fs\starfarer\api\impl\campaign\submarkets\BlackMarketPlugin.java (This is a good reference point for doing lots of things with the BaseSubmarketPlugin.)

2) Add an entry in Submarkets.csv (starsector-core\data\campaign) which points to your plugin. (Note: Your version of the csv from a mod standpoint must match the path of vanilla's csv and share the same name in order to merge into the games list of submarkets.)

3) Now the submarket is available with an id. My recommendation would be to add that id to the Submarkets enum in case you need it in enum form for other methods, but for adding a submarket to the MarketAPI of an entity you can just use the id I believe.

4) Create a script to find the markets you want through their entity ids and add the new submarket to them.

5) Add the script to your mod plugin - onNewGameAfterEconomyLoad() or onNewGame() is probably the best place.

(EDIT: More informative in this format and I may expand it. For any details of any component of the explanation - or any additional clarification - post here or PM me!)
« Last Edit: September 19, 2020, 09:42:27 PM by Morrokain »
Logged

Ed

  • Captain
  • ****
  • Posts: 436
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6781 on: September 20, 2020, 07:48:22 AM »

That helped a lot Morrokain, i just need now a sample code on how to search for markets and add the submarket during the onNewGameAfterEconomyLoad()
I looked for mods that have special submarkets, i know of Tahlan for GH shop, but i can't find where in the plugin code is the part where the submarket is added.

« Last Edit: September 20, 2020, 09:48:31 AM by Ed »
Logged
Check out my ships

SafariJohn

  • Admiral
  • *****
  • Posts: 1756
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6782 on: September 20, 2020, 08:32:09 AM »

MarketAPI.addSubmarket() IIRC
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 1476
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6783 on: September 20, 2020, 09:31:12 AM »

That helped a lot Morrokain, i just need now a sample code on how to search for markets and add the submarket during the onNewGameAfterEconomyLoad()
I looked for mods that have special submarkets, i know of Tahlan for GH shop, but i can't find where in the plugin code is the part where the submarket is added.

Here is code I use to remove a submarket. Just switch it with the add method like SafariJohn already mentioned and use the id you added to the spreadsheet.

Code:
Spoiler
Code
package archeus.campaign.world.factions;

        import com.fs.starfarer.api.Global;
        import com.fs.starfarer.api.campaign.SectorAPI;
        import com.fs.starfarer.api.campaign.SectorEntityToken;
        import com.fs.starfarer.api.campaign.StarSystemAPI;
        import com.fs.starfarer.api.campaign.econ.MarketAPI;
        import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
        import org.apache.log4j.Logger;

public class RemoveSubmarketsForLuddicChurchStations {

    private static final Logger LOG = Global.getLogger(RemoveSubmarketsForLuddicChurchStations.class);

    public void set(SectorAPI sector, boolean logInfo) {
        StarSystemAPI system = sector.getStarSystem("canaan");
        if (system == null) {
            if (logInfo) {
                LOG.info("Canaan system was not found.");
            }
            return;
        }
        SectorEntityToken fortress = system.getEntityById("gilead_fortress");
        if (fortress == null) {
            if (logInfo) {
                LOG.info("Entity gilead_fortress was not found in the " + system.getId() + " system.");
            }
            return;
        }
        MarketAPI market = fortress.getMarket();
        if (market == null) {
            if (logInfo) {
                LOG.info("A market was not found for " + fortress.getId() + " in the " + system.getId() + " system.");
            }
            return;
        }
        market.removeSubmarket(Submarkets.SUBMARKET_OPEN);
        market.removeSubmarket(Submarkets.SUBMARKET_BLACK);
        if (logInfo) {
            LOG.info("Removed open market and black market from " + fortress.getId() + " in the " + system.getId() + " system.");
        }
    }
}
[close]

And here is how its implemented in the mod plugin:

Spoiler
Code
    @Override
    public void onNewGameAfterEconomyLoad() {
        SectorAPI sector = Global.getSector();

        // Removes submarkets for restricted faction markets like Gilead Fortress.
        new RemoveSubmarketsForLuddicChurchStations().set(sector, LOG_INFO);
    }
[close]
Logged

Ed

  • Captain
  • ****
  • Posts: 436
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6784 on: September 20, 2020, 09:48:52 AM »

thanks, got it

But now how do i make it so the market only sell pristine quality ships?

-edit-

I think i found out what i was doing wrong, i copied the submarket script from another mod, now I am looking at it properly. Ok fixed, wonderful!

« Last Edit: September 20, 2020, 10:07:58 AM by Ed »
Logged
Check out my ships

Ed

  • Captain
  • ****
  • Posts: 436
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6785 on: September 20, 2020, 02:43:12 PM »

How do i start a quest from an unique NPC or by entering a system instead of using random bar events?
I wanna make Wurgandal unique by making it so you can only gain it in a quest, but i want it to be easy to start the quest, just hard to do.

My plan is having the player going to a high danger [Redacted] system, either finding it randomly or having an unique NPC tell him about it (talk to the NPC in the comms of a station)
Finds a wreck, fight a huge [Redacted] armada, and get the ship core
Go to a special NPC, deliver the core and earn 500k as reward or pay extra 10 million to get the ship instead
Later if the player regrets choosing the money he can buy the ship for 15 million.
Logged
Check out my ships

N1MH

  • Ensign
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6786 on: September 22, 2020, 08:00:09 PM »

What would be the difficulty level of modifying the entropy amplifier system into making it lower a ships time acceleration like the scarabs system but for the enemy?

Only know how to modify code, not make my own yet.
Logged

Ed

  • Captain
  • ****
  • Posts: 436
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6787 on: September 23, 2020, 07:52:44 AM »

What would be the difficulty level of modifying the entropy amplifier system into making it lower a ships time acceleration like the scarabs system but for the enemy?

Only know how to modify code, not make my own yet.
Simple, you can check my code (Ed shipyards) in the spatial swap system I boost the defenses of the ally being swapped before the swap happens, you could instead of applying a buff to an ally, apply a debuff an enemy, save the debuffed enemy and unapply the debuff after the duration of the system ends (remember to check if the debuffed enemy is still alive when doing so)
Logged
Check out my ships

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17028
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6788 on: September 23, 2020, 09:09:52 AM »

How do i start a quest from an unique NPC or by entering a system instead of using random bar events?
I wanna make Wurgandal unique by making it so you can only gain it in a quest, but i want it to be easy to start the quest, just hard to do.

By entering a system: you'd need to have a script that checks for this, and once the conditions are met, starts the mission removes itself.

From a unique NPC: you'd probably want to write a custom rule command to do it.
Logged

Ed

  • Captain
  • ****
  • Posts: 436
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6789 on: September 23, 2020, 10:05:33 AM »

How do i start a quest from an unique NPC or by entering a system instead of using random bar events?
I wanna make Wurgandal unique by making it so you can only gain it in a quest, but i want it to be easy to start the quest, just hard to do.

By entering a system: you'd need to have a script that checks for this, and once the conditions are met, starts the mission removes itself.

From a unique NPC: you'd probably want to write a custom rule command to do it.
After looking at bar events they seem better than expected, I will try a bar event first.
Logged
Check out my ships

Jaghaimo

  • Lieutenant
  • **
  • Posts: 65
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6790 on: September 29, 2020, 02:45:01 PM »

Until now, I have been building my mod using libs from Starsector directly. As I want to set up a CI pipeline for my mod I don't have those available, and downloading whole Starsector each commit just to extract few JARs is bad. Fortunately all of those (other than starfarer.api.jar) are available in a Maven repo. So far this works (compiles fine) but I'd want to use exact versions Starsector uses (these are slighly modified from 0.8.1a).

  • Could you tell what versions of libraries Starsector uses?
  • Could you host just starfarer.api.jar so integration becomes easier please (AWS or Maven repository)?
  • Alternatively, are you fine with bundling starfarer.api.jar in a mod repo (again, for build / pipeline ease)?
Thanks!

Code
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
    implementation group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: '2.9.3'
    implementation group: 'org.lwjgl.lwjgl', name: 'lwjgl_util', version: '2.9.3'
    implementation group: 'log4j', name: 'log4j', version: '1.2.9'
    implementation group: 'org.json', name: 'json', version: '20170516'
    implementation group: 'net.java.jinput', name: 'jinput', version: '2.0.7'
    implementation group: 'org.codehaus.janino', name: 'janino', version: '3.0.7'
« Last Edit: September 29, 2020, 02:48:02 PM by Jaghaimo »
Logged
Stellar Logistics - courier services
Hyperspace Network - information services

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17028
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6791 on: September 29, 2020, 03:31:27 PM »

  • Could you tell what versions of libraries Starsector uses?

Ah, I'm sorry, I don't remember offhand! That info is probably buried in commit comments somewhere but, if we're being perfectly honest, I'm not really up for digging through it to hunt it all down.

  • Could you host just starfarer.api.jar so integration becomes easier please (AWS or Maven repository)?

I'd prefer not to add another item to my release checklist...

  • Alternatively, are you fine with bundling starfarer.api.jar in a mod repo (again, for build / pipeline ease)?

Sure, feel free!
Logged

Ed

  • Captain
  • ****
  • Posts: 436
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6792 on: October 01, 2020, 06:53:19 PM »

I am trying to make a ship system that hijacks enemy missiles, i got them to stop hitting my ships and targeting the enemy that they came from, but they seem to have lost their collision, they just circle the enemy until they timeout phasing through it instead of hitting.

Code
if (missile.getOwner() != ship.getOwner()) {
   missile.setOwner(ship.getOwner());
}
Logged
Check out my ships

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17028
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6793 on: October 01, 2020, 06:57:29 PM »

Ah - this is probably because a missile can't hit the ship it came from until it flames out. Let me add get/setSource() methods to MissileAPI.

In the meantime, your best bet might be to spawn a new missile and place it in the same exact location... though I don't recall offhand if you can set the flight time etc so this wouldn't "refuel" it.
Logged

Ed

  • Captain
  • ****
  • Posts: 436
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6794 on: October 01, 2020, 07:18:43 PM »

Ah - this is probably because a missile can't hit the ship it came from until it flames out. Let me add get/setSource() methods to MissileAPI.

In the meantime, your best bet might be to spawn a new missile and place it in the same exact location... though I don't recall offhand if you can set the flight time etc so this wouldn't "refuel" it.
that was the problem, it works now, thanks :)
Logged
Check out my ships
Pages: 1 ... 451 452 [453] 454 455 ... 458