player.get_vehicle

a.k.a. player.try_get_vehicle

When called on a player, this function returns the vehicle that the player is occupying or boarding.

When Bungie and 343i use this function, they often manually clear the object variable they are assigning to before calling the function. However, reverse-engineering of the game engine suggests that this is not actually necessary; the game will always properly return a value when this function is called.

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

Example

--
-- Award points for killing an enemy using a sniper rifle while riding in a revenant.
--
for each player do
   alias killer  = global.player[0]
   alias vehicle = global.object[0]
   if current_player.killer_type_is(kill) then
      --
      -- The player is dead.
      --
      global.number[0] = current_player.get_death_damage_type()
      if global.number[0] == enums.damage_reporting_type.sniper_rifle then
         killer  = current_player.get_killer()
         vehicle = killer.get_vehicle()
         if vehicle.is_of_type(revenant) then
            killer.score += 1
         end
      end
   end
end

Notes

See also