player.get_vehicle
a.k.a. player.try_get_vehicleWhen 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
As mentioned in the description, this function also works for checking if a player is hijacking or boarding a vehicle. Vehicles can have multiple seats defined for them in the game data, and boarding relies on special "seats" that are flagged as being exclusively for boarding.
The alternate name for this function,
try_get_vehicle
, is deprecated and originates from the oldest versions of ReachVariantTool. In older versions, the two names existed as part of a precaution that reverse-engineering has established was not actually necessary.