From 4f1c2fa8d7a98c2a8d2d8612edb8152a3b973c5f Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:13:47 +0200 Subject: [PATCH] Common - Fix adding unusable throwables (#9980) * Prevent adding unusable grenades * Update fnc_addToInventory.sqf * Update addons/common/functions/fnc_addToInventory.sqf Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Update fnc_addToInventory.sqf --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- .../common/functions/fnc_addToInventory.sqf | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/addons/common/functions/fnc_addToInventory.sqf b/addons/common/functions/fnc_addToInventory.sqf index 9902abe82b..38476ad5fc 100644 --- a/addons/common/functions/fnc_addToInventory.sqf +++ b/addons/common/functions/fnc_addToInventory.sqf @@ -59,6 +59,21 @@ switch (_container) do { }; }; +if (_type select 0 == "magazine") then { + private _configAmmoCount = getNumber (configFile >> "CfgMagazines" >> _classname >> "count"); + + // https://feedback.bistudio.com/T74244 + // When adding throwables with the addXXXCargo(Global) commands, they don't show up in the throwables list + // If a throwable has more than 1 ammo count, adding it with addItem(XXX) commands also renders the throwable unusable + if (_configAmmoCount == 1 && {_ammoCount in [-1, 1]} && {_classname call BIS_fnc_isThrowable}) then { // TODO: replace with https://community.bistudio.com/wiki/isThrowable in 2.18 + _type set [0, "item"]; + }; + + if (_ammoCount == -1) then { + _ammoCount = _configAmmoCount; + }; +}; + switch (_type select 0) do { case "weapon": { if (_canAdd || {_canFitWeaponSlot}) then { @@ -106,10 +121,6 @@ switch (_type select 0) do { }; case "magazine": { - if (_ammoCount == -1) then { - _ammoCount = getNumber (configFile >> "CfgMagazines" >> _classname >> "count"); - }; - if (_canAdd) then { _addedToUnit = true;