2015-01-14 02:00:48 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-04-11 04:51:07 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
2024-02-28 19:44:27 +00:00
|
|
|
#include "initKeybinds.inc.sqf"
|
|
|
|
|
2016-02-18 16:58:18 +00:00
|
|
|
GVAR(cacheAmmoLoudness) = call CBA_fnc_createNamespace;
|
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", {
|
2016-02-16 18:58:42 +00:00
|
|
|
TRACE_1("settingInit",GVAR(EnableCombatDeafness));
|
2016-02-17 00:17:42 +00:00
|
|
|
// Only run PFEH and install event handlers if combat deafness is enabled
|
2016-02-16 18:58:42 +00:00
|
|
|
if (!GVAR(EnableCombatDeafness)) exitWith {};
|
|
|
|
|
2015-07-11 02:01:32 +00:00
|
|
|
// Spawn volume updating process
|
2017-01-09 18:10:52 +00:00
|
|
|
[LINKFUNC(updateVolume), 1, [false]] call CBA_fnc_addPerFrameHandler;
|
2015-04-11 04:21:54 +00:00
|
|
|
|
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"];
|
|
|
|
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));
|
|
|
|
};
|
|
|
|
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;
|
|
|
|
["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];
|
|
|
|
private _explosionEH = _oldPlayer getVariable [QGVAR(explosionEH), -1];
|
|
|
|
_oldPlayer removeEventHandler ["Explosion", _explosionEH];
|
|
|
|
_oldPlayer setVariable [QGVAR(explosionEH), nil];
|
|
|
|
TRACE_3("removed unit eh",_oldPlayer,_firedEH,_explosionEH);
|
|
|
|
};
|
|
|
|
// 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)
|
|
|
|
};
|
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];
|
2017-02-14 16:54:37 +00:00
|
|
|
private _explosionEH = _player addEventHandler ["Explosion", {call FUNC(explosionNear)}];
|
2017-01-09 18:10:52 +00:00
|
|
|
_player setVariable [QGVAR(explosionEH), _explosionEH];
|
|
|
|
TRACE_3("added unit eh",_player,_firedEH,_explosionEH);
|
|
|
|
};
|
|
|
|
|
2016-02-17 00:17:42 +00:00
|
|
|
GVAR(deafnessDV) = 0;
|
|
|
|
GVAR(deafnessPrior) = 0;
|
|
|
|
GVAR(time3) = 0;
|
|
|
|
[] 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;
|