# Talk:Accuracy formula

Jump to navigation Jump to search

From experience I think the chance of hitting an alien tends to be best if in an exact straight line (orthagonal or diagonal), and on the same level as it. This probably is explained by the misses that hit anyway, because you can miss slightly short and kneecap them, or long and hit them in the face, but I think this is less likely if you are at an oblique or acute angle (because there are less squares that are behind him you can scatter to, but still hit him - especially as you get further and further away so the aliens width becomes less of a factor). Equally with height, the further up you are, the less squares the fire can scatter to but still intersect with the alien.

Does this match up with other peoples experiences?

--Sfnhltb 12:59, 27 February 2007 (PST)

Hmm, I'm not sure what I'd say. In theory the "silhouette" wouldn't change much, if the angle were not a multiple of 45 degrees (that's what you mean, right?). I'm willing to bet that the engine is more influenced by things that might truncate values here and there, than anything else. And/or the interaction with exactly how they "draw" the "3D" target that the shot's trying to intersect. I'm sure it's crude but effective... but crude in what ways? shrug. - MikeTheRed 15:50, 28 February 2007 (PST)

Does the accuracy displayed in-game for the auto-fire apply to each individual shot or to all three shots?

It applies to each individual shot. -NKF 22:39, 1 December 2008 (CST)
Indeed. Note that the displayed "chance to hit" isn't really your chance to hit... It's more a measurement of the ranges of angles you can fire along. - Bomb Bloke 00:37, 2 December 2008 (CST)
In Laser Squad Nemesis, that is explicit - units have a stat called "inaccuracy", defined as "The average deviation from true for a weapon shot, in degrees." Has anyone made tests in X-Com, what is the relation of distance to target and displayed and actual chance to hit? - Quantifier 05:14, 2 December 2008 (CST)
Yes, this has been done. Arrow Quivershaft 08:49, 2 December 2008 (CST)
As in "spread" of your shots, BB? Where bigger spread means, less accurate? -MikeTheRed 04:15, 2 December 2008 (CST)

What, exactly, happens when you miss? Does the game shift your aim by pivoting around the fire point or actually pick a random location in 3D that's close'ish to the target? It seems to me like it's the latter due to your ability to miss and shoot the ground right at your feet when shooting at nearby aliens. This doesn't seem to happen for farther away targets. Would this then suggest that aiming behind your target could potentially result in more hits on target due to more "misses" hitting? I haven't tried this tactic in practice.

This is one of the unanswered questions, but the working hypothesis is that there is no specific hit/miss determination. That is, the game engine just fires the shot and introduces a random angular error. The maximum angular error is inversely proportional to the adjusted Chance to Hit. If the angular error is wide enough, the path of the shot no longer intersects the silhouette of the target defined by LOFTEMPS. Horizontal angular error seems to be greater than vertical angular error. But, most of this is conjecture. I was talking to Mike The Red about doing some histograms, analysing multiple shots with a wall of some vertical "destructible terrain" positioned behind a target. But we did not make any progress on that. Spike 14:13, 1 April 2011 (EDT)
Seb76 has obtained the firing point from the executable. I have a reverse-engineering of the horizontal angle the game pivots around the fire point (cf. User_talk:Bomb_Bloke:Firing_Accuracy), but I haven't been able to convince Bomb Bloke that it's completely correct. (We disagree on how my formula graphs. It does exactly match the extreme bounds by construction.) I am getting empirically correct predictions in-game combining my horizontal accuracy formula with Blind_Spots_From_First_Principles. It's very nice being able to directly calculate the best possible ambush locations in a landed Supply ship :) Zaimoni 23:51, April 1, 2011 (CDT)

## Height?

I've been testing a new terrain which has several 2 and 3 level buildings and one thing that I am noticing is that accuracy seems to be affected by differences in height. The terrain allows for long range gunfights between different heights and it has become common to see my elite soldiers hitting nearly all targets at the same height but missing close to half while firing at a different height. Hobbes 17:28, 28 February 2012 (EST)

Units seem to have better accuracy vertically then they do horizontally, but as you get higher and higher above your target, their profile effectively gets smaller (eg, if you're directly above someone, all you're shooting at is their head).
Though there may be more to it then this. Kneeling when standing directly next to an alien (forcing them to fire downwards at you) dramatically increases your life expectancy, way more then you'd expect it to. In fact kneeling increases the odds so dramatically in your favour that you could just about believe there's a bug in the firing engine somewhere.
Shots are weighted (according to a bellcurve) so that they'll typically be closer to what you're shooting at, on average, then they could be. At 0% accuracy, you "can" fire anywhere up to half a radian to either the left or the right of the target - at 100%, you're still not guaranteed a hit, but you will never miss by MUCH (dunno what percentage you need to achieve "perfect" accuracy). This is why rookies are more likely to hit other team members then veterans are - because even if a vet misses, odds are his firing line is going to be closer to the alien then that of a rookie, so he has less chance of hitting anything that isn't directly between him and the target.
from the code: there seems to be two type of "misses", 1) a big miss, when the soldier completely misses against the odds displayed in the shooting menu, the bullet has high dispersion factor, and a 2) close shot, when the odds put the bullet just on target (close RNG call), there is a small extra divergence factor. So the rookies, obviously, get more of the first type. The first type of miss is probably responsible for the unreal "close miss" 1 or 2 tiles away. --kyrub 16:13, 1 March 2012 (EST)
I see you posted a formula regarding this on my accuracy testing page a few months back - I missed it then, but am looking at it with great interest now!
It never excludes accuracy from the equation entirely (as you're suggesting in your above post), but assuming "dispersion factor" represents the maximum angle a unit can shoot at, then a DF of 150 (only possible to roll with 0 accuracy) would mean that the actual shot COULD go anywhere within a radian spread, while a DF of 0 (achievable whenever x plus ten happens to be equal to accuracy) should always hit dead-on (a one-in-a-hundred chance of this happening, assuming accuracy is between 10 to 110 - otherwise, it can't).
There would have to be another roll after this to get the actual angle, but even a simple one would be enough to generate some degree of curve to the average shot angle observed in game. I wrote a proggy to generate a few thousand angles by first rolling a DF based on an accuracy of 0, then randomly selecting an angle from a range of DF divided by 150 times a radian, and got a graph that seems to exactly match the curve I obtained empirically! VERY happy to see that, though it may not hold up for other FAs (will have to do more testing tomorrow).
I guess there's another roll to get the vertical deviation in addition to the horizontal one, but I dunno what the max vertical firing angle is yet. And going by what Hobbes is saying, it may be that that roll is further affected by the height difference between units... - 07:19, 2 March 2012 (EST)
But I digress. Vertically speaking, the angle range is much lower (though I haven't measured that one precisely yet - I just know it's smaller), but it may be that the same "weighting" isn't performed. This'd make height deviations much more important then they'd first appear as shot deviations would be less predictable. - 09:14, 1 March 2012 (EST)
I should have mentioned that the shooting at buildings usually involves targets at both different vertical and horizontal levels. And it gets really weird to see because you have a soldier with 90 to 100 Firing Accuracy and its shots come as if he has only half the accuracy. Hobbes 14:24, 1 March 2012 (EST)
So you're saying the shots go a lot wider if the target isn't on the same level? It may indeed be that the effective accuracy of a soldier does indeed get a penalty in that scenario, if that's the case. Are you talking left/right angles or up/down ones? - 07:19, 2 March 2012 (EST)
Not sure what you mean by left/right up/down angles. Usually the situation is a soldier at ground level firing at a distance of 7 tiles or more to an alien located on the 1st or 2nd level, either to the left or to the right, of the soldier. You see this also happening while firing from the top of the Skyranger ramp. Hobbes 07:29, 2 March 2012 (EST)
What I'm getting at is that the lower your accuracy, the wider your shots can go. A soldier with 100 accuracy will, if he misses, hit a tile very close to the target - if he were firing "as if he has only half the accuracy", then he can miss by quite a bit more. A soldier with VERY low accuracy may fire on such a bad angle that he actually has to turn in order to make the shot (I guess this happens whenever his selected firing line is more then 22.5 degrees away from the target, given that the eight different directions he can face divides into 360 degrees 45 times). Though you have to have somewhat less then 50 accuracy to even have a chance of firing that badly.
Though I realise this isn't strictly common knowledge, so that may not be what you meant.
To rephrase the question: When your soldiers miss, have you been able to spot whether the bullet usually goes to the left or right of the alien (that is to say, is the horizontal angle off), or does it usually line up horizontally but miss vertically (in which case the bullet would end up hitting directly above/below the target)? Or both? - 08:16, 2 March 2012 (EST)
Got it now, thanks. The answer to your last question is both - when they miss the shot can go stray either horizontal or vertical or both. Another thing that I've remembered is that flying units also seem to suffer from an accuracy penalty when firing on the air, so I think that there's definitely a height factor involved in the calculation for a shot to hit or miss.Hobbes 09:57, 2 March 2012 (EST)

## Tank Puzzle

Whoops - hit rollback instead of edit.

While we're on the topic of firing accuracy here's a puzzle that I came upon in TFTD that may suggest there's more to calculating accuracy. Either that, or TFTD is just different.

Scenario: Damaged G. Cannon/Coelacanth with 2/90 health, reducing base firing accuracy to 1%. Theoretically this means that its aimed shot should now be something like 1.2%. (I think that's right. (2/90) * 60 * (90/100) = 1.2%)

What the game reads out to me is that it has 40% aimed accuracy, and I actually hit something in the next field over.

Another probable spanner in the works?

Coincidentally, didn't realise 50% of the main article was just a really old verbatim quote of mine speculating about this matter. -NKF 01:51, 4 March 2012 (EST)

Just performed some tests by editing soldier's health levels. Found that in both UFO and TFTD the actual penalty applied by taking damage is 25% * PercentHealthLost, rounded up.
This doesn't match your observation, but when I rigged up a G. Cannon with two health it got 38% accuracy, which DOES match up given that it's top rated accuracy was 51%. I notice that my tank's aimed shot accuracy is only 85% (60% unit accuracy divided by the 51% rated shot accuracy), whereas our data page for that unit reports 90%. This value must be correct for your game, which I'm guessing is DOS (90% weapon accuracy times 60% unit accuracy times 75% due to lost life = 40%), but incorrect for mine (CE)? - 03:02, 4 March 2012 (EST)
Yep, was using the v2.0 dos version. Are the SWS accuracies different in the CE version? -NKF 03:53, 4 March 2012 (EST)
Nope, they're not. I'm just an idiot who assumed "G. Cannon" meant "Gauss Cannon". - 04:12, 4 March 2012 (EST)

## Percentage of life lost? or remaining?

The formula on the page, as stated, implies that your accuracy gets better as your health goes down. (75% + 25% * percentage life lost) means that it would be a 75% multiplier at full health, and a 100% multiplier (or non factor) when you're dead. I'm assuming that this is a mistype and not the actual formula, just from a common sense perspective, and that it should read (75% + 25% * percentage of life remaining) which would add up to 100% at full health, approaching 75% as you near death.--Twilightdusk 13:03, 5 March 2012 (EST)

Too silly mistakes I made in a row! Got it stuck in my head that it was a penalty, then went and wrote an equation that applied it as a bonus.
Note that the game does appear to apply it as a bonus, and rounds it down. So in cases like the example NKF posted (the tank with 2hp left) you take the full -25%. - 17:13, 5 March 2012 (EST)

## Maximum Gun Accuracy

Soldier Kneeling Bonus = +15%.

Max Soldier Accuracy = 125% Best Case or 120% Typical.

Max Engine Accuracy = 254% (250% to be Safe)

Best Case Multiplier: 1.15 x 1.25 = 1.4375 (Kneeling Bonus X Absolute Max Accuracy = Multiplier)

Typical Multiplier: 1.15 x 1.20 = 1.38 (Kneeling Bonus X Typcial Max Accuracy = Multiplier)

#### ABSOLUTELY the Maximum Accuracy percentages to be used in an editor if using these settings:

Max Engine & Best Case: 254 / 1.4375 = 176.695652 (176%)

Safe Engine & Best Case: 250 / 1.4375 = 173.913043 (173%)

Max Engine & Typical: 254 / 1.38 = 184.0580 (184%)

Safe Engine & Typical: 250 / 1.38 = 181.159420 (181%)

### What This Means

When editing a gun for absolute best accuracy rating (when doing auto,snap or aimed) you cannot (or rather really shouldn't) go over 254% Chance to Hit. Since kneeling and maximum soldier accuracy are the only two the matter (since everything else will decrease the chance to hit. eg: fatal wounds, two handed weap using one hand etc. etc.), just making a gun (in your editor) at 254% accuracy will give an in-game best chance to hit of 365%. Since this is over the 255 wrap-around, your gun will end up being garbage!

Try to use a safe approach and limit the game behaving badly by using a conservative maximum gun accuracy in your editor of 170%. I'm pretty sure I have it correct. EsTeR 06:07, 22 March 2012 (EDT)

UPDATE Just tested this: Soldier: Acc=125 Edited Rifle Accuracy: 170% Aimed, 250% Snap, 255% Auto.

Chance to hit (NOT kneeling): 212% Aimed, 312% Snap, 318% Auto. Chance to hit (kneeling): 243% Aimed, -297% Snap, -290% Auto.

Confirmed that aproximately 170% editor value for gun accuracy is best using any type of shot (when the soldier is at maximum accuracy). Although I doubt that 318% is correct! EsTeR 06:39, 22 March 2012 (EDT)

UPDATE 2 Changed weapon accuracy in editor to 228%, 229%, 230%. Used a soldier with 125 accuracy and got these values:

Not Kneeling (in-game chance to hit): 285%, 286%, 287%. Kneeling: 326%, 327%, -326%

WHAT!?!? With a soldier at absolute maximum accuracy (of 125), the absolute best accuracy you should give a weapon when editing them is:

229%

giving an ingame chance-to-hit of:

327%.

although I only used a standard rifle for this test, I cannot see how this would affect any other guns or launchers.

Used: Xcom 1 CE pure, win98 (no dosbox)

Editor Weapon: UFOMOD v1.0 (Chris Voss)

Editor Soldier: UFOSAVED v2.3 {Victor Fernandez Martinez}

EsTeR 07:08, 22 March 2012 (EDT)

### non-uniform spreading

It's clearly that shooting along X axis has lower accuracy than shooting along Y axis. Diagonal shoots are also wide spreaded. There are 2 kinds of areas in these sets: A) hit area - almost doesn't have any deviations. B) miss area - is quite deviated, depends on distance and angle (non uniform). For accuracy 0 there's no hit area - everything is covered by miss area, though it doesn't mean it can't hit at all. There are small chances. For accuracy 109 there's no miss area (doesn't matter if it gone beyond109). Though "hit" spot has size 2x2x2 voxels, so it's possible that projectile will hit obstacle with chance. Vertical (z) spread is 1/2 of x/y. There's also some x/y spreading addition when Z of origin and Z of target are differ. And the more difference of Z, the more x/y addition it has.

--Volutar 07:47, 11 November 2013 (EST)

## Most recent edit

The most recent edit to this article (in 2013) changed the "health modifier" to a simple "current health/max health".

I know this is wrong, because I've had soldiers on 1 HP (which is logically at most 4% of their maximum) with displayed double-digit chances to hit. I don't know if the previously-listed "0.75 + 0.25*current health/max health" is correct or not, but I know that the one up there at the moment can't possibly be right.

Could someone with some more knowledge than myself comment on this? Magic9mushroom (talk) 03:11, 17 August 2015 (EDT)

The health multiplier is indeed 0.75 + (0.25 * current health/max health). The simpler health/max health formula was what we worked out originally until we learned more about how health relates to accuracy. Let's fix that. NKF (talk) 03:42, 17 August 2015 (EDT)

Oh, I think I see what's going on. The stats screen of a unit reports Firing Accuracy as being penalised by that "current health/max health" factor, while the shot selection screen when you're using a weapon (and, I'm pretty sure, the actual firing algorithm) uses "0.75 + 0.25 * current health/max health". Known Bugs material, you think? Magic9mushroom (talk) 05:03, 17 August 2015 (EDT)

Definitely. The game has a number of information screens with erroneous or omitted data, so we appear to have another one. NKF (talk) 05:52, 17 August 2015 (EDT)