Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.9.1a is out! (05/10/19); Blog post: Skills and Story Points (07/08/19)

Author Topic: Is it possible to add a built in mod trough dialogue?  (Read 758 times)

Voiddweller

  • Ensign
  • *
  • Posts: 27
    • View Profile
    • Email
Is it possible to add a built in mod trough dialogue?
« on: April 19, 2019, 12:46:27 PM »

My goal is making a reward or upgrade system, to make common ships more unique, special, as time passes.
« Last Edit: April 19, 2019, 12:59:37 PM by Voiddweller »
Logged

Sundog

  • Admiral
  • *****
  • Posts: 659
    • View Profile
Re: Is it possible to add a built in mod trough dialogue?
« Reply #1 on: April 20, 2019, 08:47:50 AM »

I'm not an expert on this sort of thing, so take all this with a grain of salt.

Built-in mods are defined by the hull specification of the ship, meaning that even if you could add a built in mod to a ship , it would add the same mod to every other ship of the same class. However, there are at least three (edit: two) other types of hull mod, and ShipVariantAPI has a method to add each of them.
Perma - Typically D-Mods. I assume any perma mod would automatically come with the baggage of a D-Mod (the orange bar, deployment cost reduction, removed on restoration, etc.) but I may be wrong (edit: I was). If there's a way to avoid those things, using addPermaMod might be your best bet.
Suppressed - No idea. Hopefully someone with more knowledge will come by to enlighten us. (edit: see Alex's post below)
Normal - Your everyday removable mods. Honestly, this might be your best option, as long as there's any reason a player might want to remove your special mods. I'm pretty sure you could still ensure that they could only be added through your system.

You could certainly trigger a script that modifies ship variants via a dialogue. The main problem with that would be creating a clean interface for selecting which ship gets which mod (assuming the player gets to choose)

Hope that helps. Good luck with getting this idea working! It sounds like it could be pretty cool.
« Last Edit: April 20, 2019, 11:12:43 AM by Sundog »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 14480
    • View Profile
Re: Is it possible to add a built in mod trough dialogue?
« Reply #2 on: April 20, 2019, 09:16:39 AM »

Actually! "Perma" mods can be anything, not just d-mods. The special treatment of dmods is governed by their tags - namely "dmod" (red bar, removal when the ship is restored) and a couple of other ones (such as "damage") that control when the dmod can be added.

The reduced deployment cost is coded in the mod's implementation class - see com.fs.starfarer.api.impl.hullmods.CompromisedStructure.modifyCost(); the other dmods call this static method and have their descriptions set up with the required parameters (see: getCostDescParam() in same class).

"Suppressed" is a way to remove a mod without actually removing it from the variant. This is in particular useful for "removing" built-in mods from a ship; due to how things work if you actually removed a built-in mod iirc it would keep getting auto-added each time the variant synced itself up with the hull (and its built-in mods).


So, right: perma-mods are what you're looking for here, as far as the OP. That said, there might be some issues that I haven't anticipated. This is all supposed to work with all kinds of mods, but dmods (unless I'm forgetting something) are the only vanilla use case. If there are issues with this, they'd likely be bugs and I'd love to fix them, so: please let me know!
Logged

Nicke535

  • Commander
  • ***
  • Posts: 226
  • I make pink lasers
    • View Profile
    • Email
Re: Is it possible to add a built in mod trough dialogue?
« Reply #3 on: April 21, 2019, 11:27:05 PM »

"Suppressed" is a way to remove a mod without actually removing it from the variant. This is in particular useful for "removing" built-in mods from a ship; due to how things work if you actually removed a built-in mod iirc it would keep getting auto-added each time the variant synced itself up with the hull (and its built-in mods).
So that's what it's for. That makes perfect sense in retrospect.

...now to use it for something fancy...

Sundog

  • Admiral
  • *****
  • Posts: 659
    • View Profile
Re: Is it possible to add a built in mod trough dialogue?
« Reply #4 on: May 03, 2019, 07:18:46 PM »

The special treatment of dmods is governed by their tags - namely "dmod" (red bar, removal when the ship is restored) and a couple of other ones (such as "damage") that control when the dmod can be added.
If there are issues with this, they'd likely be bugs and I'd love to fix them, so: please let me know!
Are there any criteria other than the "dmod" tag that would cause a perma mod to be removed by restoration? Restoration removes the reputation hullmods I use in starship legends, but that might be due to some wackiness on my end.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 14480
    • View Profile
Re: Is it possible to add a built in mod trough dialogue?
« Reply #5 on: May 03, 2019, 08:03:44 PM »

Hmm, looking at the code, it actually does remove all the perma-mods - let me touch this up, should be a fairly safe change. I don't think there's any reason to do it (aside it being needed to make d-mod removal work, but I can do that in a slightly different way).
Logged

Sundog

  • Admiral
  • *****
  • Posts: 659
    • View Profile
Re: Is it possible to add a built in mod trough dialogue?
« Reply #6 on: May 03, 2019, 11:56:02 PM »

Many thanks!