Fractal Softworks Forum
Starsector => Mods => Modding => Topic started 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.
-
For the threat part, you've got something like this set up in your .system file, right?
"aiHints":{
"threatRange":600,
"threatAmount":4,
"threatAngle":0,
"threatArc":360,
}
(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:
InterdictorArrayStats.findTarget()
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.