From 5d43fa93c6a3bacefe2b0a247b1e37f04d8bcca5 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 4 Dec 2015 19:37:37 +0100 Subject: [PATCH] fix FUNC(binocularMagazine), fix #2916, fix #2917, fix #2918, fix #2922, fix #2928, fix #2933 --- .../functions/fnc_binocularMagazine.sqf | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/addons/common/functions/fnc_binocularMagazine.sqf b/addons/common/functions/fnc_binocularMagazine.sqf index f097b90841..b5f4f0558e 100644 --- a/addons/common/functions/fnc_binocularMagazine.sqf +++ b/addons/common/functions/fnc_binocularMagazine.sqf @@ -9,32 +9,24 @@ * Magazine of the units binocular * * Example: - * [player] call ace_common_fnc_binocularMagazine + * player call ace_common_fnc_binocularMagazine * * Public: Yes - * - * Note: Doesn't work on dead units */ #include "script_component.hpp" -params ["_unit"]; +params [["_unit", objNull, [objNull]]]; -private ["_binocular", "_muzzle", "_mode", "_magazine"]; +private _binocular = binocular _unit; -_binocular = binocular _unit; +scopeName "main"; -if (_binocular == "") exitWith {""}; +{ + if ((_x select 0) isEqualTo _binocular) then { + // note: if there is no magazine, _x(4,0) will be nil, which skips the breakOut. + (_x select 4 select 0) breakOut "main"; + }; + false +} count weaponsitems _unit; -_muzzle = currentMuzzle _unit; -_mode = currentWeaponMode _unit; - -_unit selectWeapon _binocular; - -// didn't select the binocular (unit probably dead or not local). function won't work. quit with empty string -if (currentWeapon _unit != _binocular) exitWith {""}; - -_magazine = currentMagazine _unit; - -[_unit, _muzzle, _mode] call FUNC(selectWeaponMode); - -_magazine +""