diff --git a/addons/csw/XEH_PREP.hpp b/addons/csw/XEH_PREP.hpp index 7985e2aff9..27e6b6f90b 100644 --- a/addons/csw/XEH_PREP.hpp +++ b/addons/csw/XEH_PREP.hpp @@ -5,7 +5,6 @@ PREP(aceRearmGetCarryMagazines); PREP(ai_handleFired); PREP(ai_handleGetIn); PREP(ai_reload); -PREP(ai_unloadMagazines); PREP(assemble_canDeployTripod); PREP(assemble_canDeployWeapon); @@ -37,6 +36,7 @@ PREP(reload_handleAddTurretMag); PREP(reload_handleRemoveTurretMag); PREP(reload_handleReturnAmmo); PREP(reload_loadMagazine); +PREP(unloadMagazines); PREP(staticWeaponInit); PREP(staticWeaponInit_unloadExtraMags); diff --git a/addons/csw/functions/fnc_ai_reload.sqf b/addons/csw/functions/fnc_ai_reload.sqf index 3b53d3c71c..4f4c066381 100644 --- a/addons/csw/functions/fnc_ai_reload.sqf +++ b/addons/csw/functions/fnc_ai_reload.sqf @@ -23,7 +23,7 @@ if (_loadableMagazines isEqualTo []) exitWith {TRACE_1("could not find reloadabl private _forcedMag = _vehicle getVariable [QGVAR(forcedMag), ""]; // If this is called while CSW has ammo, unload mags in gunner's turret -if (someAmmo _vehicle) then {[_vehicle, _gunner, [_gunner] call EFUNC(common,getTurretIndex)] call FUNC(ai_unloadMagazine)}; +if (someAmmo _vehicle) then {[_vehicle, [_gunner] call EFUNC(common,getTurretIndex)] call FUNC(unloadMagazines)}; private _bestAmmo = 0; private _magazineInfo = []; diff --git a/addons/csw/functions/fnc_ai_unloadMagazines.sqf b/addons/csw/functions/fnc_unloadMagazines.sqf similarity index 60% rename from addons/csw/functions/fnc_ai_unloadMagazines.sqf rename to addons/csw/functions/fnc_unloadMagazines.sqf index 544944dd59..7e1fbffb19 100644 --- a/addons/csw/functions/fnc_ai_unloadMagazines.sqf +++ b/addons/csw/functions/fnc_unloadMagazines.sqf @@ -1,19 +1,24 @@ #include "script_component.hpp" /* * Author: LinkIsGrim - * Switch loaded magazine on an AI CSW + * Unloads and returns magazines from a CSW * * Arguments: - * 0: CSW - * 1: Gunner - * 2: Turret Path + * 0: CSW (default: objNull) + * 1: Turret Path (default: [0], gunner turret) + * 2: Return removed magazines (default: true) * * Return Value: * None * - * Public: No + * Example: + * [cursorTarget, [0]] call ace_csw_fnc_unloadMagazines + * + * Public: Yes */ -params ["_vehicle", "_gunner", "_turretPath"]; +params [["_vehicle", objNull, [objNull]], ["_turretPath", [0], [0]], ["_returnMags", true, [true]]]; + +if (isNull _vehicle) exitWith {}; private _magsToRemove = []; private _containerMagazineClassnames = []; @@ -38,6 +43,8 @@ private _containerMagazineCount = []; _vehicle removeMagazinesTurret _x; } forEach _magsToRemove; -{ - [_vehicle, _x, _containerMagazineCount select _forEachIndex] call FUNC(reload_handleReturnAmmo); -} forEach _containerMagazineClassnames; +if (_returnMags) then { + { + [_vehicle, _x, _containerMagazineCount select _forEachIndex] call FUNC(reload_handleReturnAmmo); + } forEach _containerMagazineClassnames; +};