Hearing - New XEH, Fix dead effects, Medical var (#3802)

* Hearing - New XEH, Fix dead effects, Medical var

* Use setHearingCapability

* Cleanup dead player vol update

* Don't change global hearing in medical

* Fix exitWith
This commit is contained in:
PabstMirror 2016-05-20 11:23:14 -05:00
parent f67b3561e8
commit f69142dd45
8 changed files with 39 additions and 62 deletions

View File

@ -46,6 +46,8 @@ if (isServer) then {
GVAR(statusEffect_Names) = [];
GVAR(statusEffect_isGlobal) = [];
GVAR(setHearingCapabilityMap) = [];
//////////////////////////////////////////////////
// Set up PlayerChanged eventhandler for pre init (EH is installed in postInit)
//////////////////////////////////////////////////

View File

@ -5,48 +5,44 @@
* Arguments:
* 0: id <STRING>
* 1: settings <NUMBER>
* 2: add (default: true) <BOOL>
* 2: add [true] OR remove [false] (default: true) <BOOL>
*
* Return Value:
* None
*
* Public: Yes
* Example:
* ["earwax", 0.5, true] call ace_common_fnc_setHearingCapability
*
* Note: uses player
* Public: Yes
*/
#include "script_component.hpp"
params ["_id", "_settings", ["_add", true]];
private _map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]];
params ["_id", "_setting", ["_add", true]];
private _exists = false;
{
if (_id == _x select 0) exitWith {
_exists = true;
if (_add) then {
_x set [1, _settings];
} else {
_map set [_forEachIndex, 0];
_map = _map - [0];
};
};
} forEach _map;
if (!_exists && _add) then {
_map pushBack [_id, _settings];
};
missionNamespace setVariable [QGVAR(setHearingCapabilityMap), _map];
// find lowest volume
private _lowestVolume = 1;
{
_lowestVolume = (_x select 1) min _lowestVolume;
GVAR(setHearingCapabilityMap) = GVAR(setHearingCapabilityMap) select {
_x params ["_xID", "_xSetting"];
if (_id == _xID) then {
_exists = true;
if (_add) then {
_x set [1, _setting];
_lowestVolume = _lowestVolume min _setting;
true
} else {
false
} count _map;
};
} else {
_lowestVolume = _lowestVolume min _xSetting;
true
};
};
if (!_exists && _add) then {
_lowestVolume = _lowestVolume min _setting;
GVAR(setHearingCapabilityMap) pushBack [_id, _setting];
};
// in game sounds
0 fadeSound _lowestVolume;

View File

@ -25,22 +25,6 @@ class Extended_Init_EventHandlers {
};
};
class Extended_FiredNear_EventHandlers {
class AllVehicles {
class GVAR(FiredNear) {
clientFiredNear = QUOTE(_this call FUNC(firedNear););
};
};
};
class Extended_Explosion_EventHandlers {
class CAManBase {
class GVAR(ExplosionNear) {
clientExplosion = QUOTE(_this call FUNC(explosionNear););
};
};
};
class Extended_Respawn_EventHandlers {
class CAManBase {
class ADDON {

View File

@ -17,6 +17,10 @@ GVAR(volumeAttenuation) = 1;
// Only run PFEH and install event handlers if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};
//Add XEH:
["CAManBase", "FiredNear", FUNC(firedNear)] call CBA_fnc_addClassEventHandler;
["CAManBase", "Explosion", FUNC(explosionNear)] call CBA_fnc_addClassEventHandler;
// Update hearing protection now:
[] call FUNC(updateHearingProtection);

View File

@ -16,9 +16,6 @@
*/
#include "script_component.hpp"
// Only run if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};
params ["_unit", "_damage"];
if (_unit != ACE_player) exitWith {};

View File

@ -22,9 +22,6 @@
*/
#include "script_component.hpp"
// Only run if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};
params ["_object", "_firer", "_distance", "_weapon", "", "", "_ammo"];
//Only run if firedNear object is player or player's vehicle:

View File

@ -16,6 +16,12 @@
*/
#include "script_component.hpp"
if (!alive ACE_player) exitWith {
if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
TRACE_1("dead - removing hearing effects",ACE_player);
[QUOTE(ADDON), 1, true] call EFUNC(common,setHearingCapability);
};
(_this select 0) params ["_justUpdateVolume"];
GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0;
@ -54,9 +60,4 @@ if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
_volume = _volume min GVAR(UnconsciousnessVolume);
};
private _soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1};
_soundTransitionTime fadeSound _volume;
_soundTransitionTime fadeSpeech _volume;
ACE_player setVariable ["tf_globalVolume", _volume];
if (!isNil "acre_api_fnc_setGlobalVolume") then {[_volume^(0.33)] call acre_api_fnc_setGlobalVolume;};
[QUOTE(ADDON), _volume, true] call EFUNC(common,setHearingCapability);

View File

@ -37,19 +37,15 @@ if (isServer) then {["placedInBodyBag", FUNC(serverRemoveBody)] call EFUNC(commo
params ["_unit", "_status"];
if (local _unit) then {
if (_status) then {
_unit setVariable ["tf_globalVolume", 0.4];
_unit setVariable ["tf_voiceVolume", 0, true];
_unit setVariable ["tf_unable_to_use_radio", true, true];
_unit setVariable ["acre_sys_core_isDisabled", true, true];
if (!isNil "acre_api_fnc_setGlobalVolume") then { [0.4^0.33] call acre_api_fnc_setGlobalVolume; };
} else {
_unit setVariable ["tf_globalVolume", 1];
_unit setVariable ["tf_voiceVolume", 1, true];
_unit setVariable ["tf_unable_to_use_radio", false, true];
_unit setVariable ["acre_sys_core_isDisabled", false, true];
if (!isNil "acre_api_fnc_setGlobalVolume") then { [1] call acre_api_fnc_setGlobalVolume; };
};
};
}] call EFUNC(common,addEventHandler);