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: Simulator Enhancements (03/13/24)

Author Topic: Ship-system related issues  (Read 1276 times)

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Ship-system related issues
« 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.
Logged
 

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Ship-system related issues
« Reply #1 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?

"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.
Logged