Parsed random range

From FreeSpace Wiki
Revision as of 18:42, 19 September 2024 by Kestrellius (talk | contribs) (Created page with "{{SCP_table}} The '''parsed random range''' syntax allows modders to specify random distributions for certain values. {{Table242| As of 24.2, there are three types of distri...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This feature requires FreeSpace Open

The parsed random range syntax allows modders to specify random distributions for certain values.


FS2 Open, 24.2:

As of 24.2, there are three types of distribution available: uniform, normal, and curve. Uniform is used by default if there is no string specifying type; normal and curve are accessed by prefacing the min and max values with the appropriate string. Details below.

Uniform random range

  • This accepts 1 or 2 values. If one value is used then the random range always returns that value. If two values are specified then a uniformly distributed random value will be picked from the range, with the first value as minimum and the second as maximum.
  • Prior to 24.2, this was the only type of random range available in tables.
  • Syntax: (Random values), a list of floating point values. Either one or two values. If only one value is specified then the parentheses are optional.
    • Example: (4 20)
    • Example: 4


FS2 Open, 24.2:

Normal distribution random range

  • This takes the string "NORMAL", followed by 1 or 2 values. This random range generates values according to a normal distribution. The first value specified the mean value of the distribution. The second value specifies the standard deviation of the distribution; this defaults to 1.
  • Syntax: NORMAL (Random values), a list of floating point values. Either one or two values.
    • Example: NORMAL (4 20)

Curve distribution random range

  • This takes the string "CURVE", followed by a string matching the name of a curve from Curves.tbl (or one of the built-in curves), optionally followed by two values. This random range generates values by using the curve as a probability density function. Curves which have a height of zero along the Y axis, or which dip below zero along the Y axis, are not allowed. If min and max values are provided, the generated values will be remapped into the range specified. Otherwise, the range of values generated will be determined by the smallest and largest X values of the curve's keyframes.
  • Note that while distributions based on curves with only two keyframes are quite cheap, curves with many keyframes can be significantly costly.
  • Syntax: CURVE curve_name (Random values), type string followed by curve name followed optionally by a list of floating point values. A single value will not do anything; you must specify neither or both.
    • Example: CURVE CurvePolyDown2.0 (0 25)