-
Notifications
You must be signed in to change notification settings - Fork 148
/
fnc_replaceMagazineCargo.sqf
65 lines (49 loc) · 1.78 KB
/
fnc_replaceMagazineCargo.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Internal Function: cba_disposable_fnc_replaceMagazineCargo
Description:
Replaces disposable launcher magazines with loaded disposable launchers.
Parameters:
_box - Any object with cargo <OBJECT>
Returns:
Nothing.
Examples:
(begin example)
_box call cba_disposable_fnc_replaceMagazineCargo
(end)
Author:
commy2
---------------------------------------------------------------------------- */
if (!GVAR(replaceDisposableLauncher)) exitWith {};
params ["_box"];
if (!local _box) exitWith {};
if (missionNamespace getVariable [QGVAR(disableMagazineReplacement), false]) exitWith {};
private _uniformContainer = uniformContainer _box;
if (!isNull _uniformContainer) then {
_uniformContainer call FUNC(replaceMagazineCargo);
};
private _vestContainer = vestContainer _box;
if (!isNull _vestContainer) then {
_vestContainer call FUNC(replaceMagazineCargo);
};
private _backpackContainer = backpackContainer _box;
if (!isNull _backpackContainer) then {
_backpackContainer call FUNC(replaceMagazineCargo);
};
{
_x call FUNC(replaceMagazineCargo);
} forEach everyBackpack _box;
if (magazineCargo _box arrayIntersect GVAR(magazines) isEqualTo []) exitWith {};
private _magazines = magazinesAmmoCargo _box;
clearMagazineCargoGlobal _box;
private _isBackpack = getNumber (configFile >> "CfgVehicles" >> typeOf _box >> "isBackpack") != -1;
{
_x params ["_magazine", "_ammo"];
if (_magazine in GVAR(magazines)) then {
if !(_isBackpack) then {
_box addWeaponCargoGlobal [GVAR(MagazineLaunchers) getVariable _magazine, 1];
};
} else {
_box addMagazineAmmoCargo [_magazine, 1, _ammo];
};
} forEach _magazines;