GSC reference › Built-in
RandomIntRange()
Built-in (engine)
Server
Math
Returns a random integer r, where min <= r < max
Signature
RandomIntRange(<min>, <max>)
Parameters
| Name | Required? | Details |
|---|---|---|
| min | Required | The minimum result |
| max | Required | The maximum result + 1 |
Example (from Treyarch's docs)
rand = RandomIntRange( 3, 5 )
Real uses in BO3's scripts
Called 845 times in the decompiled scripts. A few, zombies first:
- scripts/zm/_ambient.csc, line 153
random_angle = (randomintrange(min_pitch, max_pitch) * -1, randomint(360), 0); - scripts/zm/_destructible.gsc, line 335
wait(randomintrange(wait_times[0], wait_times[1])); - scripts/zm/_zm.csc, line 1778
playfx(clientnum, burst_fx, self.origin + (0, 0, randomintrange(5, 10))); - scripts/zm/_zm.gsc, line 4416
rand = randomintrange(0, players.size); - scripts/zm/_zm_ai_astro.gsc, line 53
level.next_astro_round = level.astro_round_start + (randomintrange(0, level.max_astro_round_wait + 1));
Related built-ins
- Int()Casts a floating point number or a string to an integer
- RandomFloatRange()Returns a random floating point number r, where min <= r < max
- RandomInt()Returns a random integer between 0 and max-1 inclusive
- 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
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).