1# Accuracy and Projectiles
2
3Mechanics of accuracy.
4
5## Distance
6
7[Source](https://www.youtube.com/watch?v=HpzOTdItUGA)
8
9Accuracy depends on the distance to the intended target. The following figure shows accuracy of shooting a standing target at various distances. `o` represents the archer (in this case: Elite Longbowman), `X` represents the target. Every `.` symbolizes a tile between the two units.
10
11```
12......................................
13...1 Tile....oX.......................  100   % accuracy
14......................................
15...2 Tiles...o.X......................  100   % accuracy
16......................................
17...3 Tiles...o..X.....................  96.63 % accuracy
18......................................
19...4 Tiles...o...X....................  91.90 % accuracy
20......................................
21...6 Tiles...o.....X..................  87.82 % accuracy
22......................................
23...12 Tiles..o...........X............  83.17 % accuracy
24......................................
25...21 Tiles..o....................X...  81.77 % accuracy
26......................................
27```
28If the target is standing 2 or less tiles away, arrows always seem to hit. For targets at range 3 or more, the archer's accuracy deteriorates. The deterioration slows down with every tile between archer and target and seems to approach a *minimum accuracy* (in this case: 80 %).
29
30### Inaccuracy
31
32[Source](https://www.youtube.com/watch?v=nh3GnmFSkeY)
33
34The game probably determines first, if a shot is accurate (meaning it will 100 with a 100 % accuracy) or inaccurate. In the latter case the *accuracy error radius* comes into effect. This value is used by the game to calculate a margin between the target and the spot where the projectile lands.
35
36Also, this margin is likely related to the distance between archer and target. In this case, the code for calculating the margin would look like this:
37
38    (margin) = (distance) * rand(0,accuracy_error_radius)
39
40Because the margin is very low for most of the units a projectile can still hit its intended target despite being inaccurate.
41
42## Mechanics before and after "Ballistics"
43
44[Source](https://www.youtube.com/watch?v=1AXTuKJ1dLg)
45
46100 % accuracy in the game's sense must not be confused with hitting the target 100 % of the time.
47
48Before researching Ballistics, units fire at the current positions of a target. If the target moves and is fast enough, it will not be hit by the projectile. This has the effect that even though the game determines a shot to be accurate, it doesn't mean the target has to be hit.
49
50After the player researched Ballistics, units tend to fire at the position where the target is supposed to be when the arrow lands. The targeted unit can still dodge the shot if it moves into another direction after the archer fires.
51Ballistics does affect bombard towers but not other gunpowder or siege units.
52
53## Stray Arrows and Scorpions
54
55[Source2](https://www.youtube.com/watch?v=DZQn4-aAjGU)
56
57If a ranged unit misses its target but the arrow happens to hit a different unit, this unit only takes **half** of the damage.
58
59This behaviour also applies to scorpions and other units, which have arrows passing through units. Scorpions will only damage their targeted unit with full damage, even if the arrows move through other units first.
60[Source](https://www.youtube.com/watch?v=o4Z0BTmzRgg)
61
62## Target Size
63
64[Source3](https://www.youtube.com/watch?v=33MEpQKCTes)
65
66The chance to hit also depends on the unit size. Bigger units seem to have a larger area to hit which in consequence counters the effect of the *accuracy error radius*.
67
68## Friendly Fire
69
70Most of the ranged units do not injure friendly units with their projectiles. The Onager is an exception because its "area of effect" attack hits all units regardless of their owner. However, other units with "area of effect"-damage such as petards and demolition ships do not injure friendlies.
71
72## Weird AoE2 Quirks
73
74When a ranged unit dies but the projectile is still in the air, modifiers for damage and effects might change. Some of the effects include:
75
76* When a trebuchet is packed before it has hit its target, the damage of the projectile will change to 1. If the trebuchet is destroyed before the projectile hits, it does no damage.
77* If a scorpion is destroyed, the bolt can suddenly destroy trees on its path.
78* The bonus for standing on a cliff or hill (+25 % damage) is removed after the units dies and all arrows that are still in the air will do normal damage.
79* Portuguese caravels fire in random directions, if attacking a melee unit at range 0. This seems to be a bug related to calculations concerning the *accuracy error radius*.
80
81[Source](https://www.youtube.com/watch?v=O6fD4AC5sFQ)
82
83Other things related to accuracy:
84
85* Trebuchets also have a hard coded 80 % accuracy against buildings [Source](https://youtu.be/nh3GnmFSkeY?t=5m46s)
86* British trebuchets after researching "Warwolf" have a 100 % accuracy against every unit except 1x1 tile buildings [Source](https://youtu.be/nh3GnmFSkeY?t=11m44s)
87