Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 638 639 [640] 641 642 ... 710

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

Ontheheavens

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9585 on: February 08, 2023, 09:00:18 AM »

How do one use LabelAPI.computeTextHeight(string)? Is it what the height would be had the text been vertically rendered? For a 65 tall PositionAPI, the call returned me 998 when I passed same string as I did to original addPara().

I want to ask the same question. No matter how long is the input string, the return is always 15. Doesn't look like the method's any good at all. Is there any other way I can get Y-axis offset for real text height so that I do not get a clipping once the dynamic string grows beyond initial size?

Looking at Stellar Networks source, seems like Jaghaimo did gave up on this too - no usages of this method in code.

Edit: turns out I needed to call getPosition().getHeight(), which indeed returns correct height of the label instance - problem solved.
« Last Edit: February 08, 2023, 09:31:56 PM by Ontheheavens »
Logged
   

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9586 on: February 08, 2023, 03:46:44 PM »

Is there a way to point to a Constellation in a bar event?

Intel has
public SectorEntityToken getMapLocation(SectorMapAPI map)
and you can use the map like so:  map.getConstellationLabelEntity(constellation)
to give you a SectorEntityToken.

Dialogs, however, have this:
dialog.getVisualPanel().showMapMarker(sectorEntityToken, etc);

Is there a way to create a S.E.T. for the constellation within BaseBarEvent?

Those entities are temporary ones created when the map is opened. I'm not sure pointing to that specific entity matters - you could create a custom entity and set its location to the location of the constellation and that should do the trick.


Interesting, is possible to modify size of NPC ships? Lets say I want to return back crazy pirate armadas as they was in 091 and older versions of the game? And if not possible, I'd like to have ability to configure this in 096.

"maxShipsInAIFleet" in settings.json, though you might need to change other stuff (in code) to make them actually larger. Fleet spawning is generally specific to whatever that specific fleet is for so there's no one-size-fits-all solution aside from, say, reducing fleet points across the board or some such.


1: Make my Hullmod apply counter stats a Multiplier of 1.33333 for speed and -25 Percent for the damage taken, this should be fairly simple to implement, but I fear would have weird interactions with any other hullmods that change the severity of D-Mods. Which this technically counts as I believe.

You could do this and also factor in ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT); which is how the impact of d-mods is modified.

2: Rewrite alternative versions of the 2 hullmods to not reference Defective Manufactory and just have the stat changes contained within. This is a bit more work and probably overall neater than my first option, but has the potential to run afoul of any other mods that modify those two hullmods.

Or this, yeah. You've covered the two ways that come to mind of doing this.


Is there a way to determine if the Ruins condition is from the Collapse or because someone Saturation-Bombed a colony into oblivion? (Or even abandoned a colony, leaving the ruins of their own.)

The market memory will have $wasCivilized in it for sat-bombed ruins.
Logged

Ontheheavens

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9587 on: February 09, 2023, 03:43:59 AM »

So I am adding an intel to intel manager. This intel has several objects stored in its fields, including an ArrayList of objects and one big child object (custom panel assembler) Saving the game - it loads, but only if I didn't manipulate field objects in any way - if there's something stored in ArrayList, the game silently closes on load without any exception thrown.

What do I do? Tried to unload the intel into persistent data while the game saves, tried to remove the intel before the save and add brand new one after save and on game load - doesn't do the trick. I'm not particular about saving the data in intel object now, I just want the game to work with my intel without throwing a white flag.

Last lines in log:

Code
201875 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 38
201875 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 39 - last

Edit: resolved by manually clearing all data before intel removal.
« Last Edit: February 09, 2023, 04:38:38 AM by Ontheheavens »
Logged
   

WhisperDSP

  • Commander
  • ***
  • Posts: 148
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9588 on: February 09, 2023, 04:33:37 AM »

Would someone please explain to me how drop groups etc work - because I appear to be doing something very, very wrong with mine. :(

Referencing the attached image. By the presence of Ore I know that this particular "First Find" has included the following drop group:
Code
heavy_machinery,wta_ruins_mining1,10
metals,wta_ruins_mining1,40
ore,wta_ruins_mining1,30
supplies,wta_ruins_mining1,20

According to the Wiki: "An example of "dropValue" might be "drop 10,000 credits worth of fuel, supplies, metals, and heavy machinery". The actual value will be within 50% of the target amount." In the following code:
Code
    // does it have at least moderate stuff to mine?
    if (getOre() > 1) {
      d = new DropData();
      d.chances = colonySize;
      d.group = "wta_ruins_mining1";
      d.value = 2000 * ruinsSize;
      d.valueMult = multEnhanced;
      dropValue.add(d);
    }

colonySize = 3 (just founded)
ruinsSize = 1 (scattered ruins)
multEnhanced = 1.25 (first drop + Alpha AI Core)

The above code has:

* Chosen the Ore (30% chance) as one of the choices
* 2000cr * 1 (ruinsSize) = 2000cr --- I will assume the worst case, under that by 50%, or only 1000cr of Ore
* 1000cr * 1.25 = 1250cr worth of ore
* 1250cr / 10 cr (Ore cost) = 125 ore

So the 10 Ore in my screenshot is approximately 8% of the Ore which I was expecting to have been returned as a minimum.

It gets worse, there are 2x more drop groups which would have been added (metals, supplies, heavy machinery, fuel). One of those should have had 3 choices at 3000cr value, and the second should have had 9 more choices at 3000cr. The returned 4x fuel (ie 1000 / 25 = 40) are nowhere near what I'm thinking should have been returned.

Please help me figure out what it is that I've messed up so badly.

--edit--

Okay, figured it out. I'm a damn idiot.

The value is the total pie, divided by the number of choices. Each choice then becomes (totalvalue / choices) amount of X chosen item from the drop group.

So to have it work like I was thinking, I will need to multiply the pie-size by the number of choices first. In this case, the colony size.

--edit-edit--

Or if I want to be more "realistic", it could be: 3000 * ruinsSize * ruinsSize * colonySize

Though it might be somewhat overboard for Vast Ruins on a size 6 Colony.
« Last Edit: February 09, 2023, 09:52:10 AM by WhisperDSP »
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9589 on: February 09, 2023, 05:08:31 AM »

Have you stepped through your code in a debugger and confirmed your values? Sometimes I have been sure that X must be Y, but it's really Z.
Logged

Dazs

  • Admiral
  • *****
  • Posts: 1070
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9590 on: February 09, 2023, 08:13:14 AM »

Hi all, having an issue with Hiver Swarm and figured I'd ask here. I have numerous requests to have their commodities not show up on the Stellar Networks Mod tabs. I have tried reaching out there but it looks like Jaghaimo has not replied to his mod questions since 09/22. I was wondering if there was a way to have their commodities not report to the com relay? Either that or if someone knows how to implement the blacklist feature of that mod, I have tried several methods with no success, please teach me. :)

WhisperDSP

  • Commander
  • ***
  • Posts: 148
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9591 on: February 09, 2023, 09:01:47 AM »

Have you stepped through your code in a debugger and confirmed your values? Sometimes I have been sure that X must be Y, but it's really Z.

Thanks, yah they are correct - I wrote them to the log to double-check the values are right.

I will look again in a bit, maybe something will jump out at me.

--edit--

ID10T Error, PEBKAC.

Figured the issue, I will update the original post with the answer.
« Last Edit: February 09, 2023, 09:39:24 AM by WhisperDSP »
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9592 on: February 09, 2023, 09:23:57 AM »

I have tried reaching out there but it looks like Jaghaimo has not replied to his mod questions since 09/22.

Looks like Jaghaimo was last active on the 1st according to his profile. He will probably be on again soon. Try PMing him - that is more likely to catch his attention.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9593 on: February 09, 2023, 10:10:10 AM »

So I am adding an intel to intel manager. This intel has several objects stored in its fields, including an ArrayList of objects and one big child object (custom panel assembler) Saving the game - it loads, but only if I didn't manipulate field objects in any way - if there's something stored in ArrayList, the game silently closes on load without any exception thrown.

Potential red flag here is storying any UI stuff in the savefile. You generally don't want to do that - at best it's unnecessary save bloat, and at worst you'd end up with the entire game's UI getting serialized in the savefile, most likely bricking it.
Logged

WhisperDSP

  • Commander
  • ***
  • Posts: 148
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9594 on: February 09, 2023, 10:11:44 AM »

Is there a way to determine if the Ruins condition is from the Collapse or because someone Saturation-Bombed a colony into oblivion? (Or even abandoned a colony, leaving the ruins of their own.)

The market memory will have $wasCivilized in it for sat-bombed ruins.

Thanks Alex. I searched for $wasCivilized and have come up with the following: if (market.getMemoryWithoutUpdate().getBoolean("$wasCivilized"))

It returns false for non-sat-bombed stuff, I'll do a full test over the weekend.

Ontheheavens

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9595 on: February 09, 2023, 10:50:05 AM »

Potential red flag here is storying any UI stuff in the savefile. You generally don't want to do that - at best it's unnecessary save bloat, and at worst you'd end up with the entire game's UI getting serialized in the savefile, most likely bricking it.

Good to know, thanks! Just to make sure I understood correctly: I want UI objects to be created on-the-spot in each game session, and prevent UI objects (which are stored in the intel instance for the interaction purposes, for example, button checking which, seemingly, has to be done through the intel method) from entering the save alongside intel instance at all, is that right?

This is how my modplugin looks:

Spoiler
Code
    override fun onGameLoad(newGame: Boolean) {
        super.onGameLoad(newGame)
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }

    override fun beforeGameSave() {
        super.beforeGameSave()
        val intel: EntryWriter = Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) as EntryWriter
        intel.clearIntelData()
        Global.getSector().intelManager.removeIntel(intel)
    }

    override fun afterGameSave() {
        super.afterGameSave()
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }
[close]

So theoretically, intel instance is not going to be in the save at all now. Am I safe?

Edit: while we're at it, should I also avoid putting a HashMap with keys of FleetMemberAPIs (or, more generally, any references to FleetMemberAPIs) in persistent data? If yes, should I use their UUIDs instead and retrieve instances by IDs after load?
« Last Edit: February 09, 2023, 11:00:22 AM by Ontheheavens »
Logged
   

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9596 on: February 09, 2023, 11:31:06 AM »

Good to know, thanks! Just to make sure I understood correctly: I want UI objects to be created on-the-spot in each game session, and prevent UI objects (which are stored in the intel instance for the interaction purposes, for example, button checking which, seemingly, has to be done through the intel method) from entering the save alongside intel instance at all, is that right?

This is how my modplugin looks:

Spoiler
Code
    override fun onGameLoad(newGame: Boolean) {
        super.onGameLoad(newGame)
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }

    override fun beforeGameSave() {
        super.beforeGameSave()
        val intel: EntryWriter = Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) as EntryWriter
        intel.clearIntelData()
        Global.getSector().intelManager.removeIntel(intel)
    }

    override fun afterGameSave() {
        super.afterGameSave()
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }
[close]

So theoretically, intel instance is not going to be in the save at all now. Am I safe?

Theoretically! I think you'd have an easier time using the "transient" keyword on the data members for whatever data you're clearing, since that'll basically do the same thing - transient variables don't go in the savefile.

Edit: while we're at it, should I also avoid putting a HashMap with keys of FleetMemberAPIs (or, more generally, any references to FleetMemberAPIs) in persistent data? If yes, should I use their UUIDs instead and retrieve instances by IDs after load?

That should be fine, though I'm not sure what's behind the question.

(With storing fleet members long term, the tricky part can be being able to tell if they're still around anywhere - storage, fleets, referred to by some other script. So it just depends on what you're doing. I've been using WeakReference to get around those types of problems in vanilla, but I don't know if that's applicable to what you're doing or not.)
Logged

Ontheheavens

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9597 on: February 09, 2023, 10:07:58 PM »

Theoretically! I think you'd have an easier time using the "transient" keyword on the data members for whatever data you're clearing, since that'll basically do the same thing - transient variables don't go in the savefile.

That is precisely the thing I didn't knew I needed! Rewrote with transient, and now all the important data is preserved and I don't need any clunky modplugin methods (and those revolting nullability shenanigans), and everything is much better! Thank you good sir.

That should be fine, though I'm not sure what's behind the question.
(With storing fleet members long term, the tricky part can be being able to tell if they're still around anywhere - storage, fleets, referred to by some other script. So it just depends on what you're doing. I've been using WeakReference to get around those types of problems in vanilla, but I don't know if that's applicable to what you're doing or not.)

What I have are companion objects for each fleetmember in player fleet with a certain hullmod, said objects describing stats and state of their modded features - they have a property field with parent FleetMember. Have assignment and cleanup methods in place that are called fairly frequently, so I'm sure all the references to fleetmembers no longer in fleet are promptly removed.

Since you say it's fine in general and I don't store members that shouldn't be around (and I didn't notice any problems during playtesting), it should be fine. Thanks again!

Edit: have another question - is it possible to emulate behaviour of refit screen's ship name text field in circumstances of large intel description? In other words, I want to save string of textfield each time it is modified - could use a normal "Save" button right next to it, but that's not ideal for my taste.
« Last Edit: February 09, 2023, 10:47:43 PM by Ontheheavens »
Logged
   

BreenBB

  • Commander
  • ***
  • Posts: 150
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9598 on: February 10, 2023, 12:44:42 AM »

Interesting it is possible to modify UI for skill selection screen? Both for Player and Officer, and if not, can I suggest it for new version? I'd like to have wider choice of skills for officer, so it less a random gamble, and to have option to make skills like they was in 091 or 06 versions of the game when they had multiple levels, 3 or 10 instead of just base skill and upgrading it to elite one.
Logged

NuclearStudent

  • Ensign
  • *
  • Posts: 20
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9599 on: February 11, 2023, 12:21:40 PM »

Is there a way to override the Codex and F1 displays of ship stats to show an arbitrary string?

Specifically, I want to display a range of possible ship stats, and have some code that randomly sets values for each individual ship instance.

My fallback plan for handling my problem is to have all stats set to 10, but have the real stats instanced as soon as the battle begins. Mostly just a "looking nice" thing that I'd prefer not to.
« Last Edit: February 11, 2023, 12:29:22 PM by NuclearStudent »
Logged
Pages: 1 ... 638 639 [640] 641 642 ... 710