Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magazine Repack - Add ability to disable repacking via class #10232

Merged
merged 7 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
params ["_unit", "_magazine"];

private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
private _isRepackDisabled = getNumber (configFile >> "CfgMagazines" >> _magazine >> "ace_disableRepacking") == 1;
Mike-MF marked this conversation as resolved.
Show resolved Hide resolved

{
_x params ["_magazineType", "_ammoCount", "_isLoaded"];

_magazineType == _magazine // Magazine is of given type
&& {!_isRepackDisabled}
&& {_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
5 changes: 3 additions & 2 deletions addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror, commy2, esteldunedain, Ruthberg
* Gets magazine children for interaciton menu.
* Gets magazine children for interaction menu.
*
* Arguments:
* 0: Target <OBJECT>
Expand All @@ -25,9 +25,10 @@ private _unitMagCounts = [];
_x params ["_xClassname", "_xCount", "_xLoaded", "_xType"];

private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count");
private _isRepackDisabled = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "ace_disableRepacking") == 1;
Mike-MF marked this conversation as resolved.
Show resolved Hide resolved

//for every partial magazine, that is either in inventory or can be moved there
if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {GVAR(repackLoadedMagazines) && {[_player, _xClassname] call CBA_fnc_canAddItem}}}) then {
if ((!_isRepackDisabled) && {_xCount < _xFullMagazineCount} && {_xCount > 0} && {(!_xLoaded) || {GVAR(repackLoadedMagazines) && {[_player, _xClassname] call CBA_fnc_canAddItem}}}) then {
private _index = _unitMagazines find _xClassname;
if (_index == -1) then {
_unitMagazines pushBack _xClassname;
Expand Down