diff --git a/addons/reload/functions/fnc_canCheckAmmo.sqf b/addons/reload/functions/fnc_canCheckAmmo.sqf index 95ac2582a2..8fbb37c726 100644 --- a/addons/reload/functions/fnc_canCheckAmmo.sqf +++ b/addons/reload/functions/fnc_canCheckAmmo.sqf @@ -3,7 +3,7 @@ * Check if the player can check the ammo of the target. * * Argument: - * 0: Player + * 0: Unit * 1: Target * * Return value: @@ -16,22 +16,24 @@ */ #include "script_component.hpp" -EXPLODE_2_PVT(_this,_player,_target); - -private ["_magazineType", "_magazineCfg"]; +params ["", "_target"]; // Return true for static weapons if they have been fired once, @todo 1.40 this work-around doesn't work anymore if (_target isKindOf "StaticWeapon") exitWith { if (currentMagazine _target != "") exitWith {true}; - private ["_magazines","_found"]; - _magazines = magazinesAmmoFull _target; - _found = false; + // no check ammo action on destroyed static weapons + if (!alive _target) exitWith {false}; + + local _found = false; + { if (_x select 2) exitWith { _found = true; }; - } forEach _magazines; + false + } count magazinesAmmoFull _target; + _found }; @@ -42,9 +44,7 @@ if !(_target isKindOf "CAManBase") exitWith {false}; if (currentWeapon _target == "") exitWith {false}; // Check if their current magazine is a belt -_magazineType = currentMagazine _target; -_magazineCfg = configFile >> "CfgMagazines" >> _magazineType; -if (getNumber (_magazineCfg >> "ACE_isBelt") == 1) exitWith {true}; +if (getNumber (configFile >> "CfgMagazines" >> currentMagazine _target >> "ACE_isBelt") == 1) exitWith {true}; // Check for rocket launchers if (currentWeapon _target == secondaryWeapon _target) exitWith {true};