The m_w and m_z variables are the RNG seeds and you must initialise them to a non-zero value before you start using the function. You should be able to use values calculated from one or more player coordinates/angle and/or gameticks passed to seed the RNG at each map (re)start if the decision about who the VIP will be is made some time into the game and the players are allowed to move a bit first.

Exactly. As a reminder, we now have:

Code:

1. Implementation of 2 new CVARs; "cv_localtime" and "cv_gmtime".
They're read-only and return the number of seconds since midnight
in local time and GMT time respectively.

This might as well be already sufficient enough. If not, I'd use the angle of one of the players (wait for at least 1 player to spawn, delay a second or two, then read the first player's angle).

1. Implementation of 2 new CVARs; "cv_localtime" and "cv_gmtime".
They're read-only and return the number of seconds since midnight
in local time and GMT time respectively.

Sweet mother of God! How do I keep missing that these things exist?

This would, of course, be the preferred way as it is the simplest, and it is completely sufficient in this case.

So, if I've got it right, in order to make it work nicely, you can make this :

Code:

/*
=============
Abs
Gives an Absolute value
=============
*/
function int Abs (int x)
{
if (x < 0)
return -x;

return x;
}

/*
=============
Random2
Alternative to Random's function (from Worst, helped by rhinoduck + Sr69Mm-jC)
=============
*/
function int Random2 (int min, int max) {

int m_z = GetCVAR("cv_gmtime");
int m_w = GetCVAR("cv_localtime");

/*
=============
Random2
Alternative to Random's function (from Worst, helped by rhinoduck + Sr69Mm-jC)
=============
*/
function int Random2 (int min, int max)
{
m_z = 36969 * (m_z & 65535) + (m_z >> 16);
m_w = 18000 * (m_w & 65535) + (m_w >> 16);
return Abs((m_z << 16) + m_w)%(max-min+1) + min;
}

The OPEN script will take care of populating the RNG seed (only needed once for one sequence of random numbers) at map start and you can then just use the function. Those two map variables hold the inner state of the RNG, you can assign to them again to change the seed and get a new sequence of random numbers (only needed at each map start in your case - happens in the OPEN script). The Abs function was alright.

You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum