Calculating where bullets will land based off cone?
4 replies, posted
How does the game calculate where the bullets will land based off the cone of the swep?
When using bullets with the FireBullets function, spread is set by...bullet.Spread = Vector(cone, cone, 0)
cone being set earlier in the script..
How exactly does the game take the bullet.Spread and set where the bullets are going to land at?
Based off no spread hacks from other games I've seen, I assume that how far from the crosshair the bullet will land is calculated before the gun is actually fired.
It uses the MD5 hash of the id number of the current user command and puts it through a function that calculates the angle to fire based off this hash. This way the client's effects are correct for the angle in which the bullet fires on the server.
(Thanks to Azu for helping me discover this)
If you're looking to create a NoSpread module - good luck. It's pretty frustrating to do.
If you want to create your own spread system: Simply set the bullet.Spread to perfectly accurate and change the angle of the shot based on a math.random result.
[QUOTE=Deco Da Man;18377451]It uses the MD5 hash of the id number of the current user command and puts it through a function that calculates the angle to fire based off this hash. This way the client's effects are correct for the angle in which the bullet fires on the server.
(Thanks to Azu for helping me discover this)
If you're looking to create a NoSpread module - good luck. It's pretty frustrating to do.
If you want to create your own spread system: Simply set the bullet.Spread to perfectly accurate and change the angle of the shot based on a math.random result.[/QUOTE]
Yeah I essentially am trying to develop my own no spread module.... the way I have seen others work I assume the offset of where the bullet will land is calculated before the shot.
If the bullet is offset to land 3 inches above the crosshair, right before the crosshair would quickly be moved 3 inches below current position, shoot, and then move it back up. I just need a way to find that offset.
I may be off base here, but in my experience toying with existing weapons, I usually set it this way...
SWEP.Primary.Cone = 0
[QUOTE=Xtensity;18377729]Yeah I essentially am trying to develop my own no spread module.... the way I have seen others work I assume the offset of where the bullet will land is calculated before the shot.
If the bullet is offset to land 3 inches above the crosshair, right before the crosshair would quickly be moved 3 inches below current position, shoot, and then move it back up. I just need a way to find that offset.[/QUOTE]
Well technically the "crosshair" is never moved and doesn't need to as it's just a sprite on your screen. It's the vector of the bullet trace that receives an offset.
Sorry, you need to Log In to post a reply to this thread.