Categories
Game Development

Cheat-proof shooting algorithm

Originally, as I implemented the bullet shooting code I would have the client send the bullet’s velocity,position, and orientation to the server. The server would verify these values for sanity and if they were reasonable it would accept them. Otherwise it would reject them. It occurred to me this isn’t very cheat-proof, especially since I […]

Originally, as I implemented the bullet shooting code I would have the client send the bullet’s velocity,position, and orientation to the server. The server would verify these values for sanity and if they were reasonable it would accept them. Otherwise it would reject them.

It occurred to me this isn’t very cheat-proof, especially since I allow modders to change the model. While it would block the most extreme cheats, you could still angle your weapons, shoot slightly faster or slower, or even auto-aim.

I changed it to where I record all fighter positions for the last second in a circular queue. When a shoot packet comes in, I use the timestamp to look back in history to see where the fighter was on the server when the bullet was fired.

This is cheat-proof, pretty accurate, and the only thing you could modify is the timestamp. But there’s really no benefit from changing the timestamp, as any changes will simply make the shot less accurate.

One reply on “Cheat-proof shooting algorithm”

For small variances – e.g., the fighter is mostly aimed in the right spot, but the only question is when exactly to fire – a bot could probably considerably improve aim by twiddling the timestamp just a little bit. For small amounts of twiddle, I think the improvement in accuracy will outweigh the cost of being late (especially with any kind of prediction).

Also, it doesn’t do anything to reduce client-side cheating to simply improve aim – helping you steer, in other words, instead of timing the firing perfectly.

Leave a Reply

Your email address will not be published. Required fields are marked *