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)

Author Topic: Modules FleetMemberAPIs have no FleetDataAPI  (Read 354 times)

Lukas04

  • Admiral
  • *****
  • Posts: 627
    • View Profile
Modules FleetMemberAPIs have no FleetDataAPI
« on: August 03, 2024, 08:09:34 AM »

While i understand that modules dont really have any priority as in their vanilla use case they work mostly fine, this specific issues is a bit of a pain when doing anything in the modded enviroment.

Due to this, there is no reliable way to tell what fleet a module is part of.
In my case, this is an issue since i require data from its fleet to load skill data for my mod. (The skills are handled through invisible hmods).
Within combat itself, i can access the fleet by looking for its parents ShipAPI, but the same, as far as i can tell, can not be applied to anything within the campaign, so skills triggered by my hullmods "applyEffectsBeforeShipCreation" function could not identify what fleet the module is part of.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24997
    • View Profile
Re: Modules FleetMemberAPIs have no FleetDataAPI
« Reply #1 on: August 03, 2024, 08:16:53 AM »

(Moving this from bug reports, since modules even *having* a FleetMemberAPI in the campaign is a bit of a surprise to me. It's probably some default "auto-created to avoid NPE" one.)

Hmm. What *is* "modules" in this context? A ShipAPI, or a ShipVariantAPI, or something else? And speaking of context, what is the context? Right now I'm guessing it's maybe "doing stuff when the module is selected in the refit screen" but I'm not actually sure.

Of note (iirc, but fairly sure) modules don't even exist in the campaign while the fleets are just flying around - their hullmods aren't applied, etc - so there may be a more fundamental issue here. All that's tracked is some secondary data like their repair state.
Logged

Lukas04

  • Admiral
  • *****
  • Posts: 627
    • View Profile
Re: Modules FleetMemberAPIs have no FleetDataAPI
« Reply #2 on: August 03, 2024, 08:29:58 AM »

(Moving this from bug reports, since modules even *having* a FleetMemberAPI in the campaign is a bit of a surprise to me. It's probably some default "auto-created to avoid NPE" one.)

Hmm. What *is* "modules" in this context? A ShipAPI, or a ShipVariantAPI, or something else? And speaking of context, what is the context? Right now I'm guessing it's maybe "doing stuff when the module is selected in the refit screen" but I'm not actually sure.

Of note (iirc, but fairly sure) modules don't even exist in the campaign while the fleets are just flying around - their hullmods aren't applied, etc - so there may be a more fundamental issue here. All that's tracked is some secondary data like their repair state.

I see, more of general issue then. Could i perhaps instead request a "applyEffectsToModulesBeforeShipCreation" method for the BaseHullmodPlugin then?
That methods parameters would preferably have:

- The parents FleetMemberAPI
- The modules Stats
- The modules variant

This would alleviate a lot of the issues i and others are facing when working with them. That way a hullmod on the modules parent could more easily influence the module in refit and on combat start.
One of those issues for example is that if the player would own a moduled ship, the modules dont receive stat updates within refit as of now. Thats the same case for vanilla skills (though i dont think they affect them at all in vanilla), but i would like to make my system support such ships.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24997
    • View Profile
Re: Modules FleetMemberAPIs have no FleetDataAPI
« Reply #3 on: August 03, 2024, 08:35:12 AM »

I'll keep it in mind, but it gets complicated! Modules and their stats don't exist before the parent module's ship creation, either.

Is this just a refit screen issue, though? If it is then a more targeted fix may be possible, such as just setting the fleet data on whatever faked-up fleet member API the module has.

Edit: and, if it is mainly just a refit screen issue, could it be assumed that it's the player fleet if the current game state is the campaign state?

Edit #2: set it for the refit screen. Note that it'll still sometimes be null (the hullmods get reapplied several times in succession, for reasons, and the first couple of times not all the data is there), so the hullmod code would still need to gracefully handle the case when it's null, but it should work otherwise. For the refit screen only.
« Last Edit: August 03, 2024, 09:52:59 AM by Alex »
Logged