2016-07-14 14:16:53 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
[QGVAR(engineFire), FUNC(engineFire)] call CBA_fnc_addEventHandler;
|
2021-10-14 15:49:27 +00:00
|
|
|
[QGVAR(cookOff), {
|
2016-08-23 07:57:54 +00:00
|
|
|
params ["_vehicle"];
|
2021-10-14 15:49:27 +00:00
|
|
|
if (local _vehicle) then {
|
|
|
|
_this call FUNC(cookOff);
|
2016-08-23 07:57:54 +00:00
|
|
|
};
|
2021-10-14 15:49:27 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cookOffEffect), FUNC(cookOffEffect)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(smoke), FUNC(smoke)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cookOffBox), FUNC(cookOffBox)] call CBA_fnc_addEventHandler;
|
2016-08-23 07:57:54 +00:00
|
|
|
|
2022-07-15 14:59:49 +00:00
|
|
|
// handle cleaning up effects when vehicle is deleted mid-cookoff
|
|
|
|
[QGVAR(addCleanupHandlers), {
|
|
|
|
params ["_vehicle"];
|
2024-02-04 09:36:59 +00:00
|
|
|
|
2022-07-15 14:59:49 +00:00
|
|
|
// Don't add a new EH if cookoff is run multiple times
|
|
|
|
if ((_vehicle getVariable [QGVAR(deletedEH), -1]) == -1) then {
|
|
|
|
private _deletedEH = _vehicle addEventHandler ["Deleted", {
|
|
|
|
params ["_vehicle"];
|
2024-02-04 09:36:59 +00:00
|
|
|
|
2022-08-20 21:38:06 +00:00
|
|
|
[QGVAR(cleanupEffects), [_vehicle]] call CBA_fnc_localEvent;
|
2022-07-15 14:59:49 +00:00
|
|
|
}];
|
2024-02-04 09:36:59 +00:00
|
|
|
|
2022-07-15 14:59:49 +00:00
|
|
|
_vehicle setVariable [QGVAR(deletedEH), _deletedEH];
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
[QGVAR(cleanupEffects), {
|
|
|
|
params ["_vehicle", ["_effects", []]];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2021-10-14 15:49:27 +00:00
|
|
|
_effects = _effects + (_vehicle getVariable [QGVAR(effects), []]);
|
2021-12-18 23:15:32 +00:00
|
|
|
if (_effects isNotEqualTo []) then {
|
2021-10-14 15:49:27 +00:00
|
|
|
{ deleteVehicle _x } count _effects;
|
2016-10-28 20:10:40 +00:00
|
|
|
};
|
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", {
|
|
|
|
(_this select 0) addEventHandler ["HandleDamage", {
|
2017-12-06 19:13:10 +00:00
|
|
|
if ((_this select 0) getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmobox)]) then {
|
2021-10-17 20:01:41 +00:00
|
|
|
_this call FUNC(handleDamageBox);
|
2016-10-06 20:37:38 +00:00
|
|
|
};
|
|
|
|
}];
|
|
|
|
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
2016-07-14 14:16:53 +00:00
|
|
|
// secondary explosions
|
2016-08-13 10:12:34 +00:00
|
|
|
["AllVehicles", "killed", {
|
2021-02-23 17:42:15 +00:00
|
|
|
params ["_vehicle", "", "", "_useEffects"];
|
|
|
|
if (
|
|
|
|
_useEffects &&
|
|
|
|
_vehicle getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmoCookoff)]
|
|
|
|
) then {
|
2017-01-23 18:13:02 +00:00
|
|
|
if (GVAR(ammoCookoffDuration) == 0) exitWith {};
|
2017-01-04 21:35:54 +00:00
|
|
|
([_vehicle] call FUNC(getVehicleAmmo)) params ["_mags", "_total"];
|
2022-08-20 21:36:37 +00:00
|
|
|
|
|
|
|
private _delay = (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY;
|
|
|
|
[FUNC(detonateAmmunition), [_vehicle, _mags, _total], _delay] call CBA_fnc_waitAndExecute;
|
2016-08-13 10:12:34 +00:00
|
|
|
};
|
2016-10-06 20:37:38 +00:00
|
|
|
}, nil, ["Man","StaticWeapon"]] call CBA_fnc_addClassEventHandler;
|
2024-02-04 09:36:59 +00:00
|
|
|
|
|
|
|
if (hasInterface) then {
|
|
|
|
// Plays a sound locally, so that different sounds can be used for various distances
|
|
|
|
[QGVAR(playCookoffSound), {
|
|
|
|
params ["_object", "_sound"];
|
|
|
|
|
|
|
|
if (isNull _object) exitWith {};
|
|
|
|
|
|
|
|
private _distance = _object distance (positionCameraToWorld [0, 0, 0]);
|
|
|
|
|
|
|
|
TRACE_3("",_object,_sound,_maxDistance);
|
|
|
|
|
|
|
|
// 3 classes of distances: close, mid and far, each having different sound files
|
|
|
|
private _classDistance = switch (true) do {
|
|
|
|
case (_distance < DISTANCE_CLOSE): {"close"};
|
|
|
|
case (_distance < DISTANCE_MID): {"mid"};
|
|
|
|
default {"far"};
|
|
|
|
};
|
|
|
|
|
|
|
|
_sound = format [QGVAR(%1_%2_%3), _sound, _classDistance, floor (random 3) + 1];
|
|
|
|
|
|
|
|
TRACE_1("",_sound);
|
|
|
|
|
|
|
|
// Allows other mods to change sounds for cook-off
|
|
|
|
_sound = getArray (configFile >> "CfgSounds" >> _sound >> "sound");
|
|
|
|
|
|
|
|
if (_sound isEqualTo []) exitWith {};
|
|
|
|
|
|
|
|
_sound params ["_sound", "_volume", "_pitch", "_maxDistance"];
|
|
|
|
|
|
|
|
if (_distance > _maxDistance) exitWith {};
|
|
|
|
|
|
|
|
// Make sure file exists, so RPT isn't spammed with non-existent entry errors
|
|
|
|
if (!fileExists _sound) exitWith {};
|
|
|
|
|
|
|
|
// Obeys speed of sound and takes doppler effects into account
|
|
|
|
playSound3D [_sound, objNull, insideBuilding _object >= 0.5, getPosASL _object, _volume, _pitch + (random 0.2) - 0.1, _maxDistance, 0, true];
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
};
|