mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
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:
parent
0643ca6fd9
commit
52c19d53af
@ -18,6 +18,9 @@
|
||||
|
||||
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");
|
||||
|
||||
{
|
||||
|
@ -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>
|
||||
@ -18,16 +18,20 @@
|
||||
|
||||
params ["_target", "_player"];
|
||||
|
||||
private _cfgMagazines = configFile >> "CfgMagazines";
|
||||
|
||||
// get all mags and ammo count
|
||||
private _unitMagazines = [];
|
||||
private _unitMagCounts = [];
|
||||
{
|
||||
_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
|
||||
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;
|
||||
|
26
docs/wiki/framework/magazine-repack-framework.md
Normal file
26
docs/wiki/framework/magazine-repack-framework.md
Normal 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;
|
||||
};
|
||||
};
|
||||
```
|
Loading…
Reference in New Issue
Block a user