mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
36442d34cd
* Cookoff: Added handling for cleaning up smoke effects when vehicle is deleted mid-cookoff * Cookoff - Prevent effects cleanup Deleted EH from getting duplicated * Cookoff - Added locality safety check to effects cleanup * Cookoff - Global effects cleanup is now triggered by the server to handle locality transfer
59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
[QGVAR(engineFire), FUNC(engineFire)] call CBA_fnc_addEventHandler;
|
|
[QGVAR(cookOff), {
|
|
params ["_vehicle"];
|
|
if (local _vehicle) then {
|
|
_this call FUNC(cookOff);
|
|
};
|
|
}] 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;
|
|
|
|
// handle cleaning up effects when vehicle is deleted mid-cookoff
|
|
[QGVAR(addCleanupHandlers), {
|
|
params ["_vehicle"];
|
|
|
|
// 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"];
|
|
|
|
[QGVAR(cleanupEffects), [_vehicle]] call CBA_fnc_globalEvent;
|
|
}];
|
|
|
|
_vehicle setVariable [QGVAR(deletedEH), _deletedEH];
|
|
};
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cleanupEffects), {
|
|
params ["_vehicle", ["_effects", []]];
|
|
|
|
_effects = _effects + (_vehicle getVariable [QGVAR(effects), []]);
|
|
if (_effects isNotEqualTo []) then {
|
|
{ deleteVehicle _x } count _effects;
|
|
};
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
["ReammoBox_F", "init", {
|
|
(_this select 0) addEventHandler ["HandleDamage", {
|
|
if ((_this select 0) getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmobox)]) then {
|
|
_this call FUNC(handleDamageBox);
|
|
};
|
|
}];
|
|
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
// secondary explosions
|
|
["AllVehicles", "killed", {
|
|
params ["_vehicle", "", "", "_useEffects"];
|
|
if (
|
|
_useEffects &&
|
|
_vehicle getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmoCookoff)]
|
|
) then {
|
|
if (GVAR(ammoCookoffDuration) == 0) exitWith {};
|
|
([_vehicle] call FUNC(getVehicleAmmo)) params ["_mags", "_total"];
|
|
[_vehicle, _mags, _total] call FUNC(detonateAmmunition);
|
|
};
|
|
}, nil, ["Man","StaticWeapon"]] call CBA_fnc_addClassEventHandler;
|