ACE3/addons/csw/functions/fnc_aceRearmGetCarryMagazines.sqf
johnb432 fa8161bc03 Separate assembly mod and ammo handling more
They aren't entirely separate. If you enable advanced assembly, you need ammo handling to be enabled.
2024-04-02 15:21:28 +02:00

50 lines
1.3 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Helper function for ace_rearm; Gets magazines that should be loaded by csw
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Specific Turret or pass bool to check all turrets <ARRAY><BOOL>(default: true)
*
* Return Value:
* [0: compatible veh mags, 1: carry mags] <ARRAY>
*
* Example:
* [cursorObject, [0]] call ace_csw_fnc_aceRearmGetCarryMagazines
*
* Public: No
*/
params ["_vehicle", ["_targetTurret", true, [[], true]]];
private _return = [[], []];
if !(_vehicle isKindOf "StaticWeapon") exitWith {_return}; // limit to statics for now
if (GVAR(ammoHandling) == 0) exitWith {_return};
private _turretMagsCSW = _return select 0;
private _allCarryMags = _return select 1;
private _turrets = allTurrets _vehicle;
if (_targetTurret isNotEqualTo true) then {
_turrets = _turrets select {_x isEqualTo _targetTurret};
};
{
private _turretPath = _x;
{
private _weapon = _x;
{
private _xMag = _x;
private _carryMag = _xMag call FUNC(getCarryMagazine);
if (_carryMag != "") then {
_turretMagsCSW pushBackUnique _xMag;
_allCarryMags pushBackUnique _carryMag;
};
} forEach (compatibleMagazines _weapon);
} forEach (_vehicle weaponsTurret _turretPath);
} forEach _turrets;
_return