diff --git a/addons/common/functions/fnc_getWeaponMuzzles.sqf b/addons/common/functions/fnc_getWeaponMuzzles.sqf index d75a01f2e3..e252d879f9 100644 --- a/addons/common/functions/fnc_getWeaponMuzzles.sqf +++ b/addons/common/functions/fnc_getWeaponMuzzles.sqf @@ -18,7 +18,7 @@ private _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles") { if (_x == "this") then { - _muzzles set [_forEachIndex, _weapon]; + _muzzles set [_forEachIndex, configName (configFile >> "CfgWeapons" >> _weapon)]; }; } forEach _muzzles; diff --git a/addons/common/functions/fnc_getWeaponState.sqf b/addons/common/functions/fnc_getWeaponState.sqf index e7b7bb80ec..73e5897236 100644 --- a/addons/common/functions/fnc_getWeaponState.sqf +++ b/addons/common/functions/fnc_getWeaponState.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: unit - * 1: weapon + * 1: weapon (optional, default: units current weapon) * * Return Value: * 0: Attachements @@ -16,21 +16,19 @@ */ #include "script_component.hpp" -params ["_unit", "_weapon"]; +params [["_unit", objNull, [objNull]], ["_weapon", nil, [""]]]; + +if (isNil "_weapon") then { + _weapon = currentWeapon _unit; +}; + +private _attachments = [_unit weaponAccessories _weapon] param [0, ["","","",""]]; private _muzzles = _weapon call FUNC(getWeaponMuzzles); -private _weaponInfo = [["","","",""], primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit] select ((["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] find _weapon) max 0); - // get loaded magazines and ammo -private _magazines = []; -private _ammo = []; - -{ - _magazines pushBack ""; - _ammo pushBack 0; - false -} count _muzzles; +private _magazines = _muzzles apply {""}; +private _ammo = _muzzles apply {0}; { if (_x select 2) then { @@ -44,6 +42,4 @@ private _ammo = []; false } count magazinesAmmoFull _unit; -_weaponInfo append [_muzzles, _magazines, _ammo]; - -_weaponInfo +[_attachments, _muzzles, _magazines, _ammo];