Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common - Fix adding unusable throwables #9980

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions addons/common/functions/fnc_addToInventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down