Files
MissionTemplate/framework/emp/functions/fn_init.sqf
2024-02-09 21:37:59 -08:00

68 lines
2.0 KiB
Plaintext

#include "..\script_component.hpp"
GVAR(maxBrightDelay) = 3.25;
GVAR(zapSounds) = [QGVAR(sound_zap1),QGVAR(sound_zap2),QGVAR(sound_zap3),QGVAR(sound_zap4)];
// call FUNC(addACEActions);
[QGVAR(event_empDeployed), {
params ["_origin", "_affectedObjects", "_affectedGroups"];
if (hasInterface) then {
[_origin] call FUNC(playLocalEffects);
[{
private _countLocalObjectEffectsPlayed = { // play effects on this machine
[_x] call FUNC(playLocalEffectsForObject);
true;
} count _affectedObjects;
[
LEVEL_DEBUG,
QUOTE(COMPONENT),
"Played EMP effects",
[
["localObjectEffectsPlayed", _countLocalObjectEffectsPlayed]
]
] call EFUNC(common,log);
}, _this, GVAR(maxBrightDelay)] call CBA_fnc_waitAndExecute;
};
// one second after peak brightness
[{
private _countLocalObjectEffectsApplied = { // apply affects to objects owned by this machine, start propagation to other machines
[_x] call FUNC(applyLocalObjectEffects);
true;
} count (_affectedObjects select {local _x});
private _countLocalGroupEffectsApplied = { // apply affects to groups owned by this machine, start propagation to other machines
[_x] call FUNC(applyLocalGroupEffects);
true;
} count (_affectedGroups select {local _x});
if (isServer) then {
private _countServerObjectEffectsApplied = {
[_x] call FUNC(applyServerObjectEffects);
true;
} count _affectedObjects;
};
private _countGlobalObjectEffectsApplied = {
[_x] call FUNC(applyGlobalObjectEffects);
true;
} count _affectedObjects;
[
LEVEL_DEBUG,
QUOTE(COMPONENT),
"Applied EMP effects",
[
["localObjectEffects", _countLocalObjectEffectsApplied],
["localGroupEffects", _countLocalGroupEffectsApplied],
["serverObjectEffects", _countServerObjectEffectsApplied],
["globalObjectEffects", _countGlobalObjectEffectsApplied]
]
] call EFUNC(common,log);
}, _this, GVAR(maxBrightDelay) + 2] call CBA_fnc_waitAndExecute;
}] call CBA_fnc_addEventHandler;