GSC reference › Built-in

RandomFloat()

Built-in (engine) Server Math

Returns a random floating point number r, where 0 <= r < max

Signature

RandomFloat(<max>)

Parameters

NameRequired?Details
maxRequired The maximum floating point size

Example (from Treyarch's docs)

if ( RandomFloat( 100 ) > 50 ) ...

Real uses in BO3's scripts

Called 195 times in the decompiled scripts. A few, zombies first:

Related built-ins

  • RandomFloatRange()
    Returns a random floating point number r, where min <= r < max
  • MapFloat()
    Returns a lerped value between <from> and <to> based on <time>.
  • Float()
    Casts a string or an integer to a float
  • LerpFloat()
    Returns a lerped value between <from> and <to> based on <time>
  • GetDvarFloat()
    Gets the value of a dvar.
  • IsFloat()
    Checks whether this entity/variable is a float
  • StrIsFloat()
    Check if a string is a float.
  • Int()
    Casts a floating point number or a string to an integer
  • DistanceSquared()
    Returns the squared distance between two points - this is cheaper than the actual distance as it doesn't involve a square root
  • RandomInt()
    Returns a random integer between 0 and max-1 inclusive
  • RandomIntRange()
    Returns a random integer r, where min <= r < max
  • AnglesToForward()
    Returns the forward vector corresponding to a set of angles.

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).