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: Autofire accuracy for fast time ships  (Read 1365 times)

Genir

  • Captain
  • ****
  • Posts: 323
    • View Profile
Autofire accuracy for fast time ships
« on: August 31, 2024, 07:08:04 AM »

Hi,

I noticed ship AI advance method is always receiving the global time `amount` value, even for ships in fast time passage. This (probably) causes the autofire accuracy to rise slower than the ship-specific time passage would dictate.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25148
    • View Profile
Re: Autofire accuracy for fast time ships
« Reply #1 on: August 31, 2024, 08:48:00 AM »

The AI advance() method gets called multiple times per frame for fast-time ships, so this should be fine.
Logged

Genir

  • Captain
  • ****
  • Posts: 323
    • View Profile
Re: Autofire accuracy for fast time ships
« Reply #2 on: August 31, 2024, 09:05:41 AM »

The AI advance() method gets called multiple times per frame for fast-time ships, so this should be fine.

Oh, I see. This explains some of the issues I'm having with my engine controller.

So the AI for fast-time ships is called multiple times per frame with adjusted `amount`. But prior to that it's called once with global `amount`, along with other ships . Isn't the first call superfluous? Or leading to conflicting decisions?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25148
    • View Profile
Re: Autofire accuracy for fast time ships
« Reply #3 on: August 31, 2024, 09:13:24 AM »

Hmm, I'm not sure how you mean.

It'll get called the right number of times, basically, for the amount of time-speedup it has.
Logged

Genir

  • Captain
  • ****
  • Posts: 323
    • View Profile
Re: Autofire accuracy for fast time ships
« Reply #4 on: August 31, 2024, 09:26:53 AM »

From what I understand, there are two loops where ship AI is called.

First, where all ship AIs are advanced. Second, only for fast-time ships, where the AIs are advanced N-1 times, where N is the maximum speedup.

In the first loop, all ships receive global `amount` value, even the fast-time ones. I would expect fast-time ships to receive speedup-adjusted amount in the first loop as well? Instead, their time multiplier is explicitely overwritten with 1f.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3110
    • View Profile
Re: Autofire accuracy for fast time ships
« Reply #5 on: August 31, 2024, 09:30:34 AM »

If a ship is moving at 2x speed, I believe its advance() method will be called twice as often, but the amount passed to it will not be halved. AKA the ship sees 2 seconds per real second.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25148
    • View Profile
Re: Autofire accuracy for fast time ships
« Reply #6 on: August 31, 2024, 09:53:56 AM »

I would expect fast-time ships to receive speedup-adjusted amount in the first loop as well?

A ship going at 3.5x time would have its AI (and regular advance()) methods called with 1x, 1x, 1x, and 0.5x the normal amount, iirc. Basically they get "extra turns" every frame, is one way to think about it.
Logged

Genir

  • Captain
  • ****
  • Posts: 323
    • View Profile
Re: Autofire accuracy for fast time ships
« Reply #7 on: August 31, 2024, 10:07:45 AM »

Yes, I understand now! Thank you for your patience  :)
Logged