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); In-development patch notes for Starsector 0.98a (2/8/25)

Author Topic: CoreLifecyclePluginImpl overrides automated ship AI with too high priority  (Read 376 times)

Genir

  • Captain
  • ****
  • Posts: 323
    • View Profile

I'm writing ship AI that replaces vanilla AI in general case, not just for specific faction, ship or encounter. My understanding is that I should deploy the modded AI via BaseModPlugin.pickShipAI with MOD_GENERAL priority. That way other mods can override my AI for their specific use cases, just as they override vanilla AI.

The approach works fine for normal ships. But for automated ships vanilla already provides pickShipAI override with CORE_SPECIFIC priority, in CoreLifecyclePluginImpl. This leaves me with the options of either using even higher priority or setting ship AI in BaseEveryFrameCombatPlugin, both of which are unfriendly towards other mods.

Can CoreLifecyclePluginImpl use lower priority? At least in cases other than involving Ziggurat?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25148
    • View Profile

I think the "expected" thing to do would be for your code to use the MOD_SPECIFIC priority, since it's overriding vanilla's CORE_SPECIFIC AI choices, but to do this only for the case of automated ships/Ziggurat, using the MOD_GENERAL priority otherwise.
Logged

Genir

  • Captain
  • ****
  • Posts: 323
    • View Profile

Yes, I can use MOD_SPECIFIC in case of automated ships. This will leave other mods with just the option of using HIGHEST to override my AI.

The question remains, why vanilla uses CORE_SPECIFIC for all automates ships? The priority is described as:

Quote
Should be used by core code only for specific encounters. For example, a "special" planet or fleet could have their own dialog, and the priority of this would override a mod that replaces the general interactions with all planets or fleets.

The description fits Ziggurat encounter well. But I think setting all automatic ships AI would fit _SET priority much better. How I understand the priority system in the context of ship AI:
  • CORE_GENERAL: "AI for all ships"
  • CORE_SET: "AI for all automated ships"
  • CORE_SPECIFIC: "AI for a certain automated boss ship, eg Guardian in cryosleeper encounter".

If it worked like that, I could use MOD_SET to apply my AI to automated ships.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25148
    • View Profile

That seems right, yeah. I forgot _SET was a thing. Changed!
Logged