ACE3/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
Mike-MF 52c19d53af
Magazine Repack - Add ability to disable repacking via class (#10232)
* Magazine Repack - Add ability to disable repacking via class

* Update addons/magazinerepack/functions/fnc_getMagazineChildren.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Bretts suggestion

* Documentation

* Apply suggestions from code review

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Review missed a line

* Fix getting number instead of config & microoptimisation

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-08-20 17:24:58 -05:00

33 lines
1009 B
Plaintext

#include "..\script_component.hpp"
/*
* Author: mharis001
* Checks if the given unit can repack magazines of the given type.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Magazine <STRING>
*
* Return Value:
* Can Repack Magazine <BOOL>
*
* Example:
* [_unit, _magazine] call ace_magazinerepack_fnc_canRepackMagazine
*
* Public: No
*/
params ["_unit", "_magazine"];
// Exit if repack is disabled for this magazine.
if (getNumber (configFile >> "CfgMagazines" >> _magazine >> "ace_disableRepacking") == 1) exitWith {false};
private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
{
_x params ["_magazineType", "_ammoCount", "_isLoaded"];
_magazineType == _magazine // Magazine is of given type
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
&& {!_isLoaded || {GVAR(repackLoadedMagazines) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}} // In inventory or can be moved into it
} count magazinesAmmoFull _unit > 1