2015-01-14 02:00:48 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2024-04-28 16:02:50 +00:00
|
|
|
if (isServer) then {
|
|
|
|
["CBA_settingsInitialized", {
|
2024-05-29 17:01:39 +00:00
|
|
|
TRACE_1("settingInit - server",GVAR(enableCombatDeafness));
|
|
|
|
|
2024-04-28 16:02:50 +00:00
|
|
|
// Only install event handler if combat deafness is enabled
|
2024-05-29 17:01:39 +00:00
|
|
|
if (!GVAR(enableCombatDeafness)) exitWith {};
|
2024-04-28 16:02:50 +00:00
|
|
|
|
|
|
|
["CAManBase", "Init", LINKFUNC(addEarPlugs), true, [], true] call CBA_fnc_addClassEventHandler;
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
};
|
|
|
|
|
2024-08-14 21:30:13 +00:00
|
|
|
["CBA_settingsInitialized", {
|
|
|
|
TRACE_1("settingInit - common",GVAR(enableCombatDeafness));
|
|
|
|
// Only install event handler if combat deafness is enabled
|
|
|
|
if (!GVAR(enableCombatDeafness)) exitWith {};
|
|
|
|
|
2024-08-22 18:38:42 +00:00
|
|
|
[{ // Convert ace_common's local explosion to a hearing global explosion event
|
|
|
|
TRACE_1("Explode",_this);
|
|
|
|
[QGVAR(explosion), _this select [0,2]] call CBA_fnc_globalEvent; // trim unused 3rd arg for network savings
|
|
|
|
}] call EFUNC(common,addExplosionEventHandler);
|
2024-08-14 21:30:13 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
2015-04-11 04:51:07 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
2024-02-28 19:44:27 +00:00
|
|
|
#include "initKeybinds.inc.sqf"
|
|
|
|
|
2024-05-24 23:05:19 +00:00
|
|
|
GVAR(cacheAmmoLoudness) = createHashMap;
|
2016-01-10 00:51:41 +00:00
|
|
|
|
2015-07-11 02:01:32 +00:00
|
|
|
GVAR(deafnessDV) = 0;
|
|
|
|
GVAR(deafnessPrior) = 0;
|
2015-07-12 02:00:40 +00:00
|
|
|
GVAR(volume) = 1;
|
2015-04-20 07:17:47 +00:00
|
|
|
GVAR(playerVehAttenuation) = 1;
|
2015-06-13 15:16:18 +00:00
|
|
|
GVAR(time3) = 0;
|
2016-02-17 00:17:42 +00:00
|
|
|
GVAR(damageCoefficent) = 1;
|
2016-02-18 16:48:40 +00:00
|
|
|
GVAR(volumeAttenuation) = 1;
|
2017-01-09 18:10:52 +00:00
|
|
|
GVAR(lastPlayerVehicle) = objNull;
|
2015-06-13 15:16:18 +00:00
|
|
|
|
2021-10-11 20:48:30 +00:00
|
|
|
["CBA_settingsInitialized", {
|
2024-08-14 21:30:13 +00:00
|
|
|
TRACE_1("settingInit - client",GVAR(enableCombatDeafness));
|
2024-05-29 17:01:39 +00:00
|
|
|
|
2016-02-17 00:17:42 +00:00
|
|
|
// Only run PFEH and install event handlers if combat deafness is enabled
|
2024-05-29 17:01:39 +00:00
|
|
|
if (!GVAR(enableCombatDeafness)) exitWith {};
|
2016-02-16 18:58:42 +00:00
|
|
|
|
2015-07-11 02:01:32 +00:00
|
|
|
// Spawn volume updating process
|
2024-05-29 17:01:39 +00:00
|
|
|
[LINKFUNC(updateVolume), 1, false] call CBA_fnc_addPerFrameHandler;
|
2015-04-11 04:21:54 +00:00
|
|
|
|
2024-08-12 13:45:03 +00:00
|
|
|
[QGVAR(explosion), LINKFUNC(explosion)] call CBA_fnc_addEventHandler;
|
2024-03-21 19:26:46 +00:00
|
|
|
[QGVAR(updateVolume), LINKFUNC(updateVolume)] call CBA_fnc_addEventHandler;
|
|
|
|
|
2016-02-18 16:48:40 +00:00
|
|
|
// Update veh attunation when player veh changes
|
2017-01-09 18:10:52 +00:00
|
|
|
["vehicle", {
|
|
|
|
params ["_player", "_vehicle"];
|
2024-05-29 17:01:39 +00:00
|
|
|
|
2017-01-09 18:10:52 +00:00
|
|
|
TRACE_2("vehicle change",_player,_vehicle);
|
|
|
|
_this call FUNC(updatePlayerVehAttenuation);
|
|
|
|
|
|
|
|
if (!isNull GVAR(lastPlayerVehicle)) then {
|
|
|
|
private _firedEH = GVAR(lastPlayerVehicle) getVariable [QGVAR(firedEH), -1];
|
|
|
|
GVAR(lastPlayerVehicle) removeEventHandler ["FiredNear", _firedEH];
|
|
|
|
GVAR(lastPlayerVehicle) setVariable [QGVAR(firedEH), nil];
|
|
|
|
GVAR(lastPlayerVehicle) = objNull;
|
|
|
|
TRACE_2("removed veh eh",_firedEH,GVAR(lastPlayerVehicle));
|
|
|
|
};
|
2024-05-29 17:01:39 +00:00
|
|
|
|
2017-01-09 18:10:52 +00:00
|
|
|
if ((!isNull _vehicle) && {_player != _vehicle}) then {
|
2017-02-14 16:54:37 +00:00
|
|
|
private _firedEH = _vehicle addEventHandler ["FiredNear", {call FUNC(firedNear)}];
|
2017-01-09 18:10:52 +00:00
|
|
|
_vehicle setVariable [QGVAR(firedEH), _firedEH];
|
|
|
|
GVAR(lastPlayerVehicle) = _vehicle;
|
|
|
|
TRACE_2("added veh eh",_firedEH,GVAR(lastPlayerVehicle));
|
|
|
|
};
|
|
|
|
}, true] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
|
2024-05-29 17:01:39 +00:00
|
|
|
["turret", LINKFUNC(updatePlayerVehAttenuation), false] call CBA_fnc_addPlayerEventHandler;
|
2016-02-17 00:17:42 +00:00
|
|
|
|
2016-02-18 16:48:40 +00:00
|
|
|
// Reset deafness on respawn (or remote control player switch)
|
2016-06-21 23:39:20 +00:00
|
|
|
["unit", {
|
2017-01-09 18:10:52 +00:00
|
|
|
params ["_player", "_oldPlayer"];
|
|
|
|
TRACE_2("unit change",_player,_oldPlayer);
|
2017-04-11 15:06:29 +00:00
|
|
|
|
2017-01-09 18:10:52 +00:00
|
|
|
if (!isNull _oldPlayer) then {
|
|
|
|
private _firedEH = _oldPlayer getVariable [QGVAR(firedEH), -1];
|
|
|
|
_oldPlayer removeEventHandler ["FiredNear", _firedEH];
|
|
|
|
_oldPlayer setVariable [QGVAR(firedEH), nil];
|
2024-08-12 13:45:03 +00:00
|
|
|
TRACE_2("removed unit eh",_oldPlayer,_firedEH);
|
2017-01-09 18:10:52 +00:00
|
|
|
};
|
|
|
|
// Don't add a new EH if the unit respawned
|
|
|
|
if ((_player getVariable [QGVAR(firedEH), -1]) == -1) then {
|
2021-02-18 18:58:08 +00:00
|
|
|
if ((getNumber (configOf _player >> "isPlayableLogic")) == 1) exitWith {
|
2017-04-11 15:06:29 +00:00
|
|
|
TRACE_1("skipping playable logic",typeOf _player); // VirtualMan_F (placeable logic zeus / spectator)
|
|
|
|
};
|
2024-05-29 17:01:39 +00:00
|
|
|
|
2017-02-14 16:54:37 +00:00
|
|
|
private _firedEH = _player addEventHandler ["FiredNear", {call FUNC(firedNear)}];
|
2017-01-09 18:10:52 +00:00
|
|
|
_player setVariable [QGVAR(firedEH), _firedEH];
|
2024-08-12 13:45:03 +00:00
|
|
|
TRACE_2("added unit eh",_player,_firedEH);
|
2017-01-09 18:10:52 +00:00
|
|
|
};
|
|
|
|
|
2016-02-17 00:17:42 +00:00
|
|
|
GVAR(deafnessDV) = 0;
|
|
|
|
GVAR(deafnessPrior) = 0;
|
|
|
|
GVAR(time3) = 0;
|
2024-05-29 17:01:39 +00:00
|
|
|
|
|
|
|
call FUNC(updateHearingProtection);
|
2017-01-09 18:10:52 +00:00
|
|
|
}, true] call CBA_fnc_addPlayerEventHandler;
|
2016-02-17 00:17:42 +00:00
|
|
|
|
2016-02-18 16:48:40 +00:00
|
|
|
// Update protection on possible helmet change
|
2017-01-09 18:10:52 +00:00
|
|
|
["loadout", LINKFUNC(updateHearingProtection), false] call CBA_fnc_addPlayerEventHandler;
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|