SEED - Falloff function

From The DarkMod Wiki
Revision as of 18:22, 14 July 2010 by Tels (talk | contribs) (stub out)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
Note: This is a design document and not actually implemented or available yet!

Introduction

The new LODE system can generate entities in random patterns, and the distribution is controlled by the spawnarg falloff. The normal values ("none", "cutoff", "square" and "exp") 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.

Parameters

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

p = 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)
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, 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 always 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, with probability incr. along the axes

This is also the default shape if you use func:

 "func_x" "1"
 "func_y" "1"
 "func_s" "0.5"
 "func_a" "0"

The resulting formula will be:

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

or simplified:

p = 0.5 * (X + Y)

See also