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 setting & hint for repacking loaded magazines #8475

Merged
merged 6 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all 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: 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>