ACE3/addons/common/functions/fnc_getTurretIndex.sqf

37 lines
567 B
Plaintext
Raw Normal View History

/*
* Author: commy2
* Get the turret index of a units current turret.
*
2015-09-20 21:40:51 +00:00
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Turret Index <ARRAY>
*
2015-09-20 21:40:51 +00:00
* Public: Yes
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-09-20 21:40:51 +00:00
params ["_unit"];
2015-05-14 18:06:06 +00:00
private ["_vehicle", "_turrets", "_units", "_index"];
_vehicle = vehicle _unit;
2015-01-16 20:16:42 +00:00
if (_unit == _vehicle) exitWith {[]};
_turrets = allTurrets [_vehicle, true];
_units = [];
2015-09-20 21:40:51 +00:00
{
2015-09-20 21:40:51 +00:00
_units pushBack (_vehicle turretUnit _x);
false
} count _turrets;
_index = _units find _unit;
if (_index == -1) exitWith {[]};
_turrets select _index;