Converted enable setting to bool

This commit is contained in:
johnb432 2024-02-13 01:34:58 +01:00
parent 0663bd16c9
commit 2cdc40a958
6 changed files with 36 additions and 21 deletions

View File

@ -11,7 +11,7 @@ class Cfg3DEN {
expression = QUOTE(if (!_value) then {_this setVariable [ARR_3('%s',_value,true)]}); expression = QUOTE(if (!_value) then {_this setVariable [ARR_3('%s',_value,true)]});
typeName = "BOOL"; typeName = "BOOL";
condition = "objectVehicle"; condition = "objectVehicle";
defaultValue = QUOTE((GETMVAR(QGVAR(enable),0)) in [ARR_2(1,2)]); defaultValue = QUOTE(GETMVAR(QGVAR(enable),true)]);
}; };
class GVAR(enableAmmoCookoff) { class GVAR(enableAmmoCookoff) {
property = QGVAR(enableAmmoCookoff); property = QGVAR(enableAmmoCookoff);

View File

@ -27,7 +27,7 @@
*/ */
if (!isServer) exitWith {}; if (!isServer) exitWith {};
if (GVAR(enable) == 0 || {GVAR(cookoffDuration) == 0}) exitWith {}; if (!GVAR(enable) || {GVAR(cookoffDuration) == 0}) exitWith {};
params [ params [
"_vehicle", "_vehicle",
@ -48,14 +48,15 @@ if !(_vehicle isKindOf "AllVehicles") exitWith {};
if (_vehicle isKindOf "CAManBase" || {_vehicle isKindOf "StaticWeapon"}) 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 // Check if cook-off is disabled on vehicle specifically
if !(_vehicle getVariable [QGVAR(enable), true]) exitWith {}; 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_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 {}; if (_vehicle getVariable [QGVAR(isCookingOff), false]) exitWith {};
@ -101,7 +102,14 @@ if (_delayBetweenSmokeAndFire) then {
private _intensity = _vehicle getVariable [QGVAR(intensity), 0]; 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; (_this select 1) call CBA_fnc_removePerFrameHandler;
// Remove effects from JIP // Remove effects from JIP

View File

@ -25,6 +25,15 @@ params ["_object", ["_destroyWhenFinished", false], ["_source", objNull], ["_ins
if (isNull _object) exitWith {}; 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 // Don't have an object detonate its ammo twice
if (_object getVariable [QGVAR(isAmmoDetonating), false]) exitWith {}; if (_object getVariable [QGVAR(isAmmoDetonating), false]) exitWith {};

View File

@ -29,16 +29,14 @@ if (isNull _object) exitWith {};
private _hasFinished = _totalAmmo <= 0 || {_magazines isEqualTo []}; 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 the cook-off has finished or been interrupted, clean up the effects for boxes (no vehicle effects)
if (_hasFinished || if (
{underwater _object} || { _hasFinished ||
if (GVAR(ammoCookoffDuration) == 0) exitWith {true}; {underwater _object} ||
{private _posASL = getPosWorld _object; surfaceIsWater _posASL && {(_posASL select 2) < 0}} || // underwater is not very reliable, so use model center instead
if (_object isKindOf "ReammoBox_F") exitWith { {GVAR(ammoCookoffDuration) == 0} ||
!(GVAR(enableAmmobox) && {_object getVariable [QGVAR(enableAmmoCookoff), true]}) {!([GVAR(enableAmmoCookoff), GVAR(enableAmmobox)] select (_object isKindOf "ReammoBox_F"))} ||
}; {!(_object getVariable [QGVAR(enableAmmoCookoff), true])}
) exitWith {
!(GVAR(enableAmmoCookoff) && {_object getVariable [QGVAR(enableAmmoCookoff), true]})
}) exitWith {
if (_object isKindOf "ReammoBox_F") then { if (_object isKindOf "ReammoBox_F") then {
[QGVAR(cleanupEffects), _object] call CBA_fnc_globalEvent; [QGVAR(cleanupEffects), _object] call CBA_fnc_globalEvent;

View File

@ -1,9 +1,9 @@
[ [
QGVAR(enable), QGVAR(enable),
"LIST", "CHECKBOX",
[LSTRING(enable_name), LSTRING(enable_tooltip)], [LSTRING(enable_name), LSTRING(enable_tooltip)],
LSTRING(category_displayName), LSTRING(category_displayName),
[[0, 1, 2], ["STR_A3_OPTIONS_DISABLED", ELSTRING(common,playerOnly), ELSTRING(common,playersAndAI)], 2], true,
1, 1,
{[QGVAR(enable), _this] call EFUNC(common,cbaSettings_settingChanged)} {[QGVAR(enable), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting; ] call CBA_fnc_addSetting;

View File

@ -17,10 +17,10 @@
<Czech>ACE Vznícení munice</Czech> <Czech>ACE Vznícení munice</Czech>
</Key> </Key>
<Key ID="STR_ACE_CookOff_enable_name"> <Key ID="STR_ACE_CookOff_enable_name">
<English>Enable vehicle cook-off</English> <English>Enable vehicle cook-off effects</English>
</Key> </Key>
<Key ID="STR_ACE_CookOff_enable_tooltip"> <Key ID="STR_ACE_CookOff_enable_tooltip">
<English>Enables vehicle cook-off effects (fire and sound).</English> <English>Enables vehicle cook-off effects (fire and fire sound, but doesn't include ammunition detonations).</English>
</Key> </Key>
<Key ID="STR_ACE_CookOff_enableBoxCookoff_name"> <Key ID="STR_ACE_CookOff_enableBoxCookoff_name">
<English>Enable ammo box cook-off</English> <English>Enable ammo box cook-off</English>