Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: Tartiflette on December 28, 2018, 04:46:16 AM

Title: Ship-system related issues
Post by: Tartiflette on December 28, 2018, 04:46:16 AM
I have found two issues related to systems:

First, when making a system AI I noticed that the "target" in
public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target)
is different from the ship target. Or at least that a system can return a target while the ship itself has none selected. This is a problem when using system that require a ship target to work like the Interdictor Array, especially when the AI hardly ever target a ship during combat (at least when it's the player ship under AI control).

And more problematic, I noticed that the AI ignore the threat of weapon-based systems. If say a ship has a system that deactivate all weapons and power up a big Beam Of Doom(tm), the targeted ship will happily drop their shield or even vent.
Title: Re: Ship-system related issues
Post by: Alex on December 28, 2018, 10:25:33 AM
For the threat part, you've got something like this set up in your .system file, right?


(This is pasted from the EMP system.)

The "target" that's passed in here is the ship that the AI is currently engaging, as far as facing, maneuvering, etc. Like for a human, that can be different from what the ship actually has targeted, which is mostly relevant for missiles.

If a system does require a target - like the Interdictor Array - take a look at:

Basically, it checks for a shiptarget first, then ship.getAIFlags().getCustom(AIFlags.MANEUVER_TARGET), then some other stuff.

AIFlags.MANEUVER_TARGET is where the core AI stores the "currently engaging" target, i.e. the ship it's intending to fight, which is separate from a shiptarget.