ACE3/addons/common/functions/fnc_getTurrets.sqf

61 lines
1.2 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
2015-09-20 21:40:51 +00:00
* Get all turret indicies of a vehicle type.
*
2015-09-20 21:40:51 +00:00
* Arguments:
* 0: Vehicle type <STRING>
*
2015-09-20 21:40:51 +00:00
* Return Value:
* Turret Indecies <ARRAY>
*
2015-09-20 21:40:51 +00:00
* Public: Yes
*
* Note: It's advised to use allTurrets [_vehicle, true] instead whenever possible
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-09-20 21:40:51 +00:00
params ["_type"];
2015-09-20 21:40:51 +00:00
private ["_varName", "_turrets"];
2015-09-20 21:40:51 +00:00
_varName = format [QGVAR(CachedTurrets_%1), _type];
_turrets = + (uiNamespace getVariable _varName);
if (!isNil "_turrets") exitWith {_turrets};
2015-09-20 21:40:51 +00:00
private ["_config", "_fnc_addTurret"];
_config = configFile >> "CfgVehicles" >> _type;
_turrets = [];
2015-09-20 21:40:51 +00:00
_fnc_addTurret = {
params ["_config", "_path"];
2015-05-14 18:06:06 +00:00
_config = _config >> "Turrets";
2015-09-20 21:40:51 +00:00
private ["_count", "_offset", "_path2", "_config2"];
2015-05-14 18:06:06 +00:00
_count = count _config;
2015-05-14 18:06:06 +00:00
_offset = 0;
2015-09-20 21:40:51 +00:00
2015-05-14 18:06:06 +00:00
for "_index" from 0 to (_count - 1) do {
_path2 = _path + [_index - _offset];
_config2 = _config select _index;
2015-05-14 18:06:06 +00:00
if (isClass _config2) then {
_turrets pushBack _path2;
[_config2, _path2] call _fnc_addTurret;
} else {
_offset = _offset + 1;
};
};
};
[_config, []] call _fnc_addTurret;
uiNamespace setVariable [_varName, _turrets];
_turrets