New script command:
srand({seed}) - Set global random number generation seed to {seed}. In most cases (probably all) you'll want to use elapsed time.
Normally, random numbers are seeded with an incrementing default starting at 1234567890. See below:
Note: This feature is not yet tested. Also be aware the random number seed is global, so ALL subsequent random number generation calls will be affected, including those made internally by the engine for things like AI randomness. While it should actually improve AI diversity, there may be unforeseen side effects.
DOWNLOAD
srand({seed}) - Set global random number generation seed to {seed}. In most cases (probably all) you'll want to use elapsed time.
Normally, random numbers are seeded with an incrementing default starting at 1234567890. See below:
Code:
/*
* OpenBOR - http://www.chronocrash.com
* -----------------------------------------------------------------------
* All rights reserved, see LICENSE in OpenBOR root for details.
*
* Copyright (c) 2004 - 2014 OpenBOR Team
*/
#include "rand32.h"
#include "types.h"
unsigned long seed = 1234567890;
unsigned int rand32(void)
{
u64 t = seed;
t *= 1103515245ull;
t += 12345ull;
seed = t;
return (t >> 16) & 0xFFFFFFFF;
}
void srand32(int n)
{
seed = n;
}
Note: This feature is not yet tested. Also be aware the random number seed is global, so ALL subsequent random number generation calls will be affected, including those made internally by the engine for things like AI randomness. While it should actually improve AI diversity, there may be unforeseen side effects.
DOWNLOAD