<?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>SimFlight</title>
    <category>Objects</category>
    <subcat>Movement</subcat>
    <version>5.1 OC</version>
    <syntax>
      <rtype>array</rtype>
      <params>
        <param>
          <type>int</type>
          <name>x</name>
          <desc>X offset of the starting position. (NOT optional if used in <code>nil</code> object context)</desc>
		  <optional />
        </param>
        <param>
          <type>int</type>
          <name>y</name>
          <desc>Y offset of the starting position. (NOT optional if used in <code>nil</code> object context)</desc>
		  <optional />
        </param>
        <param>
          <type>int</type>
          <name>xdir</name>
          <desc>Initial horizontal speed. If not specified this will default to the object's horizontal speed. (NOT optional if used in <code>nil</code> object context)</desc>
		  <optional />
        </param>
        <param>
          <type>int</type>
          <name>ydir</name>
          <desc>Initial vertical speed. If not specified this will default to the object's vertical speed. (NOT optional if used in <code>nil</code> object context)</desc>
		  <optional />
        </param>
        <param>
          <type>int</type>
          <name>min_density</name>
          <desc>Minimum density of the material which will stop the projected trajectory. If not specified this will default to value 50 (solid material).</desc>
          <optional />
        </param>
        <param>
          <type>int</type>
          <name>max_density</name>
          <desc>Maximum density of the material which will stop the projected trajectory. If not specified this will default to value 100.</desc>
          <optional />
        </param>
        <param>
          <type>int</type>
          <name>iterations</name>
          <desc>Number of simulated frames for which the projection runs. If not specified or nonpositive the simulation will run indefinitely until material or the limits of the landscape are encountered.</desc>
          <optional />
        </param>
        <param>
          <type>int</type>
          <name>precision</name>
          <desc>Precision of the velocity input and output parameters (<code>xdir</code>, <code>ydir</code>, <code>xdir_final</code> and <code>ydir_final</code>). Defaults to 10 if not specified.</desc>
          <optional />
        </param>
      </params>
    </syntax>
    <desc>Simulates the motion of a falling object with a given starting position and initial speed. The returned array will contain [int x_final, int y_final, int xdir_final, int ydir_final, int time_passed]. <br/> If the projected trajectory encounters a material of the specified density, the simulation will stop and time_passed will be non-negative. Otherwise, time_passed will be negative.</desc>
    <examples>
      <example>
        <code>if (<funclink>GetAction</funclink>() == &quot;Jump&quot;)
{
	var end = SimFlight()
	if (end[3] &gt;= 80)
		<funclink>Message</funclink>(&quot;Oh oh, this will be a rough impact!&quot;);
}</code>
        <text>If the calling clonk is situated in mid-air and it appears that he will hit the ground at high speed, he will call out.</text>
      </example>
    </examples>
  </func>
  <author>Newton</author><date>2004-03</date>
  <author>Peewee</author><date>2010-10</date>
</funcs>
