RTCW Study - Spreadscale
•
22 Jan 2017, 18:34
•
Tutorials
Hi guys,
I've got hooked on browsing RTCW source code and decided to make a video about the nitty-gritty details that shape the game. I decided to start with the mechanisms that controls spreadscale (recoil) of RTCW guns.
In this video I experiment with shooting guns while trying to explain what makes them shoot more or less accurate. I think it's a great overview for experienced players the sake of completing the puzzles and should be pretty educational for others. Either way I invite the discussion!
https://www.youtube.com/watch?v=gSAL7SE9PWA&hd=1
I've got hooked on browsing RTCW source code and decided to make a video about the nitty-gritty details that shape the game. I decided to start with the mechanisms that controls spreadscale (recoil) of RTCW guns.
In this video I experiment with shooting guns while trying to explain what makes them shoot more or less accurate. I think it's a great overview for experienced players the sake of completing the puzzles and should be pretty educational for others. Either way I invite the discussion!
https://www.youtube.com/watch?v=gSAL7SE9PWA&hd=1
You said "everything **** (couldn't understand) by 10 is going to be zero so this is kinda strange". This code is not so strange and does something very simple. In C the rand() function returns a (sort of) random integer between 0 and whatever is set for RAND_MAX. On that value it uses the modulus operator (%) which simply returns the remainder of whatever it is divided by. In this code it uses 10 so it will return the remainder of the rand() value divided by 10. So, for example if the rand() function returned 54378064, then "rand() % 10" would simply return the number 4. aimSpreadScaleAdd with this example rand() value would result in the value 19.
Basically what the code does is create an aimSpreadScaleAdd value that lies between 15 and 24, based on a random number (possible remainder values when something is divided by 10 are 0 to 9)