ACE3/addons/common/functions/fnc_useItem.sqf
mharis001 803d497d8a Improve checking of unit items (#6350)
* Add uniqueItems function

* Optimize dogtag children actions function

* Optimize getDetonators item search

* Store CfgWeapons lookup in getDetonators

* Update items to use new function

* Update items to use new function 2

* More optimization of uniqueItems function

* Update items to use new function 3
2018-09-17 14:03:28 -05:00

40 lines
791 B
Plaintext

/*
* Author: Glowbal
* Use item
*
* Arguments:
* 0: unit <OBJECT>
* 1: item <STRING>
*
* Return Value:
* if item has been used. <BOOL>
*
* Example:
* [bob, "gun"] call ace_common_fnc_useItem
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit", "_item", ["_vehicleUsage", false]];
private _return = false;
if !(_vehicleUsage) then {
if (_item != "") then {
if (_item in (_unit call EFUNC(common,uniqueItems))) then {
_unit removeItem _item;
_return = true;
} else {
if (_item in assignedItems _unit) then {
_unit unlinkItem _item;
_return = true;
};
};
};
//} else {
// @todo implement shared item functionality for with vehicles.
};
_return