CSW - Disable non-CSW rearm actions for CSW vehicles (#9255)

* improve CSW integration

* do this more cleanly

* code style

* revert ammo handling check change
This commit is contained in:
Grim 2023-08-18 14:10:15 -03:00 committed by GitHub
parent a168330550
commit 55cc755542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 19 deletions

View File

@ -18,27 +18,33 @@
params ["_vehicle", ["_targetTurret", true, [[], true]]]; params ["_vehicle", ["_targetTurret", true, [[], true]]];
if (!(_vehicle isKindOf "StaticWeapon")) exitWith { [[],[]] }; // limit to statics for now private _return = [[], []];
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]))}) exitWith { [[],[]] }; if !(_vehicle isKindOf "StaticWeapon") exitWith {_return}; // limit to statics for now
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]))}) exitWith {_return};
private _turretMagsCSW = _return select 0;
private _allCarryMags = _return select 1;
private _turrets = allTurrets _vehicle;
if (_targetTurret isNotEqualTo true) then {
_turrets = _turrets select {_x isEqualTo _targetTurret};
};
private _turretMagsCSW = [];
private _allCarryMags = [];
{ {
private _turretPath = _x; private _turretPath = _x;
if ((_targetTurret isEqualTo true) || {_turretPath isEqualTo _targetTurret}) then { {
private _weapon = _x;
{ {
private _weapon = _x; private _xMag = _x;
{ private _carryMag = _xMag call FUNC(getCarryMagazine);
private _xMag = _x; if (_carryMag != "") then {
private _carryMag = _xMag call FUNC(getCarryMagazine); _turretMagsCSW pushBackUnique _xMag;
if (_carryMag != "") then { _allCarryMags pushBackUnique _carryMag;
_turretMagsCSW pushBackUnique _xMag; };
_allCarryMags pushBackUnique _carryMag; } forEach (compatibleMagazines _weapon);
}; } forEach (_vehicle weaponsTurret _turretPath);
} forEach ([_weapon] call CBA_fnc_compatibleMagazines); } forEach _turrets;
} forEach (_vehicle weaponsTurret _turretPath);
};
} forEach (allTurrets _vehicle);
[_turretMagsCSW, _allCarryMags] _return

View File

@ -37,6 +37,9 @@ if ((missionNamespace getVariable [_proxyWeapon, objNull]) isEqualType {}) then
}; };
if (!_needed) exitWith { TRACE_2("not needed",_needed,_proxyWeapon); }; if (!_needed) exitWith { TRACE_2("not needed",_needed,_proxyWeapon); };
// Rearm compatibility, prevent reloading entire static and breaking CSW
_staticWeapon setVariable [QEGVAR(rearm,scriptedLoadout), true, true];
TRACE_2("swapping to proxy weapon",_currentWeapon,_proxyWeapon); TRACE_2("swapping to proxy weapon",_currentWeapon,_proxyWeapon);
_staticWeapon removeWeaponTurret [_currentWeapon, _turret]; _staticWeapon removeWeaponTurret [_currentWeapon, _turret];
_staticWeapon addWeaponTurret [_proxyWeapon, _turret]; _staticWeapon addWeaponTurret [_proxyWeapon, _turret];