Category: Objects
/ Status
Since engine version: 1.0 OC
GetKiller
Description
Returns the player who has lastly caused energy loss to an object.
Syntax
int GetKiller();
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 GetController for details). The controller is used to determine the player responsible for energy loss on a Clonk:
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.
- For object hits: The controlling player of the thrown object. The controller will automatically be set upon collection.
- For fire: The controller of the original fire causing player, i.e. the calling object of the original call to Incinerate(). 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.
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.
Example
protected func Death() { var killer = GetKiller(); if (killer == GetController()) Message("%s killed himself, hah!", GetName()); else if (killer != NO_OWNER) Message("%s was killed by %s!", GetName(), GetPlayerName(killer)); else DeathAnnounce(); return true; }
Script for the death of a Clonk: Customized death messages which show the murderer are shown.