ZDaemon ACS Extensions - Pseudorandom Numbers

Pseudorandom Numbers functions

4 ACS functions for simpler/better pseudorandom numbers. The syntax is:

int ZD_rand(int min_value, int max_value);
void ZD_srand(int seed);
void ZD_rand_savestate();
void ZD_rand_restorestate();

  • ZD_rand() draws a uniformly distributed random number in the specified range (the range includes the min. and max. values). It can work in "repeatable" mode (via the functions below), but that's NOT the default operation; it defaults to "always new" drawings.

  • ZD_srand() sets the seed of the random number generator; if the specified value is negative, then it will use something "random" based on the current time and other parameters. This function gets auto-called with seed = -1 on every map load, which results in "always new" drawings; if you want repeatability, you can call the function with a fixed (and non-negative) seed value (eg., 0).

  • ZD_rand_savestate() saves the current state so you can restore it later.

  • ZD_rand_restorestate() restores a previously saved state so you can re-draw the same random numbers.