How to deal with gun accuracy in an authoritative server?

I am working on a third-person-shooter that uses an authoritative server for pretty much everything. Instead of using RPC’s for shots I am simply using OnSerializeNetworkView and serializing the character state at that moment. The character state includes a simple bool value that says if the character is firing or not. The client then simulates the shot and where it would have hit, the server does its own simulation checking where players were at the time of the shot then raycasting and sending out an RPC if a player was hit. I don’t use an RPC for shots because I want the origin and direction of the shot to be authoritative and not allow a client to simply say “i want to shoot from point A with direction B” as this could be hacked.

Problem:
I am currently not implementing any type of accuracy system with the gun shots at the moment so everything works great as the server simulation is usually the same as the players. However once random accuracy is introduced the client side simulation of gun shots is not likely to be the same as the server simulation, seeing that random numbers on the client side are not going to be the same as the server side.

My initial idea is to round the client command time and set that as Random.seed once the server receives the latest command from the player, however the server is receiving multiple commands from multiple players all the time, so this seed would be getting overwritten constantly, so that doesn’t work. Somehow it almost seems like I need a local random number generator that would exist for each client and have its own local seed, but im not sure how I could do something like that, or if it would even work.

Has anyone come across this issue before and solved it?

Well, if you’ve played Call of Duty: Black Ops, the replays there are absolutely terrible. It will say you had a headshot when clearly the shots were not even near the head. If they can get away with that level of half-hearted replay quality, you’ll be fine.

I guess its possible that the client simulation only gives a semi-accurate representation of where the shots may go, but during my years of Counter-Strike play, I can safely say that the clients prediction of where the bullets would go is very accurate without waiting for a response from the server. Unfortunately Halflife engine is not open source as far as I know. Quake3 is open source, however from what I remember in quake 3 movement is the only thing that is predicted client side, and shots arent rendered until the client receives a response from the server.

Easy - make the random numbers on the client the same as those on the server.

How? As I layed out in the original post I cant just seed both the client and server with the same seed, the client will likely not process as much random data as the server, and the server will be processing inputs from all players including itself.

I’m sure there are dozen’s of ways - but how about this?

Use the number of shot’s fired as your seed. It is fairly trivial to count your shots, and you should already be ensuring that both the server and the client agree on this detail.

Anywho - your problem is that your thinking of random as a single thing for your entire game - there is absolutely no reason why you can’t have a seeded pair for each players aiming system - one for server one for the player.

Sounds like if this was the case I would need a Random Number Generator for each client, so they are exclusive from each others seed values.

Now they I have tried the game with some accuracy in it without syncing randomness, it actually isn’t too bad. A player should be attempting to aim directly at the target, so if they are accurate in their aim, similar number of shots should hit the player, as the overall accuracy of the gun is the same on the client and server.

Yep. Or you could constantly be resetting the seed (which seems kinda pointless).

Depends on how you build your game really, but I’ve played plenty of games where a random bullet (near the end of a long firing spree) has killed my (already weaken) opponent. So it can matter.

Well it does matter that random bullets can kill your enemy, however the only difference would be that the clients representation of where the bullets are going are not exactly the same as the servers. Random bullets should still be able to kill your enemy.