mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Replace canAdd with CBA_fnc_canAddItem (#8012)
This commit is contained in:
parent
d55529041a
commit
b151148542
@ -46,7 +46,7 @@ if (isNull _attachedObject || {_itemName == ""}) exitWith {ERROR("Could not find
|
|||||||
private _isChemlight = _attachedObject isKindOf "Chemlight_base";
|
private _isChemlight = _attachedObject isKindOf "Chemlight_base";
|
||||||
|
|
||||||
// Exit if can't add the item
|
// Exit if can't add the item
|
||||||
if (!(_unit canAdd _itemName) && {!_isChemlight}) exitWith {
|
if (!([_unit, _itemName] call CBA_fnc_canAddItem) && {!_isChemlight}) exitWith {
|
||||||
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
|
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,16 +28,16 @@ private _addedToUnit = false;
|
|||||||
|
|
||||||
switch (_container) do {
|
switch (_container) do {
|
||||||
case "vest": {
|
case "vest": {
|
||||||
_canAdd = _unit canAddItemToVest _classname;
|
_canAdd = [_unit, _classname, 1, false, true, false] call CBA_fnc_canAddItem;
|
||||||
};
|
};
|
||||||
case "backpack": {
|
case "backpack": {
|
||||||
_canAdd = _unit canAddItemToBackpack _classname;
|
_canAdd = [_unit, _classname, 1, false, false, true] call CBA_fnc_canAddItem;
|
||||||
};
|
};
|
||||||
case "uniform": {
|
case "uniform": {
|
||||||
_canAdd = _unit canAddItemToUniform _classname;
|
_canAdd = [_unit, _classname, 1, true, false, false] call CBA_fnc_canAddItem;
|
||||||
};
|
};
|
||||||
default {
|
default {
|
||||||
_canAdd = _unit canAdd _classname;
|
_canAdd = [_unit, _classname] call CBA_fnc_canAddItem;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ private _fullMagazines = floor (_ammo / _carryMaxAmmo);
|
|||||||
private _bulletsRemaining = _ammo % _carryMaxAmmo;
|
private _bulletsRemaining = _ammo % _carryMaxAmmo;
|
||||||
|
|
||||||
if (_unloadTo isKindOf "CaManBase") then {
|
if (_unloadTo isKindOf "CaManBase") then {
|
||||||
while {(_fullMagazines > 0) && {_unloadTo canAdd _carryMag}} do {
|
while {(_fullMagazines > 0) && {[_unloadTo, _carryMag] call CBA_fnc_canAddItem}} do {
|
||||||
_unloadTo addMagazine [_carryMag, _carryMaxAmmo];
|
_unloadTo addMagazine [_carryMag, _carryMaxAmmo];
|
||||||
_fullMagazines = _fullMagazines - 1;
|
_fullMagazines = _fullMagazines - 1;
|
||||||
};
|
};
|
||||||
if ((_bulletsRemaining > 0) && {_unloadTo canAdd _carryMag}) then {
|
if ((_bulletsRemaining > 0) && {[_unloadTo, _carryMag] call CBA_fnc_canAddItem}) then {
|
||||||
_unloadTo addMagazine [_carryMag, _bulletsRemaining];
|
_unloadTo addMagazine [_carryMag, _bulletsRemaining];
|
||||||
_bulletsRemaining = 0;
|
_bulletsRemaining = 0;
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@ params ["_player", ["_displayHint", false, [false]]];
|
|||||||
|
|
||||||
if (!GVAR(EnableCombatDeafness)) exitWith {};
|
if (!GVAR(EnableCombatDeafness)) exitWith {};
|
||||||
|
|
||||||
if !(_player canAdd "ACE_EarPlugs") exitWith { // inventory full
|
if !([_player, "ACE_EarPlugs"] call CBA_fnc_canAddItem) exitWith { // inventory full
|
||||||
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
|
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,5 +26,5 @@ private _compatibleMags = [_weapon] call CBA_fnc_compatibleMagazines;
|
|||||||
|
|
||||||
(magazinesAmmoFull _player) findIf {
|
(magazinesAmmoFull _player) findIf {
|
||||||
_x params ["_className", "", "_loaded"];
|
_x params ["_className", "", "_loaded"];
|
||||||
(_className in _compatibleMags) && {!_loaded} && {_target canAdd _className}
|
(_className in _compatibleMags) && {!_loaded} && {[_target, _className] call CBA_fnc_canAddItem}
|
||||||
} > -1
|
} > -1
|
||||||
|
@ -21,7 +21,7 @@ params ["_player", "_target", "_weapon"];
|
|||||||
private _compatibleMags = [_weapon] call CBA_fnc_compatibleMagazines;
|
private _compatibleMags = [_weapon] call CBA_fnc_compatibleMagazines;
|
||||||
private _filteredMags = magazinesAmmoFull _player select {
|
private _filteredMags = magazinesAmmoFull _player select {
|
||||||
_x params ["_className", "", "_loaded"];
|
_x params ["_className", "", "_loaded"];
|
||||||
(_className in _compatibleMags) && {!_loaded} && {_target canAdd _className}
|
(_className in _compatibleMags) && {!_loaded} && {[_target, _className] call CBA_fnc_canAddItem}
|
||||||
};
|
};
|
||||||
|
|
||||||
//select magazine with most ammo
|
//select magazine with most ammo
|
||||||
|
@ -25,5 +25,5 @@ private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >>
|
|||||||
|
|
||||||
_magazineType == _magazine // Magazine is of given type
|
_magazineType == _magazine // Magazine is of given type
|
||||||
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
|
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
|
||||||
&& {!_isLoaded || {_unit canAdd _magazineType}} // In inventory or can be moved into it
|
&& {!_isLoaded || {[_unit, _magazineType] call CBA_fnc_canAddItem}} // In inventory or can be moved into it
|
||||||
} count magazinesAmmoFull _unit > 1
|
} count magazinesAmmoFull _unit > 1
|
||||||
|
@ -27,7 +27,7 @@ private _unitMagCounts = [];
|
|||||||
private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count");
|
private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count");
|
||||||
|
|
||||||
//for every partial magazine, that is either in inventory or can be moved there
|
//for every partial magazine, that is either in inventory or can be moved there
|
||||||
if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {_player canAdd _xClassname}}) then {
|
if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {[_player, _xClassname] call CBA_fnc_canAddItem}}) then {
|
||||||
private _index = _unitMagazines find _xClassname;
|
private _index = _unitMagazines find _xClassname;
|
||||||
if (_index == -1) then {
|
if (_index == -1) then {
|
||||||
_unitMagazines pushBack _xClassname;
|
_unitMagazines pushBack _xClassname;
|
||||||
|
@ -39,7 +39,7 @@ private _startingAmmoCounts = [];
|
|||||||
if (_xClassname == _magazineClassname && {_xCount != _fullMagazineCount && {_xCount > 0}}) then {
|
if (_xClassname == _magazineClassname && {_xCount != _fullMagazineCount && {_xCount > 0}}) then {
|
||||||
if (_xLoaded) then {
|
if (_xLoaded) then {
|
||||||
//Try to Remove from weapon and add to inventory, otherwise ignore
|
//Try to Remove from weapon and add to inventory, otherwise ignore
|
||||||
if (_player canAdd _magazineClassname) then {
|
if ([_player, _magazineClassname] call CBA_fnc_canAddItem) then {
|
||||||
switch (_xType) do {
|
switch (_xType) do {
|
||||||
case (1): {_player removePrimaryWeaponItem _magazineClassname};
|
case (1): {_player removePrimaryWeaponItem _magazineClassname};
|
||||||
case (2): {_player removeHandgunItem _magazineClassname};
|
case (2): {_player removeHandgunItem _magazineClassname};
|
||||||
|
Loading…
Reference in New Issue
Block a user