GetKiller

Category: Objects / Status
Since engine version: 4.9.6.0 CR

Description

Returns the player who has lastly caused energy loss to an object.

Syntax

int GetKiller (object pObj);

Parameter

pObj:
[opt] Object to be checked. Can be 0 in local calls.

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:
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").
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 iKiller = GetKiller();
	if (iKiller == GetController()) Message("%s hat sich selbst umgebracht.", this(), GetName());
	else if (iKiller > NO_OWNER) Message("%s wurde von %s geplättet!", this(), GetName(), GetPlayerName(iKiller));
	else DeathAnnounce();
	return(true);
}
Script for the death of a Clonk: Customized death messages which show the murderer are shown.
See also: DoEnergy, GetController, GetOwner, SetController, SetKiller
Sven2, April 2007