openclonk/docs/sdk/script/fn/Random.xml

35 lines
1.0 KiB
XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>Random</title>
<category>Arithmetics</category>
<version>5.1 OC</version>
<syntax>
<rtype>int</rtype>
<params>
<param>
<type>int</type>
<name>max</name>
<desc>Maximum value. Must be zero or greater. The bevaviour for negative values is undefined.</desc>
</param>
</params>
</syntax>
<desc>Yields a random number from 0 to max-1.</desc>
<examples>
<example>
<code>protected func Hit()
{
<funclink>if</funclink>(!Random(60)) <funclink>Explode</funclink>(Random(10)+1);
}
</code>
<text>Explodes the object with a probability of 1:60. The explosion radius is a random value from 1 to 10.</text>
</example>
</examples>
<related><funclink>RandomX</funclink></related>
</func>
<author>jwk</author><date>2002-06</date>
</funcs>