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

Disposable - Replace magazines in backpack when launcher fits backpacks #1485

Merged
merged 4 commits into from
Dec 18, 2021
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
6 changes: 6 additions & 0 deletions addons/disposable/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ GVAR(NormalLaunchers) = [] call CBA_fnc_createNamespace;
GVAR(LoadedLaunchers) = [] call CBA_fnc_createNamespace;
GVAR(UsedLaunchers) = [] call CBA_fnc_createNamespace;
GVAR(magazines) = [];
GVAR(BackpackReplaceableMagazines) = [];
commy2 marked this conversation as resolved.
Show resolved Hide resolved
GVAR(MagazineLaunchers) = [] call CBA_fnc_createNamespace;

private _cfgWeapons = configFile >> "CfgWeapons";
Expand All @@ -35,6 +36,7 @@ private _cfgMagazines = configFile >> "CfgMagazines";
{
private _launcher = configName _x;
private _magazine = configName (_cfgMagazines >> (getArray (_cfgWeapons >> _launcher >> "magazines") select 0));
private _replaceInBackpack = [_cfgMagazines >> _magazine, QGVAR(launcherFitsBackpack), 0] call BIS_fnc_returnConfigEntry > 0;
commy2 marked this conversation as resolved.
Show resolved Hide resolved
getArray _x params ["_loadedLauncher", "_usedLauncher"];

GVAR(LoadedLaunchers) setVariable [_launcher, _loadedLauncher];
Expand All @@ -48,6 +50,10 @@ private _cfgMagazines = configFile >> "CfgMagazines";
GVAR(MagazineLaunchers) setVariable [_magazine, _loadedLauncher];
};

if (_replaceInBackpack) then {
GVAR(BackpackReplaceableMagazines) pushBackUnique _magazine;
commy2 marked this conversation as resolved.
Show resolved Hide resolved
};

// check if mass entries add up
private _massLauncher = getNumber (_cfgWeapons >> _launcher >> "WeaponSlotsInfo" >> "mass");
private _massMagazine = getNumber (_cfgMagazines >> _magazine >> "mass");
Expand Down
2 changes: 1 addition & 1 deletion addons/disposable/fnc_replaceMagazineCargo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private _isBackpack = getNumber (configOf _box >> "isBackpack") != -1;
_x params ["_magazine", "_ammo"];

if (_magazine in GVAR(magazines)) then {
if !(_isBackpack) then {
if (!_isBackpack || {_magazine in GVAR(BackpackReplaceableMagazines)}) then {
_box addWeaponCargoGlobal [GVAR(MagazineLaunchers) getVariable _magazine, 1];
commy2 marked this conversation as resolved.
Show resolved Hide resolved
};
} else {
Expand Down