Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Autofit Bypasses Requisites  (Read 2418 times)

Machine

  • Commander
  • ***
  • Posts: 114
    • View Profile
Autofit Bypasses Requisites
« on: October 14, 2017, 04:21:19 PM »

By using autofit a hullmod that has an specific requisite can be installed into a different ship skin that doesn't meet the prerequisite

Highlighting the relevant code of the Fleet Server (TSC_CommCenter) hullmod from my own mod

Code
    @Override
    public boolean isApplicableToShip(ShipAPI ship) {
        /*The checked hullmod is only present in TSC combat ships as built-in, so it is used to discriminate which ship can install the Fleet Server hulllmod,
        sadly can't make this hullmod available to every ship since I would need to modify every ship to add the effect weapon*/
        return ship != null && (ship.getVariant().getHullMods().contains("TSC_ParticleConduits"));
    }
   
This hullmod can be then installed in, for example, a TT skin Amentum which lacks the Integrated Particle Conduits of the TSC version, by just autofitting it to the Attack variant.

I've already added code to my hullmods that have this kind of requirements to auto remove themselves, if they are not met, however it seems relevant enough to post the issue, since it also leads to autofit leaving unspent OP.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Autofit Bypasses Requisites
« Reply #1 on: October 14, 2017, 05:02:34 PM »

Hmm - not at my dev box, but I'll take a look when I am. Not sure this will be easily fixable since IIRC there's no ship object available when autofit is doing its job, and there shouldn't be since autofit may be used outside the refit context. Possibly the isApplicableToShip() method should be isApplicableToVariant() instead - not sure if anything in the game checks anything other than variant-specific data in that method, anyway.

I think if you flag the skin as incompatible with base (I forget what the key to do that is in the .skin file, again, not at dev computer), then that would work around the issue, by making this variant unavailable as a "goal" variant when autofitting that skin.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Autofit Bypasses Requisites
« Reply #2 on: October 15, 2017, 10:16:29 AM »

Took a look, hmm. The isApplicableToShip() indeed needs a ship - some hullmods check whether a ship has shields, so it can't do with just a variant.

It does look like I already fixed this in the dev version. However, it's only feasible to do this check when working in the refit screen, where there's only one ship. If autofit was used to generate variants for AI fleets, I suspect it couldn't do this and still run fast enough. Would have to check it and see, though, when I get to that point.

If so, the options would be 1) accept that autofitted AI-fleet variants may have these sorts of issues, or 2) implement this as a separate hull rather than a skin, to avoid the issue entirely.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Autofit Bypasses Requisites
« Reply #3 on: October 15, 2017, 10:19:55 AM »

Btw, I'm curious - what does your script to auto-remove the hullmod look like? Asking because depending on how it's implemented there's a risk it could be a major performance drain.
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Autofit Bypasses Requisites
« Reply #4 on: October 15, 2017, 11:43:02 AM »

It’s removed in applyAfterShipCreation.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Autofit Bypasses Requisites
« Reply #5 on: October 15, 2017, 11:55:30 AM »

Ah, excellent, thank you!
Logged