From 2cdc40a958ae8f4899df5922621168a2d778cb62 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 13 Feb 2024 01:34:58 +0100 Subject: [PATCH] Converted enable setting to bool --- addons/cookoff/CfgEden.hpp | 2 +- addons/cookoff/functions/fnc_cookOff.sqf | 20 +++++++++++++------ .../functions/fnc_detonateAmmunition.sqf | 9 +++++++++ .../fnc_detonateAmmunitionServer.sqf | 18 ++++++++--------- addons/cookoff/initSettings.inc.sqf | 4 ++-- addons/cookoff/stringtable.xml | 4 ++-- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/addons/cookoff/CfgEden.hpp b/addons/cookoff/CfgEden.hpp index 12117cae3b..77c5e9e281 100644 --- a/addons/cookoff/CfgEden.hpp +++ b/addons/cookoff/CfgEden.hpp @@ -11,7 +11,7 @@ class Cfg3DEN { expression = QUOTE(if (!_value) then {_this setVariable [ARR_3('%s',_value,true)]}); typeName = "BOOL"; condition = "objectVehicle"; - defaultValue = QUOTE((GETMVAR(QGVAR(enable),0)) in [ARR_2(1,2)]); + defaultValue = QUOTE(GETMVAR(QGVAR(enable),true)]); }; class GVAR(enableAmmoCookoff) { property = QGVAR(enableAmmoCookoff); diff --git a/addons/cookoff/functions/fnc_cookOff.sqf b/addons/cookoff/functions/fnc_cookOff.sqf index 215cfd1c92..7c82e18deb 100644 --- a/addons/cookoff/functions/fnc_cookOff.sqf +++ b/addons/cookoff/functions/fnc_cookOff.sqf @@ -27,7 +27,7 @@ */ if (!isServer) exitWith {}; -if (GVAR(enable) == 0 || {GVAR(cookoffDuration) == 0}) exitWith {}; +if (!GVAR(enable) || {GVAR(cookoffDuration) == 0}) exitWith {}; params [ "_vehicle", @@ -48,14 +48,15 @@ if !(_vehicle isKindOf "AllVehicles") exitWith {}; if (_vehicle isKindOf "CAManBase" || {_vehicle isKindOf "StaticWeapon"}) exitWith {}; +// If under water, ignore +// underwater is not very reliable, so use model center instead +if (underwater _vehicle || {private _posASL = getPosWorld _vehicle; surfaceIsWater _posASL && {(_posASL select 2) < 0}) exitWith {}; + // Check if cook-off is disabled on vehicle specifically if !(_vehicle getVariable [QGVAR(enable), true]) exitWith {}; -// Exit if cook-off enabled only for players and no players in vehicle crew found -if ((GVAR(enable) isEqualTo 1) && {(crew _vehicle) findIf {isPlayer _x} == -1}) exitWith {}; - TRACE_2("cooking off",_vehicle,_intensity); -TRACE_8("",_instigator,_delayBetweenSmokeAndFire,_ammoDetonationChance,_detonateAfterCookoff,_fireSource,_canRing,_maxIntensity,_canJet); +TRACE_9("",_source,_instigator,_delayBetweenSmokeAndFire,_ammoDetonationChance,_detonateAfterCookoff,_fireSource,_canRing,_canJet,_maxIntensity); if (_vehicle getVariable [QGVAR(isCookingOff), false]) exitWith {}; @@ -101,7 +102,14 @@ if (_delayBetweenSmokeAndFire) then { private _intensity = _vehicle getVariable [QGVAR(intensity), 0]; - if (isNull _vehicle || {_intensity <= 1} || {GVAR(enable) == 0} || {GVAR(cookoffDuration) == 0}) exitWith { + if ( + isNull _vehicle || + !GVAR(enable) || + {_intensity <= 1} || + {GVAR(cookoffDuration) == 0} || + {underwater _vehicle} || + {private _posASL = getPosWorld _vehicle; surfaceIsWater _posASL && {(_posASL select 2) < 0})} + ) exitWith { (_this select 1) call CBA_fnc_removePerFrameHandler; // Remove effects from JIP diff --git a/addons/cookoff/functions/fnc_detonateAmmunition.sqf b/addons/cookoff/functions/fnc_detonateAmmunition.sqf index e6186ccedc..f2002b4b2e 100644 --- a/addons/cookoff/functions/fnc_detonateAmmunition.sqf +++ b/addons/cookoff/functions/fnc_detonateAmmunition.sqf @@ -25,6 +25,15 @@ params ["_object", ["_destroyWhenFinished", false], ["_source", objNull], ["_ins if (isNull _object) exitWith {}; +// Check if the object can cook its ammo off +if ( + underwater _object || + {private _posASL = getPosWorld _object; surfaceIsWater _posASL && {(_posASL select 2) < 0}} || // underwater is not very reliable, so use model center instead + {GVAR(ammoCookoffDuration) == 0} || + {!([GVAR(enableAmmoCookoff), GVAR(enableAmmobox)] select (_object isKindOf "ReammoBox_F"))} || + {!(_object getVariable [QGVAR(enableAmmoCookoff), true])} +}) exitWith {}; + // Don't have an object detonate its ammo twice if (_object getVariable [QGVAR(isAmmoDetonating), false]) exitWith {}; diff --git a/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf b/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf index 2e3d56bb7e..7a5a55ebb5 100644 --- a/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf +++ b/addons/cookoff/functions/fnc_detonateAmmunitionServer.sqf @@ -29,16 +29,14 @@ if (isNull _object) exitWith {}; private _hasFinished = _totalAmmo <= 0 || {_magazines isEqualTo []}; // If the cook-off has finished or been interrupted, clean up the effects for boxes (no vehicle effects) -if (_hasFinished || - {underwater _object} || { - if (GVAR(ammoCookoffDuration) == 0) exitWith {true}; - - if (_object isKindOf "ReammoBox_F") exitWith { - !(GVAR(enableAmmobox) && {_object getVariable [QGVAR(enableAmmoCookoff), true]}) - }; - - !(GVAR(enableAmmoCookoff) && {_object getVariable [QGVAR(enableAmmoCookoff), true]}) -}) exitWith { +if ( + _hasFinished || + {underwater _object} || + {private _posASL = getPosWorld _object; surfaceIsWater _posASL && {(_posASL select 2) < 0}} || // underwater is not very reliable, so use model center instead + {GVAR(ammoCookoffDuration) == 0} || + {!([GVAR(enableAmmoCookoff), GVAR(enableAmmobox)] select (_object isKindOf "ReammoBox_F"))} || + {!(_object getVariable [QGVAR(enableAmmoCookoff), true])} +) exitWith { if (_object isKindOf "ReammoBox_F") then { [QGVAR(cleanupEffects), _object] call CBA_fnc_globalEvent; diff --git a/addons/cookoff/initSettings.inc.sqf b/addons/cookoff/initSettings.inc.sqf index d06e1bdfab..cfcad8c986 100644 --- a/addons/cookoff/initSettings.inc.sqf +++ b/addons/cookoff/initSettings.inc.sqf @@ -1,9 +1,9 @@ [ QGVAR(enable), - "LIST", + "CHECKBOX", [LSTRING(enable_name), LSTRING(enable_tooltip)], LSTRING(category_displayName), - [[0, 1, 2], ["STR_A3_OPTIONS_DISABLED", ELSTRING(common,playerOnly), ELSTRING(common,playersAndAI)], 2], + true, 1, {[QGVAR(enable), _this] call EFUNC(common,cbaSettings_settingChanged)} ] call CBA_fnc_addSetting; diff --git a/addons/cookoff/stringtable.xml b/addons/cookoff/stringtable.xml index 51c67564f5..a49955ac2b 100644 --- a/addons/cookoff/stringtable.xml +++ b/addons/cookoff/stringtable.xml @@ -17,10 +17,10 @@ ACE Vznícení munice - Enable vehicle cook-off + Enable vehicle cook-off effects - Enables vehicle cook-off effects (fire and sound). + Enables vehicle cook-off effects (fire and fire sound, but doesn't include ammunition detonations). Enable ammo box cook-off