2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-02-20 05:45:17 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: esteldunedain
|
2021-09-25 15:39:03 +00:00
|
|
|
* Removes a magazine from the unit or object that has a specific ammo count
|
2015-02-20 05:45:17 +00:00
|
|
|
*
|
2015-09-19 17:26:45 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
2015-02-20 05:45:17 +00:00
|
|
|
* 1: Magazine <STRING>
|
|
|
|
* 2: Ammo count <NUMBER>
|
|
|
|
*
|
2015-09-19 17:26:45 +00:00
|
|
|
* Return Value:
|
2021-09-25 15:39:03 +00:00
|
|
|
* Magazine Removed <BOOL>
|
2015-09-19 17:26:45 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, "magazine", 5] call ace_common_fnc_removeSpecificMagazine
|
|
|
|
*
|
2015-09-19 17:26:45 +00:00
|
|
|
* Public: No
|
2015-02-20 05:45:17 +00:00
|
|
|
*/
|
|
|
|
|
2015-12-14 12:08:19 +00:00
|
|
|
params [["_unit", objNull, [objNull]], ["_magazineType", "", [""]], ["_ammoCount", 0, [0]]];
|
2015-09-19 17:26:45 +00:00
|
|
|
|
2015-12-14 12:08:19 +00:00
|
|
|
private _isRemoved = false;
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2021-09-25 15:39:03 +00:00
|
|
|
private _fnc_removeMagazine = {
|
|
|
|
params ["_container", "_magArray"];
|
|
|
|
_magArray params ["_magazineType", "_ammoCount"];
|
2015-12-14 12:08:19 +00:00
|
|
|
|
2023-09-05 14:14:42 +00:00
|
|
|
if (_magArray in (magazinesAmmoCargo _container)) exitWith {
|
|
|
|
_container addMagazineAmmoCargo [_magazineType, -1, _ammoCount];
|
2021-09-25 15:39:03 +00:00
|
|
|
true
|
|
|
|
};
|
|
|
|
false
|
2015-02-20 05:45:17 +00:00
|
|
|
};
|
|
|
|
|
2021-09-25 15:39:03 +00:00
|
|
|
private _containerArray = [_unit];
|
|
|
|
if (_unit isKindOf "CAManBase") then {
|
|
|
|
_containerArray = [uniformContainer _unit, vestContainer _unit, backpackContainer _unit];
|
2015-02-20 05:45:17 +00:00
|
|
|
};
|
|
|
|
|
2021-09-25 15:39:03 +00:00
|
|
|
{
|
|
|
|
if ([_x, [_magazineType, _ammoCount]] call _fnc_removeMagazine) exitWith {_isRemoved = true};
|
|
|
|
} forEach _containerArray;
|
2015-12-14 12:08:19 +00:00
|
|
|
|
2021-09-25 15:39:03 +00:00
|
|
|
_isRemoved
|