ACE3/addons/gunbag/functions/fnc_toGunbagCallback.sqf

43 lines
976 B
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2016-06-12 11:51:23 +00:00
/*
* Author: Ir0n1E
* Put weapon into gunbag.
2016-06-12 11:51:23 +00:00
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_gunbag_fnc_toGunbagCallback
2016-06-12 11:51:23 +00:00
*
* Public: No
*/
params ["_unit", "_target"];
// Set up current weapon for storing
2016-06-12 11:51:23 +00:00
private _gunbag = backpackContainer _target;
private _items = (getUnitLoadout _unit) select 0;
2016-06-12 11:51:23 +00:00
private _magazines = _items select [4, 2];
_items deleteRange [4, 2];
2016-06-12 11:51:23 +00:00
private _weapon = _items deleteAt 0;
2016-06-12 11:51:23 +00:00
private _mass = [_weapon, _items, _magazines apply {_x select 0}] call FUNC(calculateMass);
2016-06-12 11:51:23 +00:00
_unit removeWeapon _weapon;
// Add virtual load
2016-06-12 11:51:23 +00:00
[_target, _gunbag, _mass] call EFUNC(movement,addLoadToUnitContainer);
2016-06-12 11:51:23 +00:00
_gunbag setVariable [QGVAR(gunbagWeapon), [_weapon, _items, _magazines], true];
// Play sound
if (["ace_backpacks"] call EFUNC(common,isModLoaded)) then {
2016-06-12 11:51:23 +00:00
[_target, _gunbag] call EFUNC(backpacks,backpackOpened);
};