From dfc018a031103bd10a5a32e597dc5b5440818ace Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:06:33 +0200 Subject: [PATCH] Minor improvements --- addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf | 5 +++-- .../cookoff/functions/fnc_detonateAmmunitionServerLoop.sqf | 2 +- addons/cookoff/functions/fnc_getVehicleAmmo.sqf | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf b/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf index 9f9fecaab2..b6b97c856a 100644 --- a/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf +++ b/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf @@ -39,11 +39,12 @@ if (_object getVariable [QGVAR(isAmmoDetonating), false]) exitWith {}; _object setVariable [QGVAR(isAmmoDetonating), true, true]; -_object setVariable [QGVAR(cookoffMagazines), _object call FUNC(getVehicleAmmo)]; +// Make sure that virtual magazines have been reset +_object setVariable [QGVAR(virtualMagazines), nil]; // Save the vehicle's ammo, so it won't be removed during cook-off if (!GVAR(removeAmmoDuringCookoff)) then { - _object setVariable [QGVAR(cookoffMagazines), _object call FUNC(getVehicleAmmo)]; + _object setVariable [QGVAR(cookoffMagazines), [_object, true] call FUNC(getVehicleAmmo)]; }; [LINKFUNC(detonateAmmunitionServerLoop), [_object, _destroyWhenFinished, _source, _instigator], _initialDelay] call CBA_fnc_waitAndExecute; diff --git a/addons/cookoff/functions/fnc_detonateAmmunitionServerLoop.sqf b/addons/cookoff/functions/fnc_detonateAmmunitionServerLoop.sqf index 34124cc70d..a40221a56b 100644 --- a/addons/cookoff/functions/fnc_detonateAmmunitionServerLoop.sqf +++ b/addons/cookoff/functions/fnc_detonateAmmunitionServerLoop.sqf @@ -27,7 +27,7 @@ private _objectAmmo = _object getVariable QGVAR(cookoffMagazines); private _removeAmmoDuringCookoff = isNil "_objectAmmo"; if (_removeAmmoDuringCookoff) then { - _objectAmmo = _object call FUNC(getVehicleAmmo); + _objectAmmo = [_object, true] call FUNC(getVehicleAmmo); }; _objectAmmo params ["_magazines", "_totalAmmo"]; diff --git a/addons/cookoff/functions/fnc_getVehicleAmmo.sqf b/addons/cookoff/functions/fnc_getVehicleAmmo.sqf index 2c48729ab8..83ab3f375f 100644 --- a/addons/cookoff/functions/fnc_getVehicleAmmo.sqf +++ b/addons/cookoff/functions/fnc_getVehicleAmmo.sqf @@ -5,6 +5,7 @@ * * Arguments: * 0: Object + * 1: If the virtual magazine count should be set (default: false) * * Return Value: * 0: Ammo array @@ -20,7 +21,7 @@ * Public: No */ -params ["_object"]; +params ["_object", ["_setVirtualAmmoCount", false]]; TRACE_1("getVehicleAmmo",_object); private _ammoToDetonate = []; @@ -80,7 +81,9 @@ if (isNil "_virtualAmmo") then { _totalAmmo = _totalAmmo + 10; }; - _object setVariable [QGVAR(virtualMagazines), _virtualAmmo]; + if (_setVirtualAmmoCount) then { + _object setVariable [QGVAR(virtualMagazines), _virtualAmmo]; + }; } else { { _totalAmmo = _totalAmmo + (_x select 1);