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 ... 628 629 [630] 631 632 ... 706

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

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9435 on: December 29, 2022, 09:55:45 AM »

Would really like to see certain parts of Industry be extendable from outside the class:
- items
- right-click menu in the market screen
- AI cores

Maybe also supply/demand.

Would definitely like to see the resource deposit condition script support multiple industries for each resource. Just change INDUSTRY to be List<String, List<String>> with each industry keyed to a list of commodities and adjust the code that reads the lists.
Logged

Wyvern

  • Admiral
  • *****
  • Posts: 3786
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9436 on: December 29, 2022, 10:05:16 AM »

Is there any way to mark a special item as installable in any industry that outputs commodities? Ideally, I'd just be able to use a API method for this, because I have something specific in mind, e.g. it should be installable in anything that either produces commodities or outputs production capacity.
Sortof? You can make a special item that is installable in a specific list of industries, via tags in its special_items.csv listing. See, for example, the sigma matter items in Dassault-Mikoyan Engineering.

However, that works only for vanilla industries;* it won't automagically be installable in mod-added industries. And that's probably a good thing; for example, the Shadowyards mod has a special Heavy Industry replacement industry that takes and consumes installable items to specialize itself; if you gave it an installable item it wasn't expecting - well, you might get a game crash, and you'd almost certainly get unexpected behavior.

* Edit: To clarify, yes, you could put a mod-added industry on the list. But you'd have to explicitly add it, which implies that you know about that industry and have tested the interactions with your installable item, rather than getting potential untested interactions with some random industry you've never heard of before.

Edit2: Also, if you want AI-controlled colonies to have proper item upgrade behavior for items installed in vanilla industries, there's a MagicLib module for that. Getting that working was surprisingly annoying. Again, see DME's Sigma Matter for an example of the module in use.
« Last Edit: December 29, 2022, 10:20:19 AM by Wyvern »
Logged
Wyvern is 100% correct about the math.

Harmful Mechanic

  • Admiral
  • *****
  • Posts: 1340
  • On break.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9437 on: December 29, 2022, 10:18:12 AM »

See, for example, the sigma matter items in Dassault-Mikoyan Engineering.
(Just a note here - that's the dev build, not anything generally accessible... yet.)
Logged

Wyvern

  • Admiral
  • *****
  • Posts: 3786
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9438 on: December 29, 2022, 10:22:54 AM »

See, for example, the sigma matter items in Dassault-Mikoyan Engineering.
(Just a note here - that's the dev build, not anything generally accessible... yet.)
Oh, oops. >.<

...Right, okay, if someone need a simple demo of this, I can probably put something together.
Logged
Wyvern is 100% correct about the math.

alaricdragon

  • Commander
  • ***
  • Posts: 145
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9439 on: December 30, 2022, 01:27:35 PM »

hello once more all. i come with two questions:
1) when raiding, were is the marine XP gain calculated? I have failed to find it in the MarketCMD for some reason.
2) how does one get the players marine's current XP based combat bonuses?
thank you all once more for the responses to my very silly questions in the past. it was very kind for you all to do so.
Logged

Ontheheavens

  • Commander
  • ***
  • Posts: 134
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9440 on: January 01, 2023, 01:12:45 AM »

Seems like "Dismiss" button in commodity market share screen uses either 16 or possibly 21 size Victor font, while in TooltipMakerAPI there's only setButtonFontVictor14(). Is there any way to work around this to get 100% vanilla button look?

It's 20pt Orbitron, actually! Added to TooltipMakerAPI:

   void setButtonFontOrbitron20();
   void setButtonFontOrbitron20Bold();
   void setButtonFontOrbitron24();
   void setButtonFontOrbitron24Bold();

Big thanks, love me some API additions. One more question about tooltips: is there a way to add footer-tooltip widget "Press F1 for more info" and corresponding behaviour to tooltips of classes where 'boolean isTooltipExpandable();' is not present, say, to hullmod tooltips?

If it is impossible, then I'm left with simple addPara() and keyboard check, right? Can do with that, just wanted a bit more vanilla beauty. :)

Edit: since there is a Ballistic Rangefinder already and you are adding Missile Autoloader, seems like expandable hullmod tooltips are going to be necessary for vanilla too!

Edit 2: while I'm at it, might as well point out this (didn't want to make a separate thread for something so trifling): on some resolutions lower than 1600x900 header line in "Command" CoreUI tab overlaps with exit button graphic. Line needs to be shorter if insufficient display height causes said line to render too close to the top edge.

[attachment deleted by admin]
« Last Edit: January 01, 2023, 02:10:59 AM by Ontheheavens »
Logged
   

rogerbacon

  • Commander
  • ***
  • Posts: 142
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9441 on: January 01, 2023, 04:31:29 PM »

Are ship images cached somewhere? I made some ships and then realized I forgot to resize the png files. After resizing them the game is still using the big ones.

[Edit] Turns out it saves the size in the .ship file and doesn't care what size the actual png file is. Solved.
« Last Edit: January 01, 2023, 04:53:02 PM by rogerbacon »
Logged

ctuncks

  • Commander
  • ***
  • Posts: 117
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9442 on: January 01, 2023, 04:54:52 PM »

I am currently making some hullmods based off of and requiring in game hullmods to work. I’m still wrapping my head around Java though and have quite a few gaps in knowledge.

At current I’m attempting to create a hullmod that requires Integrated Point Defense AI to be installed (I already know how to do this). The intended function for my hullmod is to remove the PD conversion applied small ballistic/energy weapons without affecting another of the other bonuses from Integrated Point Defense AI or accidentally stripping away PD capacity from weapons that already have it as a base feature.

I'm pretty sure the following is what applies the conversion.

Code
public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
List weapons = ship.getAllWeapons();
Iterator iter = weapons.iterator();
while (iter.hasNext()) {
WeaponAPI weapon = (WeaponAPI)iter.next();
// if (weapon.hasAIHint(AIHints.PD)) {
// weapon.get
// }
boolean sizeMatches = weapon.getSize() == WeaponSize.SMALL;
//sizeMatches |= weapon.getSize() == WeaponSize.MEDIUM;

if (sizeMatches && weapon.getType() != WeaponType.MISSILE) {
weapon.setPD(true);
}
}
}

if (weapon.hasAIHint(AIHints.PD)) {
//            weapon.get


I think I need something like an inverted version of this to target all weapons without the PD tag in weapon.csv that's on the applicable ship.

and then need to follow it up with weapon.setPD(false);

I'm just not sure how you'd write this out to function properly, I was really hoping to be able to use an unmodify, but don't think it's works.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9443 on: January 01, 2023, 05:14:41 PM »

1) when raiding, were is the marine XP gain calculated? I have failed to find it in the MarketCMD for some reason.
2) how does one get the players marine's current XP based combat bonuses?

See: com.fs.starfarer.api.impl.PlayerFleetPersonnelTracker, for both.

Something like PlayerFleetPersonnelTracker.getInstance().getMarineData().getXPLevel() for the second, btw; should return a number between 0 and 1. The values of that that correspond to the ranks are specified in the PersonnelRank enum.


Big thanks, love me some API additions. One more question about tooltips: is there a way to add footer-tooltip widget "Press F1 for more info" and corresponding behaviour to tooltips of classes where 'boolean isTooltipExpandable();' is not present, say, to hullmod tooltips?

If it is impossible, then I'm left with simple addPara() and keyboard check, right? Can do with that, just wanted a bit more vanilla beauty. :)

Edit: since there is a Ballistic Rangefinder already and you are adding Missile Autoloader, seems like expandable hullmod tooltips are going to be necessary for vanilla too!

Yeah, I don't think it's possible. And, yeah, I might end up having to add this at some point :)

Edit 2: while I'm at it, might as well point out this (didn't want to make a separate thread for something so trifling): on some resolutions lower than 1600x900 header line in "Command" CoreUI tab overlaps with exit button graphic. Line needs to be shorter if insufficient display height causes said line to render too close to the top edge.

Thank you, made a note!


I think I need something like an inverted version of this to target all weapons without the PD tag in weapon.csv that's on the applicable ship.

and then need to follow it up with weapon.setPD(false);

I'm just not sure how you'd write this out to function properly, I was really hoping to be able to use an unmodify, but don't think it's works.

What you want, I think, is to check weapon.getSpec().contains(AIHints.PD) and then if it doesn't, but weapon.hasAIHint(AIHints.PD) returns true, then that's a weapon that was set to be PD while it normally isn't, and you'd do weapon.setPD(false).
Logged

rogerbacon

  • Commander
  • ***
  • Posts: 142
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9444 on: January 02, 2023, 10:27:27 AM »

I'm making a hullmod and I need to store the hullsize so I can get it later in an AdvanceableListener during combat. When I run Starsector it says it can't convert Object to int.
Code
private static Map mag = new HashMap();
static {
mag.put(HullSize.FRIGATE, 1);
mag.put(HullSize.DESTROYER, 2);
mag.put(HullSize.CRUISER, 3);
mag.put(HullSize.CAPITAL_SHIP, 4);
}
public int hs = 1;

@Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
this.hs = (int) mag.get(hullSize); // It doesn't like this line for some reason

    }

In another hullmod I do basically the same thing and it doesn't complain at all

Code
	private static Map mag = new HashMap();
static {
mag.put(HullSize.FRIGATE, 80f);
mag.put(HullSize.DESTROYER, 160f);
mag.put(HullSize.CRUISER, 160f);
mag.put(HullSize.CAPITAL_SHIP, 160f);
}

    @Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getCargoMod().modifyFlat(id, (Float) mag.get(hullSize)); // No problem here
stats.getFluxCapacity().modifyFlat(id, (Float) mag.get(hullSize) * -0.5f);
stats.getFluxDissipation().modifyFlat(id, -60f);

    }

I tried making it a float just to be 100% the same as the working one but it didn't make a difference. I'm not compiling into a .jar or .class file. I'm letting Starsector do the compiling, which has always worked fine for me before.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9445 on: January 02, 2023, 10:58:28 AM »

Not sure about that, but: you should not store any data in hullmod class member variables, because there's only one instance (i.e. copy) of this class, so this data will be shared across ALL ships that use this hullmod.

What you want to do is create a custom data-holder class and stick it into CombatEngineAPI.getCustomData(), keying off the ID of the ship, so that you get a separate copy of the data for each ship in combat. For an example of this, see com.fs.starfarer.api.impl.hullmods.SharedFluxSink. In particular, this part:

String key = SINK_DATA_KEY + "_" + ship.getId();
FluxSinkData data = (FluxSinkData) engine.getCustomData().get(key);
if (data == null) {
   data = new FluxSinkData();
   engine.getCustomData().put(key, data);
}
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9446 on: January 02, 2023, 02:45:11 PM »

Can which way the AI decides which facing to choose, especially when 'trading flux' 1v1, or going 'all-in' 1v1, be roughly predicted from weapon layout and opponent?  I ask because we want to calculate that facing for ship combat analysis. CapnHector tested a Conquest armed with kinetics on the left and high explosives on the right, and it presented the right side to the enemy early in 1v1 simulator engagements against a Dominator and an Aurora, while the enemy shields remained up.

https://fractalsoftworks.com/forum/index.php?topic=25536.msg384442#msg384442

I (more or less) reproduced the result and think the Conquest preferred the longer-ranged kinetics on its right side regardless of their damage type.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9447 on: January 02, 2023, 03:22:04 PM »

IIRC which broadside is chosen does not look at damage types etc - just the weapon ranges and the distance to the target.
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9448 on: January 02, 2023, 10:38:23 PM »

IIRC which broadside is chosen does not look at damage types etc - just the weapon ranges and the distance to the target.

And is this true for ships generally, besides the Conquest?  :D

ctuncks

  • Commander
  • ***
  • Posts: 117
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9449 on: January 03, 2023, 01:05:49 AM »

Quote from: Alex
What you want, I think, is to check weapon.getSpec().contains(AIHints.PD) and then if it doesn't, but weapon.hasAIHint(AIHints.PD) returns true, then that's a weapon that was set to be PD while it normally isn't, and you'd do weapon.setPD(false).

Thanks for the reply, not yet able to implement it yet, still need a bit more experience. For the meantime I've opted for a lesser workaround.
Logged
Pages: 1 ... 628 629 [630] 631 632 ... 706