# Best practice for RTS accuracy/aim

As I'm developing a RTS game set during the Napoleonic Campaign, I've got a question about the best method to implement 'bad aim' for the AI, as the accuracy of muskets were quite terrible back then.

Currently, in my GDD, the accuracy is calculated based on: stamina, dexterity, weapon accuracy and range. But this will result in calculating the chances of a hit in a Pen-and-Paper like style. If it fails the unit will shoot somewhere else (threshold around the target), as I want to have some visible tracer for optical reasons (even though this isn't historical accurate).

Is this method okay?

Because of this the damage is calculated instantly and prevent me theoretically from implementing a first person option for the player, as this would need a second aim&shoot calculation script.

What would be another solution for this?

You should create a parametrical equation. Map each variable (weapon accuracy, stamina, etc.) between 1 and 0, then multiply each value with a weight (if a lower stamina causes lower precision aim more than the precision of the gun, then it should have a higher weigh than the gun value), add them together, then divide the sum with the sum if the weights. This brings this value between 0 and 1.

• That's what I do. The question is more about the process of hitting a target. Commented Dec 6, 2016 at 11:41
• @Tech well, get a random number, if it's below that value, then it hits, if it isn't, then it's a miss Commented Dec 6, 2016 at 11:53
• @I know. It's more about If i should calculate the hit as stated above or should the AI "aim" like a five year old in oder to simullate the lack of precision Commented Dec 6, 2016 at 11:58
• @TechTree Well, before the modern guns, people literally just took a chance, because the smoke coming out of the gun was too thick to be able to see something trough it. So yeah, they should aim like a five years old. Commented Dec 6, 2016 at 12:00
• I think we are talking about the wrong thing^^ This is indeed the case but I'm still asking for a better method^^ A) Hit-Scan like pre calculation with event based hit/miss animation or B) randomly cast a ray with a threshold towards the enemy and only substract HP if the projectile hits the enemies collider Commented Dec 6, 2016 at 13:01

It really depends on the scale of your game, calculating hit detection can be very expensive if you have a game with units on the scale of a total war kind of game, where you may have hundreds of shots per minute. In that case you would have to sacrifice realism for the simple random number generator.

On smaller scales it might be possible to use proper hit detection, but this will be much more expensive.

It might also be worth making the accuracy a pseudo random distribution, so that it becomes increasingly easier for the ai to make a shot if they have already missed multiple in the past, making the game feel 'fairer' to the player.