SEED - Falloff function

From The DarkMod Wiki
Jump to navigationJump to search

Introduction

The new SEED system can generate entities in random patterns, and the distribution is controlled by the spawnarg falloff. The normal values ("none", "cutoff", "square" and "power") only generate entities in symmetrical patterns all over the place, but creating f.i. a triangle shaped distribution is not possible with them.

This article describes how to use the variant func to achieve such effects.

Note: It is also possible to use image maps in place of a falloff function. See SEED - Spawnargs for details.

Parameters

When setting falloff to func, the probability that an entity will spawn is computed from a function given here:

p = f( min, max, s * (Xt * x + Yt * y + a) )

whereas:

Name Description
p resulting probability, clamped to the range 0 (no entity) and 1.0 (entity always appears)
f Restricting function. Either "clamp" (default) (values < min are set to min, values > max to max), or "zeroclamp" (values < min and > max are set to 0.0f)
min 0 .. 1.0. Minimum value for p, values lower than that get restricted (see "f").
max 0 .. 1.0. Maximum value for p, values greater than that get restricted (see "f").
s Scaling factor (default 0.5)
x Scaling factor for the X-coordinate (default 1.0)
y Scaling factor for the Y-coordinate (default 1.0)
a Additive factor (default 0.0)
Xt X coordinate, (default "X", running from 0 .. 1.0, automatically set)
Yt Y coordinate, (default "y", running from 0 .. 1.0, automatically set)

The parameters are set with the spawnargs having as prefix func_, so s is set with func_s.

Values

Possible values are for all parameters are given above, or otherwise are constant floating point numbers (like "0.5", "-1.0", "-2" etc).

For Xt and Yt, the following values are possible (replace "X" with "Y" for y-axis):

whereas:

Value Description
X the relative coordinate (0..1.0)
X*X the relative coordinate (0..1.0), multiplied with itself


Note:
Make sure that the result of the function (p) is in the range 0 .. 1.0. Values < 0 or greater than 1.0 will simply clamped to the range 0 .. 1.0. To ensure this, set func_s accordingly.

Values that result in a range of f.i. 0.2 .. 0.8 do work, though. This can f.i. be used to spawn less entities of one type than of another.

Examples

A ramp along the X axis

 "func_x" "1"
 "func_y" "0"
 "func_s" "1"
 "func_a" "0"
 "func_Xt" "X"

The resulting formula will be:

p = 1 * (X * 1 + Y * 0 + 0)

or simplified:

p = X

That means the probability only depends on the X-axis, and not on the Y-axis. Here is how it looks in game:

A ramp, squared along the Y axis

 "func_x" "0"
 "func_y" "1"
 "func_s" "1"
 "func_a" "0"
 "func_Yt" "Y*Y"

The resulting formula will be:

p = 1 * (X * 0 + Y * Y * 1 + 0)

or simplified:

p = Y * Y

That means the probability only depends on the Y-axis, and not on the Y-axis. Here is how it looks in game:

A triangle

 "func_x" "1"
 "func_y" "1"
 "func_s" "0.5"
 "func_a" "0"
 "func_min" "0.5"
 "func_max" "1.0"
 "func_f" "zeroclamp"

The resulting formula will be:

p = Zeroclamp( 0.5, 1.0, 0.5 * (X * 1 + Y * 1 + 0) )

or simplified:

p = Zeroclamp( 0.5, 1.0, 0.5 * (X + Y) )