Modme Forums

How to do RNG

Game Modding | Call of Duty: Black Ops 3 | Scripting


Zixology:

To make things simpler, I want to be able to have maybe 3 to 5 different ways a script can go each game. Completely random on which one takes place so that every time someone plays, it's not exactly the same. How can I do this? I only have pretty basic knowledge of scripting. Any and all help is appreciated.


Chroma:

I don't know, but I wonder if you could reverse engineer something like the shi no numa perk script.


FrostIceforge:

GSC has several built in random number functions. You can use RandomInt for a whole number less than a certain value (so RandomInt(5) would be 0, 1, 2, 3, or 4). RandomIntRange lets you choose a different starting point than zero, like if you wanted the numbers from 10 to 20 for example. RandomFloat and RandomFloatRange create decimal "floating point" numbers like 1.3, 5.7, etc. in the same way.

What you want in your case is:

switch(RandomInt(5))
{
    case 0:
        //SCRIPT SCENARIO 0
        break;
    case 1:
        //SCRIPT SCENARIO 1
        break;
    case 2:
        //SCRIPT SCENARIO 2
        break;
    case 3:
        //SCRIPT SCENARIO 3
        break;
    case 4:
        //SCRIPT SCENARIO 4
        break;
}