diff --git a/addons/cookoff/XEH_postInit.sqf b/addons/cookoff/XEH_postInit.sqf index a0da68bfb9..ce4dac75db 100644 --- a/addons/cookoff/XEH_postInit.sqf +++ b/addons/cookoff/XEH_postInit.sqf @@ -17,13 +17,13 @@ if (isServer) then { { deleteVehicle _x; } forEach ((_this select 0) getVariable [QGVAR(vehicleEffects), []]); -}, nil, nil, true] call CBA_fnc_addClassEventHandler; +}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler; ["ReammoBox_F", "Deleted", { { deleteVehicle _x; } forEach ((_this select 0) getVariable [QGVAR(boxEffects), []]); -}, nil, nil, true] call CBA_fnc_addClassEventHandler; +}, true, [], true] call CBA_fnc_addClassEventHandler; [QGVAR(cleanupVehicleEffects), { params ["_object"]; @@ -45,21 +45,29 @@ if (isServer) then { _object setVariable [QGVAR(boxEffects), nil]; }] call CBA_fnc_addEventHandler; +// Ammo box damage handling ["ReammoBox_F", "init", { // Calling this function inside curly brackets allows the usage of "exitWith", which would be broken with "HandleDamage" otherwise (_this select 0) addEventHandler ["HandleDamage", {_this call FUNC(handleDamageBox)}]; -}, nil, nil, true] call CBA_fnc_addClassEventHandler; +}, true, [], true] call CBA_fnc_addClassEventHandler; -// Secondary explosions +// Vehicle ammo cook-off (secondary explosions) ["AllVehicles", "Killed", { if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {}; params ["_vehicle", "", "", "_useEffects"]; if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then { - [QGVAR(detonateAmmunition), [_vehicle, false, objNull, objNull, (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY]] call CBA_fnc_serverEvent; + // We don't need to pass source and instigator, as vehicle is already dead + [QGVAR(detonateAmmunition), [ + _vehicle, + false, + objNull, + objNull, + random [MIN_AMMO_DETONATION_START_DELAY, (MIN_AMMO_DETONATION_START_DELAY + MAX_AMMO_DETONATION_START_DELAY) / 2, MAX_AMMO_DETONATION_START_DELAY] + ] call CBA_fnc_serverEvent; }; -}, nil, ["CAManBase", "StaticWeapon"]] call CBA_fnc_addClassEventHandler; +}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler; if (hasInterface) then { // Plays a sound locally, so that different sounds can be used for various distances diff --git a/addons/cookoff/functions/fnc_cookOff.sqf b/addons/cookoff/functions/fnc_cookOff.sqf index 61a6631a8b..cf6e5db616 100644 --- a/addons/cookoff/functions/fnc_cookOff.sqf +++ b/addons/cookoff/functions/fnc_cookOff.sqf @@ -43,8 +43,11 @@ params [ ["_maxIntensity", MAX_COOKOFF_INTENSITY] ]; +// Make sure it's a vehicle (important, because deleted EH is assigned to AllVehicles only in postInit) if !(_vehicle isKindOf "AllVehicles") exitWith {}; +if (_vehicle isKindOf "CAManBase" || {_vehicle isKindOf "StaticWeapon"}) exitWith {}; + // Check if cook-off is disabled on vehicle specifically if !(_vehicle getVariable [QGVAR(enable), true]) exitWith {}; diff --git a/addons/cookoff/functions/fnc_cookOffBox.sqf b/addons/cookoff/functions/fnc_cookOffBox.sqf index 564762ab87..4fbc6b66b5 100644 --- a/addons/cookoff/functions/fnc_cookOffBox.sqf +++ b/addons/cookoff/functions/fnc_cookOffBox.sqf @@ -18,12 +18,16 @@ */ if (!isServer) exitWith {}; +if (!GVAR(enableAmmobox) || {GVAR(ammoCookoffDuration) == 0}) exitWith {}; params ["_box", ["_source", objNull], ["_instigator", objNull]]; -// Make sure it's a box +// Make sure it's a box (important, because deleted EH is assigned to ReammoBox_F only in postInit) if !(_box isKindOf "ReammoBox_F") exitWith {}; +if !(_box getVariable [QGVAR(enableAmmoCookoff), true]) exitWith {}; + +// Allow only 1 cook-off per box at a time if (_box getVariable [QGVAR(isCookingOff), false]) exitWith {}; _box setVariable [QGVAR(isCookingOff), true, true];