**Accuracy**

**Stationary targets**

This will have an entry in the entity xml for ranged attacks. The value will be in the range 0 to 1 and will mean the probability of hitting an infantry unit at maxRange.

When a missile is fired it will be placed according to a (2d) normal distribution (approximately). The normal distribution will be scaled linearly according to distance, so a missile fired half the distance has the same chance of hitting as a missile fired at a a target twice as wide (4x surface area). This makes aiming at nearby targets a lot more accurate.

Examples:With a maxRange of 100 and an accuracy of 0.5, the probabilities are (range:probability) 100: 50%, 75: 70%, 50: 93%, 25: 100%, 0: 100%. With a maxRange of 100 and an accuracy of 0.25, the probabilities are (range:probability) 100: 25%, 75: 40%, 50: 67%, 25: 87%, 0: 100%. With a maxRange of 100 and an accuracy of 0.0625, the probabilities are (range:probability) 100: 6.3%, 75: 8.4%, 50: 23%, 25: 64%, 0: 100%.

First, by mistake I calculated the results for a 1d normal distribution, here they are for comparison. With a maxRange of 100 and an accuracy of 0.5, the probabilities are (range:probability) 100: 50%, 75: 63%, 50: 82%, 25: 93%, 0: 100%. With a maxRange of 100 and an accuracy of 0.25, the probabilities are (range:probability) 100: 25%, 75: 29%, 50: 48%, 25: 80%, 0: 100%.

The 2d results should be fairly realistic, but for the game I think 1d would actually be better because it has a less extreme curve. Archers will automatically attack at maxRange and won't walk any closer automatically (at least currently) so having too much advantage for being closer encourages lots of micro.

Of course in dense formations if the arrow might well hit a nearby unit and will cause damage to that unit, this will make spread formations useful. Larger units such as cavalry will be easier to hit if they are stationary.

**Moving targets**

This is something that I am less sure about how to do properly so consider this a less strong proposal. Units should by default aim at where a unit is going to move to, using its movement vector. On its own this would lead to moving targets being hit with the same chance as still units though which is undesirable. There should be an accuracy decrease according to unit speed, I suggest having accuracy depend on the square of speed, with walking speed cavalry halving the hit probability and everything else worked out from there. This kind of thing is easily adjustable though so we could test and see what feels good. Again if you have a tight group then stray arrows will be likely to hit other units.

**Splash Damage**

I propose this xml structure for splash damage:

<Attack> <Melee> <Hack>7.0</Hack> <Pierce>17.0</Pierce> <Splash> <Type>Trample</Type> <Dist>5</Dist> <Crush>4.0</Hack> <FriendlyFire>No</FriendlyFire> </Splash> </Melee> </Attack>

This would work by giving splash damage to units within Dist in addition to the conventional attack, so the conventional attack would have to be decreased to compensate since the primary target would receive both conventional and splash damage.

I would recommend 3 types of splash damage, with this scheme only one would be possible per attack type (this restriction could be lifted if necessary but it would probably make the xml more messy).

**Circular**

This would damage all units in a circle of radius Dist around the location of the attack hitting (the unit being hit for melee or where the missile landed for ranged). It would have a quadratic damage falloff so units at range Dist (from the location of the hit) would receive 0 damage, units at range Dist/2 would receive 0.75x damage, units at range 0 would receive full damage. e.g. the rock throwing siege.

**Linear**

This would damage all units in a line aligned with the attack. So for a missile it would damage all units within dist of where the missile hit in the direction away from where the missile was fired from. It seems to be hard to put into words but is a simple idea so I drew a picture. The green blob is your bolt thrower, red are enemy soldiers, blue is the line along which damage is received so three red soldiers get hit. I would suggest quadratic damage falloff again.

**Trample**

This is identical to circular but the damage is calculated centered around the attacking unit rather than the position where the attack hit.