ACE3/addons/arsenal/functions/fnc_removeVirtualItems.sqf
Josuan Albin 0acbde1489 Various ACE Arsenal fixes (see description) (#5996)
* Copy the array properly when using preStart cache in openBox

* Fix add and removeVirtualItems erroring out when passing false as arg

* Disable face, voice, and insignia tabs in 3DEN

* Move grenadeList and putList outside of foreach in scanConfig

* Fix grenadeList and putList indentation

* Change the camera handling in onArsenalClose

Fixes the camera not being focused on the player after using ACE Arsenal on an other unit outside of zeus / 3DEN.
Remove the code that moved the curatorCam near the edited unit after ACE Arsenal is closed.

* Fix message control overflowing, move width defines to defines.hpp

* Add ability to exit arsenal and not apply a loadout in 3DEN

* Add ACE3 logo to common, fix config pathing to a non existing file
2018-01-05 18:56:21 +01:00

83 lines
2.4 KiB
Plaintext

/*
* Author: Alganthe
* Remove virtual items to the provided target.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Items <ARRAY of strings> <BOOL>
* 2: Add globally <BOOL>
*
* Return Value:
* None
*
* Example:
* [_box, ["item1", "item2", "itemN"]] call ace_arsenal_fnc_removeVirtualItems
* [_box, true, false] call ace_arsenal_fnc_removeVirtualItems
*
* Public: Yes
*/
#include "script_component.hpp"
params [ ["_object", objNull, [objNull]], ["_items", [], [true, [""]]], ["_global", false, [false]] ];
if (_object == objNull) exitWith {};
if (_items isEqualType [] && {count _items == 0}) exitWith {};
private _cargo = _object getVariable [QGVAR(virtualItems), [
[[], [], []], // Weapons 0, primary, handgun, secondary
[[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod
[ ], // Magazines 2
[ ], // Headgear 3
[ ], // Uniform 4
[ ], // Vest 5
[ ], // Backpacks 6
[ ], // Goggles 7
[ ], // NVGs 8
[ ], // Binoculars 9
[ ], // Map 10
[ ], // Compass 11
[ ], // Radio slot 12
[ ], // Watch slot 13
[ ], // Comms slot 14
[ ], // WeaponThrow 15
[ ], // WeaponPut 16
[ ] // InventoryItems 17
]];
if (_items isEqualType true) then {
if (_items) then {
[_object, _global] call FUNC(removeBox);
_object setVariable [QGVAR(virtualItems), nil, _global];
};
} else {
// Make sure all items are in string form
_items = _items select {_x isEqualType "" && {_x != ""}};
{
if (_forEachIndex isEqualTo 0) then {
_cargo set [_forEachIndex, [(_x select 0) - _items, (_x select 1) - _items, (_x select 2) - _items]];
} else {
if (_forEachIndex isEqualTo 1) then {
_cargo set [_forEachIndex, [(_x select 0) - _items, (_x select 1) - _items, (_x select 2) - _items, (_x select 3) - _items]];
} else {
_cargo set [_cargo find _x, _x - _items];
};
};
} foreach _cargo;
private _itemCount = {
if (_x isEqualTo (_cargo select 0) || {_x isEqualTo (_cargo select 1)}) then {
!(_x isEqualTo [[],[],[]] || {_x isEqualTo [[],[],[],[]]})
} else {
!(_x isEqualTo [])
};
} count _cargo;
if (_itemCount == 0) then {
[_object, _global] call FUNC(removeBox);
} else {
_object setVariable [QGVAR(virtualItems), _cargo, _global];
};
};