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: Anubis-class Cruiser (12/20/24)

Pages: 1 ... 281 282 [283] 284 285 ... 748

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

Wispborne

  • Captain
  • ****
  • Posts: 486
  • Discord: wispborne
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4230 on: January 24, 2019, 07:27:12 PM »

Two questions. I accidentally wrote a book below...

1.

- I create an Intel at `com.wispborne.mod.MyIntel` and release my awesome mod.
- Time passes. People use the mod and save games with it. I am very proud.
- I realize that my package organization or naming is bad and I want to move `MyIntel` to a different package or rename it.

Is there a way to do that without breaking savegame compatibility? I mean, other than leaving MyIntel there and delegating to the new class (lol).

For example, with Gson, you can use an attribute `@NamedParameter("prefix_MyIntel")`, which tells the serializer how to refer to it, thus allowing you to decouple your implementation from the serializer contract.
I saw that XStream has `@XStreamAlias`, but it doesn't seem to do anything (presumably `xstream.autodetectAnnotations(true);` is present). Any other solutions?


2. This one is even more unlikely, but imo important, and presumably (also?) something that you, Alex, have thought about.

The API docs are ...sparse. I'm glad that modding is supported and that the API docs exist of course (and note that I'm only a 1-month veteran of Starsector), buuuuut it seems clear that working on the game is prioritized over adding to the API docs. By far, most of my time is spent trying to figure out how to do "simple" things, like bar events and intel, rather than creating exciting content. The best documentation I've found so far has been simply reading the unobfuscated classes, such as `PlanetaryShieldBarEvent`, and even then it's pretty hard to follow what classes are using that class, etc, since none of those files are indexed.
So that was a lot of complaining, which wasn't really the intent, but rather I wanted to stress that we could be generating way more really cool content much faster with better documentation.

And the question: how can we help?
You guys should keep working on what you enjoy. You're probably not gonna hire a technical writer just to update API docs. So is there a way that we as a community can contribute to the API docs? The SS modding wiki is, well, it's okay, and maybe that's the answer, but authoring an article is much more daunting than adding `BaseModPlugin: Inherit from this class to tie into the lifecycle of the game. Add the implementing class, with package, to mod_info.json`, as an example. And, I would argue, having good javadocs is more important than having a bunch of modding articles, because there are many ways of accomplishing a task and it'll be very difficult for the wiki to cover enough use cases, whereas javadocs can describe pieces in isolation. Ideally, both are great and complement each other, but again...authoring is more daunting.

Sorry for the essays! I tried to search to see if there were answers already but it's quite possible I missed things. Awesome game, I've already hooked a friend on it as well (he's on his second playthrough and blames me for sabotaging his ability to wake up early in the mornings).
« Last Edit: January 24, 2019, 07:48:28 PM by Wispborne »
Logged
Mod Managers: TriOS & SMOL | Mod: Persean Chronicles | Tool: VRAM Estimator | Tool: Forum+Discord Mod Database | If I'm inactive for 3 months, anyone can use any of my work for anything (except selling it or its derivatives).

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24918
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4231 on: January 24, 2019, 07:58:54 PM »

- I realize that my package organization or naming is bad and I want to move `MyIntel` to a different package or rename it.

Is there a way to do that without breaking savegame compatibility? I mean, other than leaving MyIntel there and delegating to the new class (lol).

Yep, I think so - see the configureXStream(XStream x) method in the ModPlugin interface, and its vanilla implementation in CoreLifecyclePluginImpl. You should be able to alias your MyIntel class to a name that's independent of the package and/or class name.


The best documentation I've found so far has been simply reading the unobfuscated classes, such as `PlanetaryShieldBarEvent`, and even then it's pretty hard to follow what classes are using that class, etc, since none of those files are indexed.

Yeah, taking a simpler core implementation of something and then working from that is definitely the way to go.

Could you expand on the bolded part? Is it just where it refers to/is used by core stuff that's not in the API, or do you mean something else?  For PlanetaryShieldBarEvent, "show references" (not sure what the equivalent is in Netbeans etc) shows where it's used, which I think is overall comparatively easy to follow - so I feel like I'm perhaps missing something.


And the question: how can we help?
You guys should keep working on what you enjoy. You're probably not gonna hire a technical writer just to update API docs. So is there a way that we as a community can contribute to the API docs? The SS modding wiki is, well, it's okay, and maybe that's the answer, but authoring an article is much more daunting than adding `BaseModPlugin: Inherit from this class to tie into the lifecycle of the game. Add the implementing class, with package, to mod_info.json`, as an example. And, I would argue, having good javadocs is more important than having a bunch of modding articles, because there are many ways of accomplishing a task and it'll be very difficult for the wiki to cover enough use cases, whereas javadocs can describe pieces in isolation. Ideally, both are great and complement each other, but again...authoring is more daunting.

I appreciate the thought!

Yeah, writing javadoc is just down to "when I have time" and the answer is basically "pretty much never" so it ends up being limited to things where I thought it was really, really necessary. There's no structure in place for the community to write javadoc; not sure how that'd work, really - the wiki indeed seems like the place for that.

Sorry for the essays! I tried to search to see if there were answers already but it's quite possible I missed things. Awesome game, I've already hooked a friend on it as well (he's on his second playthrough and blames me for sabotaging his ability to wake up early in the mornings).

Thank you! :D
Logged

Wispborne

  • Captain
  • ****
  • Posts: 486
  • Discord: wispborne
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4232 on: January 24, 2019, 08:23:38 PM »

> configureXStream(XStream x)

Oh wow, that's exactly what I was looking for. Thanks!

> since none of those files are indexed

This may be a "me" problem, and by "me" I mean "IntelliJ".

If I do a "find references" on `configureXStream` in IntelliJ, it only finds things from my own codebase, not vanilla's, because it only indexes and search my own project files.

Since we just have a jarfile of the SS api -
...
oh. I just opened up `starfarer.api.zip` for the first time. Wow.
Ok, I added that unzipped content to IntelliJ as a source and now when I "Find Usages", it finds all the usages in the vanilla files, too. That, too, is exactly what I wanted. Entirely my bad.


The only reasonable approach I could see to a community-driven javadoc would be throwing the contents of `starfarer.api.zip` (probably with the method contents removed) up on github, and accepting PRs that add to the docs.
But then that leaves you with the job of merging that into your working copy, which surely has plenty of changes from the "stable" version we're all on. And there's the question of whether people would contribute at all.
Anyway, that's all I've got for now. Thanks a bunch for the help. I try to pay it forward over on Discord whenever I'm able.
Logged
Mod Managers: TriOS & SMOL | Mod: Persean Chronicles | Tool: VRAM Estimator | Tool: Forum+Discord Mod Database | If I'm inactive for 3 months, anyone can use any of my work for anything (except selling it or its derivatives).

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24918
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4233 on: January 24, 2019, 08:28:18 PM »

oh. I just opened up `starfarer.api.zip` for the first time. Wow.
Ok, I added that unzipped content to IntelliJ as a source and now when I "Find Usages", it finds all the usages in the vanilla files, too. That, too, is exactly what I wanted. Entirely my bad.

Ah, excellent! Yeah, I can see how it would be a bit rough having a go at it without the api source :)


The only reasonable approach I could see to a community-driven javadoc would be throwing the contents of `starfarer.api.zip` (probably with the method contents removed) up on github, and accepting PRs that add to the docs.
But then that leaves you with the job of merging that into your working copy, which surely has plenty of changes from the "stable" version we're all on.

Yeah - it seems like it'd be fairly laborious process, unfortunately.

Anyway, that's all I've got for now. Thanks a bunch for the help. I try to pay it forward over on Discord whenever I'm able.

Glad to help! Feel free to ask more questions as things come up.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 432
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4234 on: January 25, 2019, 12:26:03 AM »

How drop data works? DropValue and DropRandom? how do they works ???
If I want a fleet drop 0~4 amount of commodity"XXX", how to add them?

And how to make fleets defend one place and ignore the hostile fleets which is far from them?(In a starsystem, there are 2 factions which is hostile to each other, the place defended is far from each other too)
« Last Edit: January 25, 2019, 12:41:33 AM by Originem »
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24918
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4235 on: January 25, 2019, 09:35:23 AM »

How drop data works? DropValue and DropRandom? how do they works ???
If I want a fleet drop 0~4 amount of commodity"XXX", how to add them?

DropValue will always drop some commodities from the specified group with a value equal to the number specified in the drop data with some variance (iirc +-50%).

DropRandom will have X chances to drop something from the group. If the group has a "nothing" entry, each chance may result in nothing being dropped.

For example, if you open up salvage_entity_gen_data.csv, you'll see something like this in the drop_value column:

basic:5000

This means to pick 5000 credits (+-50%) worth of stuff from the "basic" group, which is defined in drop_groups.csv.

Looking at that, we see:
metals   basic   20
heavy_machinery   basic   1
supplies   basic   10
fuel   basic   10

The number is the probability of each commodity being picked, so roughly the ratio of the commodities produced will match the ratio of these numbers.

You'll also see something like this in the drop_random column:

ai_cores2:3

This means "roll 3 times from the ai_cores2 group".

Looking at that one, we see:
nothing   ai_cores2   100
beta_core   ai_cores2   2
gamma_core   ai_cores2   5

So each roll will produce nothing with a probability of 100/107, a beta core (2/107), or a gamma core (5/107).

You might also see something like this in the drop_random column:
extended:3x3000

This means "roll 3 times from the extended drop group, and each time produce 3000 credits worth of items". This is useful for example if you want to have it drop some commodities from a list, but instead of a distribution of a little bit of everything, you want to pick a couple to focus on. For example, the group might have 20 commodities, and if rolled twice, it'll pick out two and drop a bunch of those.

DropGroups can also be set up using code - I think TechMining.generateCargoForGatheringPoint() is a decent piece of code to look at for how that works. There, it directly passes the DropData it creates o SalvageEntity.generateSalvage(), but you could also add it to a fleet using fleet.addDropRandom(DropData) (or, indeed, addDropRandom(String id, int chances) and so on.

When it comes to dropping weapons/blueprints/etc, it gets more complicated with special json syntax in place of a commodity id.


So, right, if you want a fleet to drop 0-4 of commodityXXX, you would:

1) add a drop group to drop_data.csv. Let's name it "testDrop".
nothing testDrop 50
commodityXXX testDrop 50

2) Call: fleet.addDropRandom("testDrop", 4)

Note that this would give 4 50/50 chances to drop one commodityXXX, so while you'd get 0 to 4 of them, it would not be an even probability distribution.


Hope this answers your question! Let me know if you'd like me to clarify something.


And how to make fleets defend one place and ignore the hostile fleets which is far from them?(In a starsystem, there are 2 factions which is hostile to each other, the place defended is far from each other too)

You would need to give them a custom assignment AI, for example like this one:

com.fs.starfarer.api.impl.campaign.tutorial.TutorialLeashAssignmentAI

How to do that depends on how the fleets are created.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 432
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4236 on: January 25, 2019, 05:46:14 PM »

Hope this answers your question! Let me know if you'd like me to clarify something.
Wow. It's a detailed answer, thanks very much! And if I can just use dropdata.addCommodity to custom it not in the csv but in the script?
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24918
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4237 on: January 25, 2019, 06:01:39 PM »

And if I can just use dropdata.addCommodity to custom it not in the csv but in the script?

Yep, you can do that too.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 432
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4238 on: January 26, 2019, 09:16:49 AM »

how to make a fleetmember only has 10% possible to recover?
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24918
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4239 on: January 26, 2019, 09:29:52 AM »

There's no easy way to do exactly that since it's based on the baseShipRecoveryChance (from settings.json), on the per-ship chance (that's modified by hullmods such as ReinforcedBulkheads), and on fleet commander skills.

For example, if you were to:
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyMult(id, 0.1f);

That would still get modified by the player skill recovery chance by *adding* to the chance of recovery, so it wouldn't be 10x less.


About the only thing that comes to mind is to have a ship with the UNBOARDABLE hint, then have a simple skin that does "removeHints":[UNBOARDABLE], and have the skin be 9 times less likely to be used than the base hull, using the shipRoles weights.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 432
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4240 on: January 26, 2019, 09:47:55 AM »

There's no easy way to do exactly that since it's based on the baseShipRecoveryChance (from settings.json), on the per-ship chance (that's modified by hullmods such as ReinforcedBulkheads), and on fleet commander skills.

For example, if you were to:
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyMult(id, 0.1f);

That would still get modified by the player skill recovery chance by *adding* to the chance of recovery, so it wouldn't be 10x less.


About the only thing that comes to mind is to have a ship with the UNBOARDABLE hint, then have a simple skin that does "removeHints":[UNBOARDABLE], and have the skin be 9 times less likely to be used than the base hull, using the shipRoles weights.

It reminds me that, could I just add different sprites in one hull? I mean, make a ship can have random skins.
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24918
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4241 on: January 26, 2019, 10:20:42 AM »

By making a bunch of skins and putting them all into shipRoles, yeah.
Logged

Wispborne

  • Captain
  • ****
  • Posts: 486
  • Discord: wispborne
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4242 on: January 26, 2019, 01:52:05 PM »

Is there a way to modify the hover text / tooltip that appears on the map?



Specifically, I'd love to be able to remove "(Inactive Gate)" so it just reads "Active Gate". I've done a lot of looking through the game files and my best guess is that it's hardcoded and obfuscated, but I've been wrong plenty of times.
Logged
Mod Managers: TriOS & SMOL | Mod: Persean Chronicles | Tool: VRAM Estimator | Tool: Forum+Discord Mod Database | If I'm inactive for 3 months, anyone can use any of my work for anything (except selling it or its derivatives).

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24918
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4243 on: January 26, 2019, 09:33:32 PM »

Yeah, if the name does not match the base name of the custom entity, the base name shows up in parends and this is indeed hardcoded in core code.

Defining a different custom entity (in custom_entities.json) and swapping it out with the inactive gate is an option, but you'd have to be careful since for example a debris field could be orbiting the gate. Or if an intel item is referring to the original gate, then you're pretty much out of luck, so maybe it's not a good option.
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4244 on: January 27, 2019, 02:38:18 AM »

Replace all the gates in the procgen stage.  ;D
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it
Pages: 1 ... 281 282 [283] 284 285 ... 748