mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
a4ae61f1fc
* allow players to reload from nearSupplies * limit reloading to friendly sides * add handling for ai getting inside empty weapon * configOf for lookup * add getin handler, hammer out remaining bugs * configOf lookup * improve friendly/object filter * more configOf lookups * Capitalize settings, add ammo storage setting * remove systemChat Co-authored-by: PabstMirror <pabstmirror@gmail.com> * fix TRACE Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
55 lines
1.5 KiB
Plaintext
55 lines
1.5 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: esteldunedain
|
|
* Removes a magazine from the unit or object that has a specific ammo count
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
* 1: Magazine <STRING>
|
|
* 2: Ammo count <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* Magazine Removed <BOOL>
|
|
*
|
|
* Example:
|
|
* [bob, "magazine", 5] call ace_common_fnc_removeSpecificMagazine
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params [["_unit", objNull, [objNull]], ["_magazineType", "", [""]], ["_ammoCount", 0, [0]]];
|
|
|
|
private _isRemoved = false;
|
|
|
|
private _fnc_removeMagazine = {
|
|
params ["_container", "_magArray"];
|
|
_magArray params ["_magazineType", "_ammoCount"];
|
|
|
|
private _allMagazines = magazinesAmmoCargo _container;
|
|
private _specificMagazineIndex = _allMagazines findIf {_x isEqualTo _magArray};
|
|
_allMagazines deleteAt _specificMagazineIndex;
|
|
|
|
if (_specificMagazineIndex > -1) exitWith {
|
|
clearMagazineCargoGlobal _container;
|
|
if (_container isKindOf "WeaponHolder" && {_allMagazines isNotEqualTo []}) then {
|
|
_container = createVehicle [typeOf _container, getPosATL _container, [], 0, "CAN_COLLIDE"];
|
|
};
|
|
{
|
|
_container addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
|
} forEach _allMagazines;
|
|
true
|
|
};
|
|
false
|
|
};
|
|
|
|
private _containerArray = [_unit];
|
|
if (_unit isKindOf "CAManBase") then {
|
|
_containerArray = [uniformContainer _unit, vestContainer _unit, backpackContainer _unit];
|
|
};
|
|
|
|
{
|
|
if ([_x, [_magazineType, _ammoCount]] call _fnc_removeMagazine) exitWith {_isRemoved = true};
|
|
} forEach _containerArray;
|
|
|
|
_isRemoved
|