GetKiller

Category: Objects / Status
Since engine version: 1.0 OC

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:
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 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.
See also: DoEnergy, GetController, GetOwner, SetController, SetKiller
Sven2, 2007-04