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>
This commit is contained in:
Mike-MF 2024-08-20 23:24:58 +01:00 committed by GitHub
parent 0643ca6fd9
commit 52c19d53af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 3 deletions

View File

@ -18,6 +18,9 @@
params ["_unit", "_magazine"]; 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"); private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
{ {

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror, commy2, esteldunedain, Ruthberg * Author: PabstMirror, commy2, esteldunedain, Ruthberg
* Gets magazine children for interaciton menu. * Gets magazine children for interaction menu.
* *
* Arguments: * Arguments:
* 0: Target <OBJECT> * 0: Target <OBJECT>
@ -18,16 +18,20 @@
params ["_target", "_player"]; params ["_target", "_player"];
private _cfgMagazines = configFile >> "CfgMagazines";
// get all mags and ammo count // get all mags and ammo count
private _unitMagazines = []; private _unitMagazines = [];
private _unitMagCounts = []; private _unitMagCounts = [];
{ {
_x params ["_xClassname", "_xCount", "_xLoaded", "_xType"]; _x params ["_xClassname", "_xCount", "_xLoaded", "_xType"];
private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count"); private _configMagazine = _cfgMagazines >> _xClassname;
private _xFullMagazineCount = getNumber (_configMagazine >> "count");
private _isRepackDisabled = getNumber (_configMagazine >> "ace_disableRepacking") == 1;
//for every partial magazine, that is either in inventory or can be moved there //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; private _index = _unitMagazines find _xClassname;
if (_index == -1) then { if (_index == -1) then {
_unitMagazines pushBack _xClassname; _unitMagazines pushBack _xClassname;

View File

@ -0,0 +1,26 @@
---
layout: wiki
title: Magazine Repack Framework
description: Explains how to disable repacking.
group: framework
order: 5
parent: wiki
mod: ace
version:
major: 3
minor: 18
patch: 0
---
## 1. Config Values
### 1.1 Disable Magazine Repacking
```cpp
class CfgMagazines {
class MyMagazine {
// Disables the ability to repack this magazine
ace_disableRepacking = 1;
};
};
```