ACE3/addons/cargo/functions/fnc_findNearestVehicle.sqf

36 lines
978 B
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Get nearest vehicle from unit, priority: Car-Air-Tank-Ship.
2015-08-10 21:07:47 +00:00
*
* Arguments:
2015-08-16 20:41:35 +00:00
* 0: Unit <OBJECT>
2015-08-10 21:07:47 +00:00
*
* Return value:
2015-08-16 20:41:35 +00:00
* Vehicle in Distance <OBJECT>
*
* Example:
* [unit] call ace_cargo_fnc_findNearestVehicle
2015-08-10 21:07:47 +00:00
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
2016-01-19 03:53:48 +00:00
private _loadCar = nearestObject [_unit, "car"];
2015-08-16 20:41:35 +00:00
if (_unit distance _loadCar <= MAX_LOAD_DISTANCE) exitWith {_loadCar};
2015-08-10 21:07:47 +00:00
2016-01-19 03:53:48 +00:00
private _loadHelicopter = nearestObject [_unit, "air"];
2015-08-16 20:41:35 +00:00
if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitWith {_loadHelicopter};
2015-08-10 21:07:47 +00:00
2016-01-19 03:53:48 +00:00
private _loadTank = nearestObject [_unit, "tank"];
2015-08-16 20:41:35 +00:00
if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitWith {_loadTank};
2015-08-10 21:07:47 +00:00
2016-01-19 03:53:48 +00:00
private _loadShip = nearestObject [_unit, "ship"];
2015-08-16 20:41:35 +00:00
if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitWith {_loadShip};
2015-08-10 21:07:47 +00:00
2016-01-19 03:53:48 +00:00
private _loadContainer = nearestObject [_unit,"Cargo_base_F"];
2015-08-16 20:41:35 +00:00
if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitWith {_loadContainer};
2015-08-14 20:01:14 +00:00
objNull