Skip to content

Commit

Permalink
Magazine Repack - Add setting & hint for repacking loaded magazines (#…
Browse files Browse the repository at this point in the history
…8475)

* add setting to repack equipped magazines

* derp

* derpderp

* always show hint, remove setting
  • Loading branch information
LinkIsGrim authored Oct 12, 2021
1 parent 88e774c commit bbe4b48
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >>

_magazineType == _magazine // Magazine is of given type
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
&& {!_isLoaded || {[_unit, _magazineType] call CBA_fnc_canAddItem}} // In inventory or can be moved into it
&& {!_isLoaded || {GVAR(repackLoadedMagazines) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}} // In inventory or can be moved into it
} count magazinesAmmoFull _unit > 1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private _unitMagCounts = [];
private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count");

//for every partial magazine, that is either in inventory or can be moved there
if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {[_player, _xClassname] call CBA_fnc_canAddItem}}) then {
if ((_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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private _startingAmmoCounts = [];
if (_xClassname == _magazineClassname && {_xCount != _fullMagazineCount && {_xCount > 0}}) then {
if (_xLoaded) then {
//Try to Remove from weapon and add to inventory, otherwise ignore
if ([_player, _magazineClassname] call CBA_fnc_canAddItem) then {
if (GVAR(repackLoadedMagazines) && {[_player, _magazineClassname] call CBA_fnc_canAddItem}) then {
switch (_xType) do {
case (1): {_player removePrimaryWeaponItem _magazineClassname};
case (2): {_player removeHandgunItem _magazineClassname};
Expand All @@ -48,6 +48,7 @@ private _startingAmmoCounts = [];
};
_player addMagazine [_magazineClassname, _xCount];
_startingAmmoCounts pushBack _xCount;
[LLSTRING(repackLoadedMagazinesHint)] call EFUNC(common,displayTextStructured);
};
} else {
_startingAmmoCounts pushBack _xCount;
Expand Down
8 changes: 8 additions & 0 deletions addons/magazinerepack/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ private _category = format ["ACE %1", localize LSTRING(DisplayName)];
[1, 10, 8, 1],
1
] call CBA_fnc_addSetting;

[
QGVAR(repackLoadedMagazines), "CHECKBOX",
LSTRING(repackLoadedMagazines),
_category,
true,
0
] call CBA_fnc_addSetting;
6 changes: 6 additions & 0 deletions addons/magazinerepack/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,11 @@
<Chinese>%1個滿的與%2個部分的</Chinese>
<Turkish>%1 Dolu ve %2 Partial</Turkish>
</Key>
<Key ID="STR_ACE_MagazineRepack_repackLoadedMagazines">
<English>Repack Loaded Magazines</English>
</Key>
<Key ID="STR_ACE_MagazineRepack_repackLoadedMagazinesHint">
<English>Repacking magazines, weapon unloaded</English>
</Key>
</Package>
</Project>

0 comments on commit bbe4b48

Please sign in to comment.