ACE3/addons/gunbag/functions/fnc_toGunbag.sqf

52 lines
1.3 KiB
Plaintext
Raw Normal View History

2016-05-03 08:21:21 +00:00
/*
* Author: Ir0n1E
* put weapon into gunbag
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Nothing
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_target"];
private ["_weapon", "_magazine", "_magazine_gl", "_items", "_gunbag", "_state", "_mass"];
2016-05-03 08:21:21 +00:00
_gunbag = backpackContainer _target;
_state = [_unit, primaryWeapon _unit] call EFUNC(common,getWeaponState);
/*
* example returnvalue _state
* [["","","optic_Aco",""],["arifle_MX_GL_ACO_F","GL_3GL_F"],["30Rnd_65x39_caseless_mag","1Rnd_HE_Grenade_shell"],[30,1]]
2016-05-03 08:21:21 +00:00
*/
_weapon = (_state select 1) select 0;
_magazine = [(_state select 2) select 0, (_state select 3) select 0];
_magazine_gl = [(_state select 2) select 1, (_state select 3) select 1];
_items = _state select 0;
2016-05-03 08:21:21 +00:00
if ((_magazine_gl select 0) != "") then {
_unit addMagazine _magazine_gl;
};
2016-05-03 08:21:21 +00:00
if ((_magazine select 0) != "") then {
2016-05-17 09:21:48 +00:00
_unit addMagazine _magazine;
2016-05-03 08:21:21 +00:00
};
_unit removeWeapon _weapon;
// add virtual load
2016-05-04 07:56:33 +00:00
[_target, backpackContainer _target, [_weapon, _items] call FUNC(calculateMass)] call EFUNC(movement,addLoadToUnitContainer);
_gunbag setVariable [QGVAR(GunbagWeapon), [[_weapon], _items], true];
2016-05-04 18:06:56 +00:00
// play sound
2016-05-04 18:06:56 +00:00
if(["ACE_Backpacks"] call EFUNC(common,isModLoaded)) then {
2016-05-17 09:21:48 +00:00
[_unit, _target, backpackContainer _target] call EFUNC(backpacks,backpackOpened);
2016-05-04 18:06:56 +00:00
};