GSC reference › Built-in
RandomInt()
Built-in (engine)
Server
Math
Returns a random integer between 0 and max-1 inclusive
Signature
RandomInt(<max>)
Parameters
| Name | Required? | Details |
|---|---|---|
| max | Required | The maximum integer size |
Example (from Treyarch's docs)
if ( RandomInt( 100 ) > 50 ) ...
Real uses in BO3's scripts
Called 900 times in the decompiled scripts. A few, zombies first:
- scripts/shared/aat_shared.gsc, line 742
rand = randomint(keys.size); - scripts/shared/abilities/gadgets/_gadget_clone.gsc, line 1005
classnum = randomint(10); - scripts/shared/abilities/gadgets/_gadget_heat_wave.csc, line 217
currentyaw = randomint(360); - scripts/shared/array_shared.csc, line 695
return array[keys[randomint(keys.size)]]; - scripts/shared/array_shared.gsc, line 886
return array[keys[randomint(keys.size)]];
Related built-ins
- Int()Casts a floating point number or a string to an integer
- RandomIntRange()Returns a random integer r, where min <= r < max
- RotatePoint()Returns <angle> lerped angle value.
- PointOnSegmentNearestToPoint()Given a line segment and a point P, this returns the point on the segment that is closest to P.
- RotatePointAroundAxis()Returns a vector that is the result of point rotated around the axis vector by num degrees
- VectorFromLineToPoint()Given a line and a point P, this returns a vector perpendicular to the line and pointing from the line to P.
- GetDvarInt()Gets the value of a dvar.
- PrintLn()Development only - write line to the console
- SetHintString()Set the hint string for the entity
- IPrintLnBold()Write bold line to the screen
- IPrintLn()Write line to the screen
- GetClosestPointOnNavMesh()Get a point on NavMesh that's closest to the given position within radius.
New to GSC?
Start with the basics, or paste a compile error to get the fix.
Built-in descriptions, parameters and examples come from Treyarch's BO3 mod tools docs. Usage links point at shiversoftdev/t7-source (decompiled BO3 scripts).