Author Topic: UFO Extender accuracy discussion  (Read 20262 times)

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #15 on: February 01, 2018, 03:11:54 am »
That's because the 'distance' X-Com uses for determining angular deviation from a target isn't quite Euclidean; taxicab was a good guess, but it isn't quite that either. There is some X/Y non-uniformity (because thus it is commanded), and strange things go on with height distance too.
« Last Edit: February 01, 2018, 03:27:02 am by ohartenstein23 »

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #16 on: February 01, 2018, 12:02:35 pm »
Interesting. Well, we need to be able to make accuracy go up a lot at short range, not only adjacent range. This non-uniformity may be extreme now, but with a decent accuracy system (such as optimal range/target range) it would be negligible and there wouldn't be any cases in which it affects gameplay so significantly. A 30% shot with 2 squares to target should hit almost every time. Even just pointing the weapon in the target's general direction will score hits at that range. But 30% accuracy actually shows a decent amount of aiming. This soldier will hit about 30% of long-range shots with an open line of fire.

Offline darkestaxe

  • Colonel
  • ****
  • Posts: 254
  • Emissary of the Brain
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #17 on: February 04, 2018, 05:26:13 am »
I'd calculate it like:
Actual_Shot_Accuracy = ((Soldier_Firing_Accuracy/100) * Weapon_ShotType_Accuracy) * (Weapon_ShotType_Optimal_Range / Distance_To_Target)

For example, a soldier with 60 firing accuracy fires a snap shot using a Rifle at 10 squares from his target, where a rifle has 60% snap shot accuracy and snap shots have a default 15 square optimal range.

0.54 = (60/100 * 0.6) * (15 / 10)
or 54% accuracy

I think this would be a much better implementation of range based accuracy, but the default for aimRange should be changed from 200 to 30, or aimed shots will have extremely high accuracy.

Offline Lagi

  • Squaddie
  • *
  • Posts: 6
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #18 on: February 08, 2018, 04:02:32 pm »
I would like very much increase accuracy at short range!

darkestaxe math looks sensible.

Could the formula include obstacles on the Line of Fire?

I would prefer drop of accuracy at the point blank, to give niche for melee attacks. 2 tiles away 95% sounds rad.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #19 on: February 09, 2018, 03:16:57 am »
It's actually my math. I got darkestaxe to write it in pseudocode for me.


Could the formula include obstacles on the Line of Fire?

I would prefer drop of accuracy at the point blank, to give niche for melee attacks. 2 tiles away 95% sounds rad.
The game already includes obstacles in the calculation. My equation is supposed to determine the accuracy value given as the shot is made, just like how the UFO Extender Accuracy works. It'll display roughly your chance to hit if you have an open shot. It's up to you to see that your shot is partly occluded and recognize that your actual chance to hit may be lower.


As for accuracy drop at shorter range, I would like to see the effect be an option you can add to your mod. UFO Extender Accuracy has a minimum range setting, the way it works is that anything between minimum and dropoff has max accuracy, while anything over or under has gradually reduced accuracy based on distance. As my calculation is very different, I should develop an equation for a minimum accuracy function.

My initial thought is to set an optimal close range, and if such a range is set then as target gets closer, accuracy increases only until optimal far range, stays the same from optimal far to optimal close, and goes down from optimal close, reaching zero at zero squares distance (being in the same tile). So then the calculation for the accuracy reduction would be: (TR/OCR)*BSA
TR = Target Range
OCR = Optimal Close Range
BSA = Base Shot Accuracy

So for example, we have a rifle with a snap shot optimal far range of 15 tiles while its optimal close range is 3 tiles. The soldier using this weapon has 60 accuracy and the rifle's snap shot accuracy is 60%. Here's the accuracy at different ranges:
1 tile: 12%
2 tiles: 24%
3 tiles: 36%
5 tiles: 36%
7 tiles: 36%
10 tiles: 36%
15 tiles: 36%
20 tiles: 27%
30 tiles: 18%
45 tiles: 12%

You'll note that the accuracy reaches 36% in a certain range and levels off. An alternative method would be to have accuracy continue to increase as target range decreases, until the halfway point between optimal far and optimal close range at which point it switches to the other calculation and makes accuracy begin to decrease. The halfway point isn't necessarily the median between the two but rather the point at which both calculations reach the same value. In this case, it is ~6.7082 tiles, which you can find by getting the square root of the far divided by the close, and multiply the result by the far range. 15 / 3 = 5, (sqrt)5 = ~2.2361, ~2.2361 * 3 = ~6.7082. Essentially you're just running both calculations and taking the smaller of your two resulting accuracy values. Here's how it would play out:

1 tile: 12%
2 tiles: 24%
3 tiles: 36%
5 tiles: 60%
7 tiles: 77%
10 tiles: 54%
15 tiles: 36%
20 tiles: 27%
30 tiles: 18%
45 tiles: 12%

As you can see, this change only affects values between 3 and 15 tiles. With this equation, the accuracy peaks at around 6 to 7 tiles distance to target.

Offline heu3becteh

  • Squaddie
  • *
  • Posts: 3
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #20 on: June 08, 2018, 04:20:54 pm »
I like the UFO Extender accuracy as it makes sense to use something other that Auto-shot, while without it Aimed and Snap are rarely useful.

The problem I want to adress is how the % to hit affects the cone at which soldier can fire upon, and particularly how he can fire almost at whatever (even at his comrades standing at adjacent tiles left and right, maybe even behind him?) when he has 0% to hit, it looks quite stupid, to extend of being ridiculous. And defies common sense - if your target is located further, you are more likely to shot at completely another angle, wasting your buddy standing beside you.

There is a solution to never fire with 0% chance, but that is just workaround. May it be possible to make it look reasonable? Sometimes it can be useful to just destroy all cover enemy has with Auto-fire, but with 0% accuracy you will just wipe out your team.

As I understood here, the calculation goes like that:
1. RNG decides is it a hit or is it a miss.
2. If it is a hit - shot flies straight at the target and hits.
    If it is a miss - shot flies by some traectory inside a cone (which depends on accuracy), and the trajectory inside this cone is selected based on the normal distribution. That trajectory can pass through your target too, making it a hit.

That means that when you use fire with 0% accuracy, you go straight to the point 2, and fire at some trajectory inside of a cone.

Based on that, my question: is it possible to affect % to hit with UFO Extender accuracy option on, but do not affect the cone, inside which trajectory of a miss is selected?
So that this option affects point 1, but does not affect point 2. I think that makes sense.

Best regards.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #21 on: June 09, 2018, 05:32:08 am »
My equation actually solves both of the problems you listed.

 * As accuracy diminishes beyond optimal range, and optimal range can be set by the individual shot on each weapon, different shots will be ideal at different ranges, same as with UFOExtender Accuracy.

The game has a very wide maximum shot angle. I think it should be narrowed, but it primarily shows problems when listed chance to hit is very low. If the player is given options which help to avoid being forced into tiny chances to hit, then wide shots like that won't be as common.

 * In UFOExtender Accuracy, your shot's accuracy diminishes at a steady rate, and suddenly reaches zero at some point. My equation fixes this by offering a diminishing return on accuracy with distance. As distance increases and accuracy decreases, the rate of decrease also decreases, such that the chance to hit approaches zero without ever reaching it. This means that an auto shot at 15 squares might say 2% chance to hit, and the same shot at 30 squares might say 1% chance to hit. This equation would allow aimed shots to have a reasonable range like 20 perhaps without suffering the same problems of being unable to hit targets just because they are too far away.

Example: We have a soldier with 70 accuracy using a weapon in which the aimed shot has an optimal range of 20 and an accuracy of 120. The base accuracy (at 20 squares) is 84%. Here's accuracy at longer distances on the battlefield:
30: 56%
40: 42%
50: 34%
60: 28%
No matter how far away you get, the shot can still hit the target and won't go insanely wide.

Here's the same values with UFOExtender Accuracy (if I calculated it correctly in my head):
30: 64%
40: 44%
50: 24%
60: 4%
This is why UFOExtender Accuracy cheats and sets aimed shot range to 200.
« Last Edit: June 09, 2018, 05:38:15 am by The Reaver of Darkness »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9089
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #22 on: June 09, 2018, 10:01:30 am »
This is why UFOExtender Accuracy cheats and sets aimed shot range to 200.

UFOExtender doesn't cheat... aimed shot range is 200 also without it... and can be modded if you want.

Offline Starving Poet

  • Colonel
  • ****
  • Posts: 265
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #23 on: June 09, 2018, 04:23:53 pm »
As I understood here, the calculation goes like that:
1. RNG decides is it a hit or is it a miss.
2. If it is a hit - shot flies straight at the target and hits.
    If it is a miss - shot flies by some traectory inside a cone (which depends on accuracy), and the trajectory inside this cone is selected based on the normal distribution. That trajectory can pass through your target too, making it a hit.

Read the first reply on that thread - thats exactly how it doesn't work.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #24 on: June 09, 2018, 11:11:27 pm »
UFOExtender doesn't cheat... aimed shot range is 200 also without it... and can be modded if you want.
What do you mean? Before UFOExtender Accuracy there wasn't a range factor for accuracy. Individual weapons may have had a range, but that's a strict limit on how far the projectile can travel. The 200 range for aimed shots is there for accuracy calculations using UFOExtender's system.

Offline heu3becteh

  • Squaddie
  • *
  • Posts: 3
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #25 on: June 12, 2018, 11:57:30 pm »
Read the first reply on that thread - thats exactly how it doesn't work.
Can you please clarify how does it work then?
I have read all the topic, not only the first reply, and I did understand that reply the way I described.
The first reply can imply that there is no 1 step, and the trajectory is just calculated from the beginning without any RNG.

If the game does calculate the trajectiry right away, it is possible to make 0% cone not as crazy as it is now by making it the same as with vanilla accuracy, but changing the distribution properties (which decide to which part of a cone the projectile will more likely to fly) with range. Can that be done?

Offline lx_ufoforum

  • Squaddie
  • *
  • Posts: 9
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #26 on: January 11, 2019, 08:45:06 pm »
im making a translation and i need to know if this affects aliens so i can put it in the description text.

and i think that no amount of changes will make a chance based system right.
answer a question: will those soldiers rely on luck(chance) to hit?
if i was one of them, i would not. its all a matter of many circumstances and they can not be simulated by a general purpose random number generator.
forget that someone once upon a time created a flawed system and think how would you simulate whats going on on the battlefield.

have you played frontline tactics? every shot is a hit(no cth bs). and that does not make the game any worse than x-com as a tactical turn based game with firearms combat(atleast for me).
answer my first line ;)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9089
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #27 on: January 11, 2019, 10:12:07 pm »
im making a translation and i need to know if this affects aliens so i can put it in the description text.

yes, this affects also aliens and civilians

Offline Abyss

  • Colonel
  • ****
  • Posts: 355
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #28 on: January 20, 2019, 08:41:16 pm »
That's quite a topic I was thinking of all the time when 0% hit chance resulted into the crazy cone of projectiles distribution. I believe that shot trajectory should be at least at the target's position unless it's broke with enemy nearby.   

Is it possible that megamods will include the Fire Extender modification in default to turn on? XCF and Piratez have no option in the mods setup.
« Last Edit: January 20, 2019, 08:47:03 pm by Abyss »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9089
    • View Profile
Re: UFO Extender accuracy discussion
« Reply #29 on: January 20, 2019, 08:54:08 pm »
Is it possible that megamods will include the Fire Extender modification in default to turn on? XCF and Piratez have no option in the mods setup.

Both Piratez and XCF have this option turned on.