Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Of Slipstreams and Sensor Ghosts (09/24/21)

Pages: 1 ... 441 442 [443] 444 445 ... 560

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

SirHartley

  • Captain
  • ****
  • Posts: 477
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6630 on: July 10, 2020, 09:07:08 AM »

Thanks! Any way to add that via code on sector gen then?
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 #6631 on: July 11, 2020, 08:21:42 AM »

Please forgive my obsession, but I'm here again.

So, I'm trying to make a simple hullmod that will force the ship to automatically venting when the condition is met. There were no problems with defining the condition. But for the third hour now I have been fighting the venting command. Everything should be simple, since in ShipCommand.java it is not at all difficult to find that it is VENT_FLUX.

But here my hands, growing out of ***, prove themselves! Can someone give a ready-made string to execute the command?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6632 on: July 11, 2020, 08:47:05 AM »

Thanks! Any way to add that via code on sector gen then?

You'd have to add it to specific entities; see:
http://fractalsoftworks.com/forum/index.php?topic=15244.0

Probably want to do it in ModPlugin.onNewGame() or thereabouts.

Please forgive my obsession, but I'm here again.

So, I'm trying to make a simple hullmod that will force the ship to automatically venting when the condition is met. There were no problems with defining the condition. But for the third hour now I have been fighting the venting command. Everything should be simple, since in ShipCommand.java it is not at all difficult to find that it is VENT_FLUX.

But here my hands, growing out of ***, prove themselves! Can someone give a ready-made string to execute the command?

ship.giveCommand(ShipCommand.VENT_FLUX, null, 0);

Along with the requisite imports etc. (If you haven't already, setting up an IDE might be worthwhile, since you'll get specific errors for these sorts of issues which should point you in the right direction, generally.)
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 #6633 on: July 11, 2020, 09:01:25 AM »

Perfect! Works as it should. I forgot ship.giveCommand part.

Thank you very much!
Logged

Mayu

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6634 on: July 11, 2020, 10:22:16 AM »

Hello everyone, I am a complete newbie to this and I am having a problem of adding a custom market condition. What I want to happen is to increase the fuel production and to lessen the Volatiles demand. The thing is that, the code below does increase fuel production by 2 but the demand remains unaffected. Could anyone kind enough to give me a guidance here, thanks!


Spoiler
Code

package data.scripts.campaign.econ;

import com.fs.starfarer.api.campaign.econ.Industry;
import com.fs.starfarer.api.impl.campaign.econ.BaseHazardCondition;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.util.Misc;

public class amfuel extends BaseHazardCondition{

private final int FUEL_BONUS=2;

public void apply(String id) {

Industry industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
        }

        industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            if (industry.isFunctional()) {
               industry.supply(id + "_0", Commodities.FUEL, FUEL_BONUS, "Central Fuel Production");
            } else {
               industry.getSupply(Commodities.FUEL).getQuantity().unmodifyFlat(id + "_0");
            }
        }
}
[close]
Logged

SirHartley

  • Captain
  • ****
  • Posts: 477
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6635 on: July 12, 2020, 08:27:38 AM »

Last suggestion works, thanks for pointing me towards the documentation.

Another questions, I'd like to edit the following tooltip on a per-fleetmember basis:


is this possible? If yes, where?

Hello everyone, I am a complete newbie to this and I am having a problem of adding a custom market condition. What I want to happen is to increase the fuel production and to lessen the Volatiles demand. The thing is that, the code below does increase fuel production by 2 but the demand remains unaffected. Could anyone kind enough to give me a guidance here, thanks!

Spoiler
Code

package data.scripts.campaign.econ;

import com.fs.starfarer.api.campaign.econ.Industry;
import com.fs.starfarer.api.impl.campaign.econ.BaseHazardCondition;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.util.Misc;

public class amfuel extends BaseHazardCondition{

private final int FUEL_BONUS=2;

public void apply(String id) {

Industry industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
        }

        industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            if (industry.isFunctional()) {
               industry.supply(id + "_0", Commodities.FUEL, FUEL_BONUS, "Central Fuel Production");
            } else {
               industry.getSupply(Commodities.FUEL).getQuantity().unmodifyFlat(id + "_0");
            }
        }
}
[close]
change
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
to
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id, -2);
"" denotes a string (also called text) in java. You just modified the id by adding a "-2" to it, while the actual modifier was 0.
consider using an IDE; it will make your life easier.
« Last Edit: July 12, 2020, 08:29:17 AM by SirHartley »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6636 on: July 12, 2020, 08:43:46 AM »

Last suggestion works, thanks for pointing me towards the documentation.

Glad you got it working!

Another questions, I'd like to edit the following tooltip on a per-fleetmember basis:


is this possible? If yes, where?

Ah, not possible, unfortunately. IIRC it's just a string - possibly loaded from strings.json (or maybe not), but either way, not customizable per ship.
Logged

SirHartley

  • Captain
  • ****
  • Posts: 477
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6637 on: July 12, 2020, 09:22:42 AM »

Thanks for the answer,
I'm just wondering because it seems to be implemented for other submarkets:
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6638 on: July 12, 2020, 09:30:04 AM »

Yeah, it's just those two cases based on whether it's storage or not.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 2327
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6639 on: July 12, 2020, 09:39:17 AM »

How do you get a hand-crafted nebula system to be called "XYZ Nebula" instead of "XYZ Star System"?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6640 on: July 12, 2020, 09:43:12 AM »

system.setType(StarSystemType.NEBULA) *before* calling system.setBaseName().
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 2327
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6641 on: July 12, 2020, 09:45:14 AM »

Thought I tried that right before posting, but I must have forgotten to recompile. Thanks.
Logged

Hiroyan495

  • Lieutenant
  • **
  • Posts: 61
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6642 on: July 12, 2020, 06:33:47 PM »

I know this is going to sound like madness... and it is.

But what if you were to hypothetically say... that you tried to have 14 description parameters in your test-hullmod and the game doesn't have any of your sh*t after the 9th one?
I tested around a lot and it really seems like it's not an issue with me having a typo in my hull_mods.csv.

Spoiler
99189 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.util.MissingFormatArgumentException: Format specifier 's'
java.util.MissingFormatArgumentException: Format specifier 's'
   at java.util.Formatter.format(Unknown Source)
   at java.util.Formatter.format(Unknown Source)
   at java.lang.String.format(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.addPara(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.addPara(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2$12.createImpl(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.create(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.beforeShown(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.showTooltip(Unknown Source)
   at com.fs.starfarer.ui.Objectsuper.public.super(Unknown Source)
   at com.fs.starfarer.ui.Objectsuper.processInput(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.e$Oo.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.e.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.N.processInputImpl(Unknown Source)
   at com.fs.starfarer.coreui.refit.ModPickerDialogV3.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.N.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.O0oO.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.N.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.Objectsuper.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.processInput(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

^ The log ^

Spoiler
Installing an archotech core into the ship systems significantly improves its performance and gives the ship its own personality.

Usually only utilized by rogue AI, as the core remains dormant until it is host to an alpha-level AI core.

Nanomachines take care of all reparations and maintenance, engines run mostly on power and garbage is recycled.

- Reduces the rate at which combat readiness degrades by %s
- Reduces supply use for maintenance and fuel use by %s
- Increases the repair rate by %s
- Increases the combat readiness recovery rate by %s
- Reduces the time required to repair disabled weapons and engines (in combat) by %s
- As the ship is fully automated, the need for a crew is completely removed

Conduits, resembling tentacles, extend from the core, providing the entire ship with power, generated by the core itself
This results in a vastly better performance of the ship systems and a higher flux efficiency.

- Increases maximum burn level by %s
- The ship's sensor profile is reduced by %s
- Weapon fire costs are reduced by %s
- Reduces the amount of damage taken by shields by %s
- Reduces the amount of soft flux raised shields generate per second by %s
- Increases the ship's top speed in combat by %s/%s/%s/%s su/second, depending on hull size
- Increases the ship's maneuverability by %s
[close]

Spoiler
public String getDescriptionParam(int index, HullSize hullSize) {
      if (index == 0) return "" + (int) DEGRADE_REDUCTION_PERCENT + "%";
      if (index == 1) return "" + (int) (100f - (MAINTENANCE_MULT * 100f)) + "%";
      if (index == 2) return "" + (int) Math.round(REPAIR_RATE_BONUS) + "%";
      if (index == 3) return "" + (int) Math.round(CR_RECOVERY_BONUS) + "%";
      if (index == 4) return "" + (int) REPAIR_BONUS + "%";
      if (index == 5) return "" + BURN_LEVEL_BONUS;
      if (index == 6) return "" + (int) (100f - (PROFILE_MULT * 100f)) + "%";
      if (index == 7) return "" + (int) (100f - (WEAPON_FLUX_COST_MULT * 100f)) + "%";
      if (index == 8) return "" + (int) SHIELD_BONUS + "%";
      if (index == 9) return "" + (int) SHIELD_UPKEEP_BONUS + "%";
      if (index == 10) return "" + ((Float) speed.get(HullSize.FRIGATE)).intValue();
      if (index == 11) return "" + ((Float) speed.get(HullSize.DESTROYER)).intValue();
      if (index == 12) return "" + ((Float) speed.get(HullSize.CRUISER)).intValue();
      if (index == 13) return "" + ((Float) speed.get(HullSize.CAPITAL_SHIP)).intValue();
      if (index == 14) return "" + (int) MANEUVER_BONUS + "%";
      return null;
   }
[close]

The hullmod itself seems to work fine in the game, but as soon as you hover over the description the game crashes. I tried commenting any parameters after index == 9 out and removing the values from the hull_mods.csv accordingly, which resulted in the game not crashing and displaying all values correctly.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6643 on: July 12, 2020, 06:37:57 PM »

Yeah, it just supports up to 10 total values; sorry :)

(Didn't think anyone would be crazy enough, etc etc.)

The good news is in the next release, HullModEffect will have these methods:

boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec);
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec);

Which means you'll be able to compose the entire tooltip with code, basically.
Logged

Hiroyan495

  • Lieutenant
  • **
  • Posts: 61
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6644 on: July 12, 2020, 06:44:18 PM »

I'm looking forward to it! Thanks for the quick reply Alex! I'll figure out a temporary solution. :^)
Logged
Pages: 1 ... 441 442 [443] 444 445 ... 560