mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1839 from acemod/hearingUnification
Hearing PFEH unification / Flashbangs
This commit is contained in:
commit
55614b9ac3
@ -40,7 +40,7 @@ _affected = _grenade nearEntities ["CAManBase", 20];
|
||||
[_unit, false] call EFUNC(common,disableAI);
|
||||
};
|
||||
_unit setSkill (skill _unit * 50);
|
||||
}, [_x], (7 * _strength), 0.1] call EFUNC(common,waitAndExecute); //0.1 precision is fine for AI
|
||||
}, [_x], (7 * _strength)] call EFUNC(common,waitAndExecute);
|
||||
} else {
|
||||
//Do effects for player
|
||||
// is there line of sight to the grenade?
|
||||
@ -62,7 +62,7 @@ _affected = _grenade nearEntities ["CAManBase", 20];
|
||||
|
||||
//Add ace_hearing ear ringing sound effect
|
||||
if ((isClass (configFile >> "CfgPatches" >> "ACE_Hearing")) && {_strength > 0}) then {
|
||||
[_x, 0.5 + (_strength / 2)] call EFUNC(hearing,earRinging);
|
||||
[_x, (20 * _strength)] call EFUNC(hearing,earRinging);
|
||||
};
|
||||
|
||||
// account for people looking away by slightly
|
||||
@ -95,7 +95,7 @@ _affected = _grenade nearEntities ["CAManBase", 20];
|
||||
[{
|
||||
PARAMS_1(_light);
|
||||
deleteVehicle _light;
|
||||
}, [_light], 0.1, 0] call EFUNC(common,waitAndExecute);
|
||||
}, [_light], 0.1] call EFUNC(common,waitAndExecute);
|
||||
|
||||
// blind player
|
||||
if (_strength > 0.1) then {
|
||||
@ -113,7 +113,7 @@ _affected = _grenade nearEntities ["CAManBase", 20];
|
||||
//FULLRECOVERY - end effect
|
||||
[{
|
||||
GVAR(flashbangPPEffectCC) ppEffectEnable false;
|
||||
}, [], (17 * _strength), 0] call EFUNC(common,waitAndExecute);
|
||||
}, [], (17 * _strength)] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
GVAR(currentDeafness) = 0;
|
||||
GVAR(newStrength) = 0;
|
||||
GVAR(deafnessDV) = 0;
|
||||
GVAR(deafnessPrior) = 0;
|
||||
GVAR(volume) = 1;
|
||||
GVAR(playerVehAttenuation) = 1;
|
||||
|
||||
GVAR(beep) = false;
|
||||
@ -11,10 +12,11 @@ GVAR(beep2) = false;
|
||||
GVAR(time2) = 0;
|
||||
GVAR(time3) = 0;
|
||||
GVAR(time4) = 0;
|
||||
GVAR(earRingingPFH) = -1;
|
||||
|
||||
// Spawn volume updating process
|
||||
[FUNC(updateVolume), 0.1, [] ] call CBA_fnc_addPerFrameHandler;
|
||||
["SettingsInitialized", {
|
||||
// Spawn volume updating process
|
||||
[FUNC(updateVolume), 1, [false] ] call CBA_fnc_addPerFrameHandler;
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
//Update veh attunation when player veh changes
|
||||
["playerVehicleChanged", {_this call FUNC(updatePlayerVehAttenuation);}] call EFUNC(common,addEventHandler);
|
||||
@ -22,14 +24,13 @@ GVAR(earRingingPFH) = -1;
|
||||
|
||||
//Reset deafness on respawn (or remote control player switch)
|
||||
["playerChanged", {
|
||||
ACE_player setVariable [QGVAR(dv), 0];
|
||||
ACE_player setVariable [QGVAR(prior), 0];
|
||||
GVAR(deafnessDV) = 0;
|
||||
GVAR(deafnessPrior) = 0;
|
||||
ACE_player setvariable [QGVAR(deaf), false];
|
||||
|
||||
GVAR(beep) = false;
|
||||
GVAR(beep2) = false;
|
||||
GVAR(time2) = 0;
|
||||
GVAR(time3) = 0;
|
||||
GVAR(time4) = 0;
|
||||
GVAR(currentDeafness) = 0;
|
||||
GVAR(newStrength) = 0;
|
||||
}] call EFUNC(common,addEventhandler);
|
||||
|
@ -16,11 +16,9 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (GVAR(DisableEarRinging)) exitWith {};
|
||||
|
||||
PARAMS_2(_unit,_strength);
|
||||
|
||||
if (isNull _unit) exitWith {};
|
||||
if (_unit != ACE_player) exitWith {};
|
||||
if (_strength < 0.05) exitWith {};
|
||||
|
||||
if (_unit getVariable ["ACE_hasEarPlugsin", false]) then {
|
||||
@ -36,66 +34,4 @@ if(headgear _unit != "") then {
|
||||
};
|
||||
};
|
||||
|
||||
_unit setVariable [QGVAR(dv), (_unit getVariable [QGVAR(dv), 0]) + _strength];
|
||||
|
||||
if (GVAR(earRingingPFH) != -1) exitWith {};
|
||||
|
||||
GVAR(earRingingPFH) = [{
|
||||
EXPLODE_1_PVT(_this select 0,_unit);
|
||||
private ["_prior"];
|
||||
_prior = (_unit getvariable [QGVAR(dv), 0]) min 20;
|
||||
|
||||
if (!alive _unit || _prior <= 0 || GVAR(DisableEarRinging)) exitWith {
|
||||
_unit setVariable [QGVAR(dv), 0];
|
||||
_unit setVariable [QGVAR(prior), 0];
|
||||
GVAR(beep) = false;
|
||||
GVAR(beep2) = false;
|
||||
GVAR(time2) = 0;
|
||||
GVAR(time3) = 0;
|
||||
GVAR(time4) = 0;
|
||||
GVAR(earRingingPFH) = -1;
|
||||
[_this select 1] call cba_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
if (((_unit getvariable [QGVAR(dv), 0]) - (_unit getvariable [QGVAR(prior), 0])) > 2) then {
|
||||
if (ACE_time > GVAR(time3)) then {
|
||||
GVAR(beep2) = false;
|
||||
};
|
||||
if (!GVAR(beep2)) then {
|
||||
playSound "ACE_Combat_Deafness";
|
||||
GVAR(beep2) = true;
|
||||
GVAR(time3) = ACE_time + 5;
|
||||
};
|
||||
};
|
||||
|
||||
_unit setvariable [QGVAR(prior), _prior];
|
||||
GVAR(volume) = (1 - (_prior / 20)) max 0;
|
||||
|
||||
if (_prior > 19.75) then {
|
||||
_unit setvariable [QGVAR(deaf), true];
|
||||
} else {
|
||||
_unit setvariable [QGVAR(deaf), false];
|
||||
};
|
||||
|
||||
if ((_unit getvariable [QGVAR(deaf), false]) && {ACE_time > GVAR(time4)}) then {
|
||||
playSound "ACE_Combat_Deafness";
|
||||
GVAR(beep2) = true;
|
||||
GVAR(time3) = ACE_time + 10;
|
||||
GVAR(time4) = ACE_time + 30;
|
||||
};
|
||||
|
||||
// Hearing takes longer to return to normal after it hits rock bottom
|
||||
_unit setvariable [QGVAR(dv), _prior - (0.5 * (GVAR(volume) max 0.1))];
|
||||
|
||||
if (_prior > 10) then {
|
||||
//check if the ringing is already being played
|
||||
if (ACE_time > GVAR(time2)) then {
|
||||
GVAR(beep) = false;
|
||||
};
|
||||
if (!GVAR(beep)) then {
|
||||
playSound "ACE_Ring_Backblast";
|
||||
GVAR(time2) = ACE_time + 22;
|
||||
GVAR(beep) = true;
|
||||
};
|
||||
};
|
||||
}, 1, [_unit]] call CBA_fnc_addPerFrameHandler;
|
||||
GVAR(deafnessDV) = GVAR(deafnessDV) + _strength;
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
//Only run if deafness or ear ringing is enabled:
|
||||
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
|
||||
|
||||
PARAMS_2(_unit,_damage);
|
||||
|
||||
private ["_strength"];
|
||||
|
@ -21,17 +21,18 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_muzzles", "_weaponMagazines", "_muzzleMagazines", "_ammoType", "_initSpeed", "_ammoConfig", "_caliber", "_parentClasses"];
|
||||
//Only run if deafness or ear ringing is enabled:
|
||||
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
|
||||
|
||||
PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo);
|
||||
|
||||
//Only run if combatDeafness enabled:
|
||||
if (!GVAR(enableCombatDeafness)) exitWith {};
|
||||
//Only run if firedNear object is player or player's vehicle:
|
||||
if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {};
|
||||
if (_weapon in ["Throw", "Put"]) exitWith {};
|
||||
if (_distance > 50) exitWith {};
|
||||
|
||||
private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_muzzles", "_weaponMagazines", "_muzzleMagazines", "_ammoType", "_initSpeed", "_ammoConfig", "_caliber", "_parentClasses"];
|
||||
|
||||
_vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)};
|
||||
|
||||
_distance = 1 max _distance;
|
||||
@ -67,7 +68,7 @@ if (count _weaponMagazines == 0) then {
|
||||
|
||||
_magazine = "";
|
||||
{
|
||||
EXPLODE_2_PVT(_x,_magazineType,_ammoType)
|
||||
EXPLODE_2_PVT(_x,_magazineType,_ammoType);
|
||||
if (_ammoType == _ammo) exitWith {
|
||||
_magazine = _magazineType;
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
* Initializes the Map module.
|
||||
* Initializes the Hearing module.
|
||||
*
|
||||
* Arguments:
|
||||
* Whatever the module provides. (I dunno.)
|
||||
@ -16,4 +16,4 @@ if !(_activated) exitWith {};
|
||||
|
||||
[_logic, QGVAR(enableCombatDeafness), "EnableCombatDeafness"] call EFUNC(common,readSettingFromModule);
|
||||
|
||||
diag_log text "[ACE]: Interaction Module Initialized.";
|
||||
diag_log text "[ACE]: Hearing Module Initialized.";
|
||||
|
@ -24,5 +24,8 @@ _player setVariable ["ACE_hasEarPlugsIn", true, true];
|
||||
|
||||
[localize LSTRING(EarPlugs_Are_On)] call EFUNC(common,displayTextStructured);
|
||||
|
||||
//Force an immediate fast volume update:
|
||||
[[true]] call FUNC(updateVolume);
|
||||
|
||||
/*// No Earplugs in inventory, telling user
|
||||
[localize LSTRING(NoPlugs)] call EFUNC(common,displayTextStructured);*/
|
||||
|
@ -27,3 +27,6 @@ _player addItem "ACE_EarPlugs";
|
||||
_player setVariable ["ACE_hasEarPlugsIn", false, true];
|
||||
|
||||
[localize LSTRING(EarPlugs_Are_Off)] call EFUNC(common,displayTextStructured);
|
||||
|
||||
//Force an immediate fast volume update:
|
||||
[[true]] call FUNC(updateVolume);
|
||||
|
@ -3,7 +3,8 @@
|
||||
* Updates and applys the current deafness. Called every 0.1 sec from a PFEH.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
* 0: Args <ARRAY>
|
||||
* -----0: Just update volume (skip ringing/recovery) <BOOL><OPTIONAL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -15,31 +16,62 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_recoverRate", "_volume"];
|
||||
//Only run if deafness or ear ringing is enabled:
|
||||
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
|
||||
|
||||
// Exit if combat deafness is disabled
|
||||
if !(GVAR(enableCombatDeafness)) exitWith {};
|
||||
EXPLODE_1_PVT((_this select 0),_justUpdateVolume);
|
||||
|
||||
// Check if new noises increase deafness
|
||||
GVAR(newStrength) = (((ACE_player getvariable [QGVAR(dv), 0]) min 20) / 20) ^ 2;
|
||||
if (GVAR(newStrength) > GVAR(currentDeafness)) then {
|
||||
GVAR(currentDeafness) = GVAR(newStrength);
|
||||
};
|
||||
private["_volume", "_soundTransitionTime"];
|
||||
|
||||
// Recover rate is slower if deafness is severe
|
||||
_recoverRate = 0.01;
|
||||
if (GVAR(currentDeafness) > 0.7) then {
|
||||
_recoverRate = 0.005;
|
||||
if (GVAR(currentDeafness) > 0.9) then {
|
||||
_recoverRate = 0.002;
|
||||
GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0;
|
||||
GVAR(volume) = (1 - (GVAR(deafnessDV) / 20)) max 0;
|
||||
|
||||
if (!_justUpdateVolume) then {
|
||||
//If we got a big increase in the last second:
|
||||
if ((GVAR(deafnessDV) - GVAR(deafnessPrior)) > 2) then {
|
||||
if (ACE_time > GVAR(time3)) then {
|
||||
GVAR(beep2) = false;
|
||||
};
|
||||
if ((!GVAR(DisableEarRinging)) && {!GVAR(beep2)}) then {
|
||||
playSound "ACE_Combat_Deafness";
|
||||
GVAR(beep2) = true;
|
||||
GVAR(time3) = ACE_time + 5;
|
||||
};
|
||||
};
|
||||
|
||||
GVAR(deafnessPrior) = GVAR(deafnessDV);
|
||||
|
||||
if (GVAR(deafnessDV) > 19.75) then {
|
||||
ACE_player setvariable [QGVAR(deaf), true];
|
||||
if ((!GVAR(DisableEarRinging)) && {ACE_time > GVAR(time4)}) then {
|
||||
playSound "ACE_Combat_Deafness";
|
||||
GVAR(beep2) = true;
|
||||
GVAR(time3) = ACE_time + 10;
|
||||
GVAR(time4) = ACE_time + 30;
|
||||
};
|
||||
} else {
|
||||
ACE_player setvariable [QGVAR(deaf), false];
|
||||
};
|
||||
|
||||
if (GVAR(deafnessDV) > 10) then {
|
||||
//check if the ringing is already being played
|
||||
if (ACE_time > GVAR(time2)) then {
|
||||
GVAR(beep) = false;
|
||||
};
|
||||
if ((!GVAR(DisableEarRinging)) && {!GVAR(beep)}) then {
|
||||
playSound "ACE_Ring_Backblast";
|
||||
GVAR(time2) = ACE_time + 22;
|
||||
GVAR(beep) = true;
|
||||
};
|
||||
};
|
||||
|
||||
// Hearing takes longer to return to normal after it hits rock bottom
|
||||
GVAR(deafnessDV) = (GVAR(deafnessDV) - (0.5 * (GVAR(volume) max 0.1))) max 0;
|
||||
};
|
||||
|
||||
// Deafness recovers with ACE_time
|
||||
GVAR(currentDeafness) = GVAR(currentDeafness) - _recoverRate max 0;
|
||||
if ((missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) || {!GVAR(enableCombatDeafness)}) exitWith {};
|
||||
|
||||
// needed until Bohemia fixes playSound to actually use the second argument
|
||||
_volume = (1 - GVAR(currentDeafness) max 0)^2 max 0.04;
|
||||
_volume = GVAR(volume);
|
||||
|
||||
// Earplugs reduce hearing 50%
|
||||
if ([ACE_player] call FUNC(hasEarPlugsIn)) then {
|
||||
@ -60,11 +92,9 @@ if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
|
||||
_volume = _volume min GVAR(UnconsciousnessVolume);
|
||||
};
|
||||
|
||||
if (!(missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false])) then {
|
||||
0.1 fadeSound _volume;
|
||||
0.1 fadeSpeech _volume;
|
||||
ACE_player setVariable ["tf_globalVolume", _volume];
|
||||
if (!isNil "acre_api_fnc_setGlobalVolume") then {[_volume^(0.33)] call acre_api_fnc_setGlobalVolume;};
|
||||
};
|
||||
_soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1};
|
||||
|
||||
//hintSilent format ["GVAR(currentDeafness), _Volume = %1, %2", GVAR(currentDeafness), _volume];
|
||||
_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;};
|
||||
|
@ -1,6 +1,8 @@
|
||||
#define COMPONENT hearing
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
|
||||
#ifdef DEBUG_ENABLED_HEARING
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user