2016-07-14 14:16:53 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
[QGVAR(cookOffBoxLocal), LINKFUNC(cookOffBoxLocal)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cookOffLocal), LINKFUNC(cookOffLocal)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(engineFireLocal), LINKFUNC(engineFireLocal)] call CBA_fnc_addEventHandler;
|
2024-03-28 18:57:23 +00:00
|
|
|
[QGVAR(smoke), LINKFUNC(smoke)] call CBA_fnc_addEventHandler;
|
2024-02-04 09:36:59 +00:00
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
if (isServer) then {
|
|
|
|
[QGVAR(cookOffBoxServer), LINKFUNC(cookOffBoxServer)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cookOffServer), LINKFUNC(cookOffServer)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(detonateAmmunitionServer), LINKFUNC(detonateAmmunitionServer)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(engineFireServer), LINKFUNC(engineFireServer)] call CBA_fnc_addEventHandler;
|
|
|
|
};
|
2024-02-04 09:36:59 +00:00
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
// Handle cleaning up effects when objects are deleted mid cook-off
|
|
|
|
["AllVehicles", "Deleted", {
|
|
|
|
{
|
|
|
|
deleteVehicle _x;
|
|
|
|
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
|
|
|
|
}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
|
2024-02-04 09:36:59 +00:00
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
["ReammoBox_F", "Deleted", {
|
|
|
|
{
|
|
|
|
deleteVehicle _x;
|
|
|
|
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
|
|
|
|
}, true, [], true] call CBA_fnc_addClassEventHandler;
|
2022-07-15 14:59:49 +00:00
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
// Raised when the flames have subsided or after the ammo of a box has finished cooking off
|
2021-10-14 15:49:27 +00:00
|
|
|
[QGVAR(cleanupEffects), {
|
2024-06-20 05:04:34 +00:00
|
|
|
params ["_object"];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
{
|
|
|
|
deleteVehicle _x;
|
|
|
|
} forEach (_object getVariable [QGVAR(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
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
// Ammo box damage handling
|
2016-10-06 20:37:38 +00:00
|
|
|
["ReammoBox_F", "init", {
|
2024-06-20 05:04:34 +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)}];
|
|
|
|
}, true, [], true] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
|
|
|
// Vehicle ammo cook-off (secondary explosions)
|
|
|
|
["AllVehicles", "Killed", {
|
|
|
|
if (!GVAR(enableAmmoCookoff) || {GVAR(ammoCookoffDuration) == 0}) exitWith {};
|
2016-10-06 20:37:38 +00:00
|
|
|
|
2021-02-23 17:42:15 +00:00
|
|
|
params ["_vehicle", "", "", "_useEffects"];
|
2024-06-20 05:04:34 +00:00
|
|
|
|
|
|
|
if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then {
|
|
|
|
// We don't need to pass source and instigator, as vehicle is already dead
|
|
|
|
[QGVAR(detonateAmmunitionServer), [
|
|
|
|
_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;
|
2016-08-13 10:12:34 +00:00
|
|
|
};
|
2024-06-20 05:04:34 +00:00
|
|
|
}, true, ["CAManBase", "StaticWeapon"], true] 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]);
|
|
|
|
|
2024-06-20 05:04:34 +00:00
|
|
|
TRACE_2("",_object,_sound);
|
2024-02-04 09:36:59 +00:00
|
|
|
|
|
|
|
// 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
|
2024-06-20 05:04:34 +00:00
|
|
|
playSound3D [_sound, objNull, false, getPosASL _object, _volume, _pitch + (random 0.2) - 0.1, _maxDistance, 0, true];
|
2024-02-04 09:36:59 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
};
|