Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "random"
From Quake Wiki
(Created page with "Syntax:<br/> <code>float random()</code> This function returns a floating point value greater than or equal to 0 and less than 1.") |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | ''float'' '''random'''() | |
− | + | == Usage == | |
+ | Used for generating random numbers e.g. with weapon spread. | ||
− | + | === Return === | |
+ | Returns a floating point value in the range [0, 1]. The fact it can return 1 is an oversight and caution should be exercised if using it for array indices. | ||
+ | |||
+ | == Example == | ||
+ | // Adds anywhere from 0 to 32 extra map units to the range | ||
+ | float checkRadius = 256 + 32 * random(); | ||
+ | entity head = findradius(pos, checkRadius); |
Latest revision as of 01:39, 31 July 2023
float random()
Usage[edit]
Used for generating random numbers e.g. with weapon spread.
Return[edit]
Returns a floating point value in the range [0, 1]. The fact it can return 1 is an oversight and caution should be exercised if using it for array indices.
Example[edit]
// Adds anywhere from 0 to 32 extra map units to the range float checkRadius = 256 + 32 * random(); entity head = findradius(pos, checkRadius);