player.try_get_death_damage_type

a.k.a. player.get_death_damage_type

When called on a player who is dead, this function returns a number representing their cause of death. This number can represent any cause of death that can be listed in a Post-Game Carnage Report, including weapons and vehicles. The potential values are listed and named in the damage reporting type enum.

When Bungie and 343i use this function, they often manually clear the number variable they are assigning to before calling the function. That functionality is automated in this Megalo dialect: calling the function with the name get_death_damage_type will compile in an assignment to 0 before the call, while calling the function with the name try_get_death_damage_type will not.

This function returns number. Calling this function without storing its return value in a variable is an error.

Example

--
-- Award points for killing any other player (including allies) with a DMR.
--
for each player do
   if current_player.killer_type_is(guardians | suicide | kill | betrayal | quit) then
      --
      -- The player is dead.
      --
      global.number[0] = current_player.get_death_damage_type()
      if global.number[0] == enums.damage_reporting_type.dmr then
         global.player[0] = current_player.get_killer()
         global.player[0].score += 1
      end
   end
end

See also