2016-07-14 14:16:53 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2024-01-27 08:14:10 +00:00
|
|
|
[QGVAR(cookOff), LINKFUNC(cookOff)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cookOffBoxLocal), LINKFUNC(cookOffBoxLocal)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cookOffEffect), LINKFUNC(cookOffEffect)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(engineFireLocal), LINKFUNC(engineFireLocal)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(smoke), LINKFUNC(smoke)] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
if (isServer) then {
|
|
|
|
[QGVAR(cookOffBox), LINKFUNC(cookOffBox)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(engineFire), LINKFUNC(engineFire)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(detonateAmmunition), LINKFUNC(detonateAmmunition)] call CBA_fnc_addEventHandler;
|
|
|
|
};
|
2016-08-23 07:57:54 +00:00
|
|
|
|
2024-01-27 08:14:10 +00:00
|
|
|
// Handle cleaning up effects when vehicle is deleted mid cook-off
|
2022-07-15 14:59:49 +00:00
|
|
|
[QGVAR(addCleanupHandlers), {
|
2024-01-27 08:14:10 +00:00
|
|
|
// No effects on machines without interfaces
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
|
|
|
params ["_object"];
|
|
|
|
|
|
|
|
// Don't add a new EH if cook-off is run multiple times
|
|
|
|
if (!isNil {_object getVariable QGVAR(deletedEH)}) exitWith {};
|
|
|
|
|
|
|
|
_object setVariable [QGVAR(deletedEH),
|
|
|
|
_object addEventHandler ["Deleted", {
|
|
|
|
[QGVAR(cleanupEffects), _this select 0] call CBA_fnc_localEvent;
|
|
|
|
}]
|
|
|
|
];
|
2022-07-15 14:59:49 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
[QGVAR(cleanupEffects), {
|
2024-01-27 08:14:10 +00:00
|
|
|
params ["_object", ["_effects", []]];
|
|
|
|
|
|
|
|
if (isServer) then {
|
|
|
|
// Reset, so that object can cook-off again
|
|
|
|
_object setVariable [QGVAR(isCookingOff), nil, true];
|
|
|
|
|
|
|
|
// Remove effects from JIP
|
|
|
|
private _jipID = _object getVariable QGVAR(jipID);
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2024-01-27 08:14:10 +00:00
|
|
|
if (isNil "_jipID") exitWith {};
|
|
|
|
|
|
|
|
_jipID call CBA_fnc_removeGlobalEventJIP;
|
|
|
|
|
|
|
|
_object setVariable [QGVAR(jipID), nil];
|
2016-10-28 20:10:40 +00:00
|
|
|
};
|
2024-01-27 08:14:10 +00:00
|
|
|
|
|
|
|
// No effects on machines without interfaces
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
|
|
|
// All effects are local
|
|
|
|
_effects append (_object getVariable [QGVAR(effects), []]);
|
|
|
|
|
|
|
|
if (_effects isEqualTo []) exitWith {};
|
|
|
|
|
|
|
|
{
|
|
|
|
deleteVehicle _x;
|
|
|
|
} forEach _effects;
|
|
|
|
|
|
|
|
_object setVariable [QGVAR(effects), nil];
|
2021-10-14 15:49:27 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
2016-10-28 20:10:40 +00:00
|
|
|
|
2016-10-06 20:37:38 +00:00
|
|
|
["ReammoBox_F", "init", {
|
2024-01-27 08:14:10 +00:00
|
|
|
// 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)}];
|
2016-10-06 20:37:38 +00:00
|
|
|
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
2024-01-27 08:14:10 +00:00
|
|
|
// Secondary explosions
|
|
|
|
["AllVehicles", "Killed", {
|
|
|
|
if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
|
|
|
|
|
2021-02-23 17:42:15 +00:00
|
|
|
params ["_vehicle", "", "", "_useEffects"];
|
2024-01-27 08:14:10 +00:00
|
|
|
|
|
|
|
if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then {
|
|
|
|
(_vehicle call FUNC(getVehicleAmmo)) params ["_magazines", "_total"];
|
2022-08-20 21:36:37 +00:00
|
|
|
|
|
|
|
private _delay = (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY;
|
2024-01-27 08:14:10 +00:00
|
|
|
[QGVAR(detonateAmmunition), [_vehicle, _magazines, _total, false, objNull, objNull, _delay]] call CBA_fnc_serverEvent;
|
2016-08-13 10:12:34 +00:00
|
|
|
};
|
2024-01-27 08:14:10 +00:00
|
|
|
}, nil, ["CAManBase", "StaticWeapon"]] call CBA_fnc_addClassEventHandler;
|