Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: 1 ... 451 452 [453] 454 455 ... 706

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

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6780 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: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6781 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: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6782 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: 18
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6783 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: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6784 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6785 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: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6786 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

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6787 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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6788 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: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6789 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6790 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: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6791 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

BeyondTheHorizon

  • Commander
  • ***
  • Posts: 178
  • Grand Admiral of the Galactic Empire
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6792 on: October 01, 2020, 08:44:49 PM »

How does getDamageTarget() work for missile? The code below works for other projectiles with DamagingProjectileAPI but not for missiles.
Code
for (MissileAPI m : missiles) {
if (m.getDamageTarget() == ship) {
flux.increaseFlux(m.getDamageAmount() * m.getDamageType().getShieldMult(), true);
}
}
« Last Edit: October 02, 2020, 01:00:16 AM by BeyondTheHorizon »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6793 on: October 02, 2020, 08:31:52 AM »

Offhand that seems like it'd be fine. Hmm. I'd suggest maybe stepping through with a debugger/adding some print statements to figure out exactly what's not working here.
Logged

L:atte Mint

  • Ensign
  • *
  • Posts: 11
  • this kitty is not included.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6794 on: October 02, 2020, 03:04:25 PM »

Hello there! I'm currently working on a mod that may required something very wierd, like a special, unique item (or commodity), that will be dropped only once and later maybe giving some special story with them. Frankly I didn't know how I may achive this, and this may beyond my knowledge scope. Is there anything (file, mod) specific that I could looked into?  ;)
Logged
-- 404 FELINE NOT FOUND --
Pages: 1 ... 451 452 [453] 454 455 ... 706