-
Notifications
You must be signed in to change notification settings - Fork 3
Random
Jake edited this page Aug 4, 2021
·
11 revisions
Useful links:
- https://wiki.zeroy.com/index.php?title=Call_of_Duty_4:_Scripting_Reference_-_Math
- https://github.com/shit-ware/IW4/blob/master/common_scripts/utility.gsc
- https://github.com/Flo122/Mw2/blob/master/AwesomeMod/Cleane%20Mod-Files/common_scripts/utility.gsc
Return a random value from an array
elements = [];
elements[elements.size] = "a";
elements[elements.size] = "b";
elements[elements.size] = "c";
random_value = random(elements); //a, b, or c
Include: common_scripts\utility
Return a random boolean (50/50)
random_value = cointoss(); //true or false
Include: common_scripts\utility
Return a random vector centered on <num>
direction = randomVector(1);
Include: common_scripts\utility
Return a random vector centered between <num_min> and <num_max>
direction = randomVectorRange(5, 10)
Include: common_scripts\utility
Return a random integer between 0 and <max>-1
random_value = randomInt(3); //possible contents: 0, 1, 2
Return a random integer between <min> and <max>-1
random_value = randomIntRange(2, 5); //possible contents: 2, 3, 4
Return a random float in the range: 0 <= x < max
random_value = randomFloat(1); //could equal any number >= 0 and < 1
Return a random float in the range: min <= x < max
random_value = randomFloatRange(1, 2); //could equal any number >= 1 and < 2