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 ... 320 321 [322] 323 324 ... 706

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

Kelaris

  • Ensign
  • *
  • Posts: 3
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4815 on: August 18, 2019, 11:37:22 PM »

Where would I start looking if I wanted to change the quantity/variety of different weapons, fighters, and ships available at markets?

I've been poking at things in com.fs.starfarer.api.impl.campaign.submarkets (BaseSubmarketplugin, BlackMarketPlugin, MilitarySubmarketPlugin, and OpenMarketPlugin) without successfully changing anything, as far as I can tell. I'm not sure if I'm digging in the wrong place, or if I've made some mistake in packaging my mod. First time messing with Starsector modding and I'm a complete novice with java, so any mishap is possible.
Logged

Sarissofoi

  • Captain
  • ****
  • Posts: 405
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4816 on: August 19, 2019, 06:56:10 AM »

Hardcoded in the intel, I'm afraid.

Why Alex? Whyyyyy?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4817 on: August 19, 2019, 08:30:38 AM »

Where would I start looking if I wanted to change the quantity/variety of different weapons, fighters, and ships available at markets?

I've been poking at things in com.fs.starfarer.api.impl.campaign.submarkets (BaseSubmarketplugin, BlackMarketPlugin, MilitarySubmarketPlugin, and OpenMarketPlugin) without successfully changing anything, as far as I can tell. I'm not sure if I'm digging in the wrong place, or if I've made some mistake in packaging my mod. First time messing with Starsector modding and I'm a complete novice with java, so any mishap is possible.

That's where you'd mess with it, yeah. I'd suggest trying to do something drastic (such as say always clearing the cargo in the updateBeforePlayerInteraction method) just to make sure your code is running and actually doing *something*. Or printing stuff or running with a debugger etc...

Why Alex? Whyyyyy?

:(
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4818 on: August 19, 2019, 03:21:53 PM »

Soooo... what controls Travel Drive, exactly?

I changed it a bit, and the results were... odd.  What I want:  setting Retreat activates the Travel Drive after X seconds of being unable to accelerate / decelerate.  Then the ships get to zip off the battlefield.  That... kind of works.  But somewhere along the way, I broke the Travel-Drive-Onto-Battlefield.

Seems that it expects to be a toggled System and it's turned on at the start of play... but it's not clear at all where the toggles are controlled from.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4819 on: August 19, 2019, 03:26:20 PM »

It's toggled from core code.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4820 on: August 19, 2019, 03:47:23 PM »

Okie doke; I'll try and work around that then :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

nights

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4821 on: August 19, 2019, 10:57:23 PM »

Is it possible to change the reputation gains from mission?
Been trying to find out for quite a bit.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4822 on: August 20, 2019, 03:16:59 AM »

Question I haven't been able to figure out.

So I have code for creating fleets and assigments, the problem is actually triggering that code. Since I don't need that during sectorgen, like most mods that add remnant-like enemies do, but rather periodically.

Basically, every 30-60 days check to see if the number of fleets with tag "X" is less than Y, and if it is, spawn more fleets. There can also be other checks (for example, number of alien motherships still active limits the amount of fleets to spawn), but those are easy to add.

how do I make that periodical check? From where do I call it?

Can I use CoreCampaignPluginImpl.onNewGameAfterTimePass()  .. or maybe  EveryFrameScript?
What the most efficient way to do it?

I'm a Java scrub and I'm cobbling together code from studying what other mods did, but none actually covers the specific case I'm considering.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4823 on: August 20, 2019, 07:25:08 AM »

Is it possible to change the reputation gains from mission?
Been trying to find out for quite a bit.

Not very easily - you'd have to change the code for that mission and then change the intel creator for that mission to create your version of the mission instead of the vanilla one. This probably means setting up an IDE and digging into the game's internals a fair bit.

Question I haven't been able to figure out.

So I have code for creating fleets and assigments, the problem is actually triggering that code. Since I don't need that during sectorgen, like most mods that add remnant-like enemies do, but rather periodically.

Basically, every 30-60 days check to see if the number of fleets with tag "X" is less than Y, and if it is, spawn more fleets. There can also be other checks (for example, number of alien motherships still active limits the amount of fleets to spawn), but those are easy to add.

how do I make that periodical check? From where do I call it?

Can I use CoreCampaignPluginImpl.onNewGameAfterTimePass()  .. or maybe  EveryFrameScript?
What the most efficient way to do it?

I'm a Java scrub and I'm cobbling together code from studying what other mods did, but none actually covers the specific case I'm considering.

An EveryFrameScript with an IntervalUtil to keep track of the interval seems like the way to go here. Probably use Global.getSector().addScript() to add it.

See: MilitaryBase.advance() for an example using IntervalUtil (the tracker variable). It's not an EveryFrameScript, but that portion of the code is the same.
Logged

nights

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4824 on: August 20, 2019, 08:35:30 AM »

Is it possible to change the reputation gains from mission?
Been trying to find out for quite a bit.

Not very easily - you'd have to change the code for that mission and then change the intel creator for that mission to create your version of the mission instead of the vanilla one. This probably means setting up an IDE and digging into the game's internals a fair bit.



Thanks for the reply! Was hoping is was an easy change cause the reward was always +5 rep!
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4825 on: August 20, 2019, 05:38:21 PM »

I copied the Mining industry, but my industry doesn't produce any ore/etc. Everything else works as expected. Am I just going to have to define all the supply of ore/etc. myself?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4826 on: August 20, 2019, 05:48:26 PM »

Yeah, I think so. Looking at the ResourceDepositsCondition code, it's not really set up to handle multiple industries producing resources from the same kinds of deposits. In fact, it's even got a hack in it to support Aquaculture working.
Logged

NoFoodAfterMidnight

  • Ensign
  • *
  • Posts: 39
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4827 on: August 21, 2019, 12:11:27 AM »

Is any of the base AI accessible or is the only way to modify AI to write new code and use ShipAIPlugin.Advance() ?  There's some simple tweaks I'd like to make.

If it's all done through Advance() , how would I go about finding the core methods of ship controls and such to write a new AI, and how would I overwrite parts of the base AI?
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4828 on: August 21, 2019, 02:34:38 PM »

Well, I tried to implement ore production, but something has gone wrong. I have the code below in my apply() method. The top log call reports that the market does in fact have ore_moderate and the bottom log call reports oreSupply has a value of 1, as expected, but the industry produces no ore.

Spoiler
Code: java
        int oreSupply = 0;
        int rareSupply = 0;
        int volatilesSupply = 0;
        int organicsSupply = 0;

        org.apache.log4j.Logger logger = Global.getLogger(Roider_Dives.class);

        for (MarketConditionAPI c : market.getConditions()) {
            logger.info("asddssd" + c.getId());

            switch (c.getId()) {
                case (Conditions.ORE_ULTRARICH): oreSupply++;
                case (Conditions.ORE_RICH): oreSupply++;
                case (Conditions.ORE_ABUNDANT): oreSupply++;
                case (Conditions.ORE_MODERATE): oreSupply++;
                case (Conditions.ORE_SPARSE): break;

                case (Conditions.ORGANICS_PLENTIFUL): organicsSupply++;
                case (Conditions.ORGANICS_ABUNDANT): organicsSupply++;
                case (Conditions.ORGANICS_COMMON): organicsSupply++;
                case (Conditions.ORGANICS_TRACE): break;


                // Reduced supply for rare ores and volatiles
                case (Conditions.RARE_ORE_ULTRARICH): rareSupply++;
                case (Conditions.RARE_ORE_RICH): rareSupply++;
                case (Conditions.RARE_ORE_ABUNDANT): break;
                case (Conditions.RARE_ORE_MODERATE): break;
                case (Conditions.RARE_ORE_SPARSE): break;

                case (Conditions.VOLATILES_PLENTIFUL): volatilesSupply++;
                case (Conditions.VOLATILES_ABUNDANT): break;
                case (Conditions.VOLATILES_DIFFUSE): break;
                case (Conditions.VOLATILES_TRACE): break;
            }
        }

        logger.info("asddssd ore " + oreSupply);
        logger.info("asddssd " + rareSupply);
        logger.info("asddssd " + volatilesSupply);
        logger.info("asddssd " + organicsSupply);

        supply(Commodities.ORE, oreSupply);
        supply(Commodities.RARE_ORE, rareSupply);
        supply(Commodities.VOLATILES, volatilesSupply);
        supply(Commodities.ORGANICS, organicsSupply);
[close]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4829 on: August 21, 2019, 02:44:54 PM »

Is any of the base AI accessible or is the only way to modify AI to write new code and use ShipAIPlugin.Advance() ?  There's some simple tweaks I'd like to make.

If it's all done through Advance() , how would I go about finding the core methods of ship controls and such to write a new AI, and how would I overwrite parts of the base AI?

It's not accessible, no. It's a tangled ball of core code that would be way too much of a project to try to extract into mod-land, unfortunately.

So it's an all-or-nothing deal, with the exception of ship systems, which have modular AIs.

For controlling ships: see ShipAPI.giveCommand().

Well, I tried to implement ore production, but something has gone wrong. I have the code below in my apply() method. The top log call reports that the market does in fact have ore_moderate and the bottom log call reports oreSupply has a value of 1, as expected, but the industry produces no ore.

I'd suggest calling the supply() method that has a String id as the first parameter. Probably something else is supplying 0 units with the default ID that the supply() method you're calling uses, and that overrides whatever you're doing. Not 100% sure, though.
Logged
Pages: 1 ... 320 321 [322] 323 324 ... 706