ACE3/addons/disarming/functions/fnc_getAllGearUnit.sqf

54 lines
1.3 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
* Author: PabstMirror
2015-08-09 03:18:26 +00:00
*
* Helper function to get all gear of a unit.
*
* Arguments:
* 0: Target <OBJECT>
*
* Return Value:
* Array of 2 arrays, classnames and count<ARRAY>
*
* Example:
* [["ace_bandage"],[2]] = [bob] call ace_disarming_fnc_getAllGearUnit
*
* Public: No
*/
2015-02-23 00:44:33 +00:00
2015-08-09 03:18:26 +00:00
params ["_target"];
2015-02-23 00:44:33 +00:00
private _allItems = (((items _target) + (assignedItems _target)) - (weapons _target)) + (weapons _target) + (magazines _target);
2015-02-23 00:44:33 +00:00
if ((backpack _target) != "") then {
_allItems pushBack (backpack _target);
};
if ((vest _target) != "") then {
_allItems pushBack (vest _target);
};
if ((uniform _target) != "") then {
_allItems pushBack (uniform _target);
};
if ((headgear _target) != "") then {
_allItems pushBack (headgear _target);
};
2015-02-27 21:23:46 +00:00
//What kind of asshole takes a man's glasses?
if ((goggles _target) != "") then {
_allItems pushBack (goggles _target);
};
2015-02-23 00:44:33 +00:00
private _uniqueClassnames = [];
private _classnamesCount = [];
2015-02-23 00:44:33 +00:00
//Filter unique and count
{
private _index = _uniqueClassnames find _x;
2015-02-23 00:44:33 +00:00
if (_index != -1) then {
_classnamesCount set [_index, ((_classnamesCount select _index) + 1)];
} else {
_uniqueClassnames pushBack _x;
_classnamesCount pushBack 1;
};
2015-08-15 01:13:41 +00:00
} forEach _allItems;
2015-02-23 00:44:33 +00:00
[_uniqueClassnames, _classnamesCount]