player.try_get_killer
a.k.a. player.get_killerWhen called on a player on the exact frame that that player died, this function returns the identity of their killer, if any. If the player died by their own hand, then they themselves are the return value.
When called on any other frame, even while the player is dead, this function does not return a value:
-
If you call
get_killer
, ReachVariantTool will silently compile in an assignment to no_player before the call. (Bungie and 343i do the same thing by hand.) This ensures that if you call the function at the wrong time, the variable you assign its return value to will be set to no_player. -
If you call
try_get_killer
, then ReachVariantTool does not compile in this failsafe. If you calltry_get_killer
at the wrong time, then the function will not return a value: the variable that you attempt to assign it to will remain unchanged.
This function returns player. Calling this function without storing its return value in a variable is an error.
Example
for each player do if current_player.killer_type_is(guardians | suicide | kill | betrayal | quit) then -- -- The player is dead. -- global.player[0] = current_player.get_killer() global.player[0].score += 1 end end