Author Topic: UFO detection mechanics  (Read 913 times)

Offline Alpha Centauri Bear

  • Colonel
  • ****
  • Posts: 466
    • View Profile
UFO detection mechanics
« on: December 26, 2023, 04:49:58 pm »
What is the concept behind UFO detection? Is it assumed each radar individually tries to detect it with its own chance? If so then this function seems to implement something different.
I understand it could be vanilla legacy. However, if logic was incorrectly implemented and is easy to fix, would it make sense to rewrite it?
Code: [Select]
UfoDetection Base::detect(const Ufo *target, const SavedGame *save, bool alreadyTracked) const

Things those seem off to me.

#1
Normal and hyperwave detection use different logic. Normal radars chances are added and their sum is used as a combined normal detection chance. Hyperwave radars chances are multiplied as it would correctly be when each of them has independent detection attempt.

#2
Not clear why detection chance for hyperwave is set to 100 when at least one of such radar passed the detection check?
What is detectionChance variable anyway? If this is resulting detection chance with all radars trying to detect UFO? If so, why it is hardcoded to 100 for hyperwave?

#3
Because of the above, parameters sent to the script is somewhat confusing. They could be only 100 for hyperwave but could be any number for normal.

#4
I didn't find radar chance is capped to 0-100 anywhere in the code. Should it be?

#5
The UFO visibility is additive. It could get as low as -50. Does it mean that very small UFO flying at the very low altitude won't ever be detected by say single small radar?



I am not telling anybody what to do. Just thinking what I would do if I need to program it. Can present change draft, of course, if anyone is interested.

- Compute normal and hyperwave detection chances separately by multiplying individual radar chances.
- Do two RNG rolls for normal and hyperwave detection chances. Either succeeding would detect UFO. Hyperwave succeeded would also uncover hyperwave info, obviously.
- Make UFO visibility modifiers multiplicative to avoid going out of 0 - 100 bound.
- Pass both parameters to script assuming the actual detection is not yet happened and script can change these values before detecting.

« Last Edit: December 26, 2023, 05:06:03 pm by Alpha Centauri Bear »

Offline Alpha Centauri Bear

  • Colonel
  • ****
  • Posts: 466
    • View Profile
Re: UFO detection mechanics
« Reply #1 on: December 26, 2023, 07:01:31 pm »
From the other hand, I don't think anyone bothers when exactly UFO is detected. Usually it is not that relevant in the game. So whether it is implemented or not is not a big deal.

One thing I would love to add, though, is that once UFO get detected by normal radar it would still have the chance to get their hyperwave transmission resolved by hyper radar. I.e. upgrade of normal detection to hyper one.