<?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>GetKiller</title>
    <category>Objects</category>
    <subcat>Status</subcat>
    <version>5.1 OC</version>
    <syntax><rtype>int</rtype></syntax>
    <desc>Returns the player who has lastly caused energy loss to an object.</desc>
    <remark>
      Because of the complexity of Clonk, it may not always be possible to determine the actual killer of a Clonk in chain reactions. In order to determine energy losses, every object stores a controller (see <funclink>GetController</funclink> for details). The controller is used to determine the player responsible for energy loss on a Clonk:<br/>
      <ul>
        <li>For object hits: The controlling player of the thrown object. The controller will automatically be set upon collection.</li>
        <li>For fire: The controller of the original fire causing player, i.e. the calling object of the original call to <funclink>Incinerate</funclink>(). The causing player is kept independently of owners and controllers of the burning object in incineration chains. If, for example, player A incinerates a Clonk of player B and player B uses his burning Clonk to incinerate a Clonk of player C, both incinerations are marked as caused by player A.</li>
      </ul>
 The energy loss causing player is automatically reset to NO_OWNER (no player), whenever the Clonk executes an action that does not have ObjectDisabled=1 set (e.g. "Walk").<br/> Energy loss caused by the controller of the Clonk itself only sets the field if it was NO_OWNER before. This prevents players from committing suicide in order to deny scores from other players. Consequently, if a Clonk is hit by a rock and falls out of the bottom of the map, the killer is the player who threw the rock.
    </remark>
    <examples>
      <example>
        <code>protected func Death()
{
	var killer = GetKiller();
	if (killer == <funclink>GetController</funclink>()) <funclink>Message</funclink>(&quot;%s killed himself, hah!&quot;, <funclink>GetName</funclink>());
	else if (killer != NO_OWNER) <funclink>Message</funclink>(&quot;%s was killed by %s!&quot;, <funclink>GetName</funclink>(), <funclink>GetPlayerName</funclink>(killer));
	else <funclink>DeathAnnounce</funclink>();
	<funclink>return</funclink> true;
}</code>
        <text>Script for the death of a Clonk: Customized death messages which show the murderer are shown.</text>
      </example>
    </examples>
    <related>
	  <funclink>SetKiller</funclink>
      <funclink>GetController</funclink>
      <funclink>GetOwner</funclink>
      <funclink>SetController</funclink>
      <funclink>DoEnergy</funclink>
    </related>
  </func>
  <author>Sven2</author><date>2007-04</date>
</funcs>
