Alright, now it will get complicated. This is where I discuss my spreadsheet.

Here the TL;DR:

You might know that a 100% accuracy shot can still miss and you need about ~120% for a guaranteed hit. Something similarly funky is going on for low accuracies. At distance 16 tiles, a shot with stated 1% accuracy has an actual accuracy of a little over 10% (I have tested that).

-- BEWARE OF MATH !---

So I tried to build a damage model that is as accurate as possible. This consists of two parts. Part 1 is the actual damage done, part two is 'do you hit or not'?

For the 0 - 200% damage roll, the average damage is:

{[(damage * resistance * 2) - armor * armorpierce]^2 } / (damage * 4)

Now calculating the hit chance... boy this gets complicated.

There is already a good amount of info out there:

https://www.ufopaedia.org/index.php/Accuracy_formula and

https://www.ufopaedia.org/index.php/Firing_Accuracy_TestingSadly, the page on firing accuracy testing does not actually state the formula that was used, it just gives the graph. So I tried to reverse engineer it from the information given. I arrived at this formula:

actual-hit-chance (dist) = 0,86 * acc + ( 1 - 0,86 * acc) * 0,462 / (dist * sin(deg))

dist = distance

acc = accuracy of the shot as stated by the game

deg is the angle of the firing cone for a missed shot as discussed in

https://www.ufopaedia.org/index.php/Accuracy_formula at the bottom. This value deg is also dependent on acc.

Using this formula I could get a reasonable fit of the graph.

Then I did my own testing to verify the formula. Unfortunately, I got different results. This could be because I used a different target. The example discussed here

https://www.ufopaedia.org/index.php/Firing_Accuracy_Testing uses a Muton as a target. I used an Agent in a suit as the target. They might have different size.

Anyway, my own results were as follows:

Distance 14, game accuracy 21, 180 shots. 61 hits = 34%

Distance 14, game accuracy 36, 180 shots. 87 hits = 48%

Distance 14, game accuracy 49, 120 shots. 67 hits = 56%

Here is where my scientific rigor is lacking. When doing statistics, you need a much bigger sample size to get consistent results. About 2000 or more is needed for the values to be reliable. Sooo... yeah, there is definately some error present. But I got tired of counting hits and misses at some point.

So to fit these results, I needed to modify the formula to:

actual-hit-chance (dist) = 0,8666 * acc + ( 1 - 0,8666 * acc) * 0,75 / (dist * sin(deg))

with deg(acc) = (20 - acc * 19) * Pi/180

I get a reasonable fit for my testing values with this formula. I played around with this formula for a bit and found that it has weaknesses. It can't do really close distances, and really low accuracy also seems to be off. So I would limit it's validity to distances of 8 to 20, accuracy should be 10% or more. I have also not added limits for accuracy over 100 yet.

So using this formula, I built a spreadsheet. You can enter the agent accuracy, the target armor, it's resistance and the distance of the shot. The spreadsheet takes into account dropoff and ranges of auto/snap/aimed shot. The output is then a single number that I would call 'damage output' of a gun. A higher number is better.

For an aimed shot however, this number is not a good indicator. Most rifles can do just one aimed shot per round, and it doesn't matter too much wheather it takes 60% or 70% Tu. What matters more is damage per round (number-of-shots-per-round * acc * damage). I've added that as a fourth column. At distances ~20 the stated accuracy should be close enough to actual accuracy that I don't need to use the complicated formula.

The spreadsheet has two pages. First page is the current state of the mod. Second page is my attempt at changing the stats for a better balance. Your opinion of what is a good balance will probably be different. This is still work in progress.