mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1609 from acemod/ace2EarRinging
Ported the ACE2 ear ringing logic
This commit is contained in:
commit
c3340b174e
@ -11,4 +11,12 @@ class CfgSounds {
|
|||||||
sound[] = {QUOTE(PATHTOF(sounds\ACE_earringing_heavy.wav)),8,1.7};
|
sound[] = {QUOTE(PATHTOF(sounds\ACE_earringing_heavy.wav)),8,1.7};
|
||||||
titles[] = {};
|
titles[] = {};
|
||||||
};
|
};
|
||||||
|
class ACE_Combat_Deafness {
|
||||||
|
sound[] = {QUOTE(PATHTOF(sounds\deafness.ogg)),3,1};
|
||||||
|
titles[] = {};
|
||||||
|
};
|
||||||
|
class ACE_Ring_Backblast {
|
||||||
|
sound[] = {QUOTE(PATHTOF(sounds\backblast_ring.ogg)),1,1};
|
||||||
|
titles[] = {};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,13 @@ GVAR(currentDeafness) = 0;
|
|||||||
GVAR(newStrength) = 0;
|
GVAR(newStrength) = 0;
|
||||||
GVAR(playerVehAttenuation) = 1;
|
GVAR(playerVehAttenuation) = 1;
|
||||||
|
|
||||||
|
GVAR(beep) = false;
|
||||||
|
GVAR(beep2) = false;
|
||||||
|
GVAR(time2) = 0;
|
||||||
|
GVAR(time3) = 0;
|
||||||
|
GVAR(time4) = 0;
|
||||||
|
GVAR(earRingingPFH) = -1;
|
||||||
|
|
||||||
// Spawn volume updating process
|
// Spawn volume updating process
|
||||||
[FUNC(updateVolume), 0.1, [] ] call CBA_fnc_addPerFrameHandler;
|
[FUNC(updateVolume), 0.1, [] ] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
@ -15,6 +22,14 @@ GVAR(playerVehAttenuation) = 1;
|
|||||||
|
|
||||||
//Reset deafness on respawn (or remote control player switch)
|
//Reset deafness on respawn (or remote control player switch)
|
||||||
["playerChanged", {
|
["playerChanged", {
|
||||||
|
ACE_player setVariable [QGVAR(dv), 0];
|
||||||
|
ACE_player setVariable [QGVAR(prior), 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(currentDeafness) = 0;
|
||||||
GVAR(newStrength) = 0;
|
GVAR(newStrength) = 0;
|
||||||
}] call EFUNC(common,addEventhandler);
|
}] call EFUNC(common,addEventhandler);
|
||||||
|
@ -6,7 +6,7 @@ class CfgPatches {
|
|||||||
weapons[] = {"ACE_EarPlugs"};
|
weapons[] = {"ACE_EarPlugs"};
|
||||||
requiredVersion = REQUIRED_VERSION;
|
requiredVersion = REQUIRED_VERSION;
|
||||||
requiredAddons[] = {"ace_interaction"};
|
requiredAddons[] = {"ace_interaction"};
|
||||||
author[] = {"KoffeinFlummi", "esteldunedain", "HopeJ", "commy2"};
|
author[] = {"KoffeinFlummi", "esteldunedain", "HopeJ", "commy2", "Rocko", "Rommel", "Ruthberg"};
|
||||||
authorUrl = "https://github.com/KoffeinFlummi/";
|
authorUrl = "https://github.com/KoffeinFlummi/";
|
||||||
VERSION_CONFIG;
|
VERSION_CONFIG;
|
||||||
};
|
};
|
||||||
|
@ -1,56 +1,92 @@
|
|||||||
/*
|
/*
|
||||||
* Author: KoffeinFlummi, commy2
|
* Author: KoffeinFlummi, commy2, Rocko, Rommel, Ruthberg
|
||||||
* Creates ear ringing effect with set strength.
|
* Ear ringing PFH
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Unit (player) <OBJECT>
|
* 0: unit <OBJECT>
|
||||||
* 1: strength of ear ringing (Number between 0 and 1) <NUMBER>
|
* 1: strength of ear ringing (Number between 0 and 1) <NUMBER>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [clientExplosionEvent] call ace_hearing_fnc_earRinging
|
* [_unit, _strength] call ace_hearing_fnc_earRinging
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_strength"];
|
if (GVAR(DisableEarRinging)) exitWith {};
|
||||||
|
|
||||||
_unit = _this select 0;
|
PARAMS_2(_unit,_strength);
|
||||||
_strength = _this select 1;
|
|
||||||
|
if (isNull _unit) exitWith {};
|
||||||
|
if (_strength < 0.05) exitWith {};
|
||||||
|
|
||||||
if (_unit getVariable ["ACE_hasEarPlugsin", false]) then {
|
if (_unit getVariable ["ACE_hasEarPlugsin", false]) then {
|
||||||
_strength = _strength / 4;
|
_strength = _strength / 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
GVAR(newStrength) = GVAR(newStrength) max _strength;
|
_unit setVariable [QGVAR(dv), (_unit getVariable [QGVAR(dv), 0]) + _strength];
|
||||||
|
|
||||||
if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith {};
|
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 (GVAR(DisableEarRinging)) exitWith {};
|
if (!alive _unit || _prior <= 0) 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 (_strength > 0.75) exitWith {
|
if (((_unit getvariable [QGVAR(dv), 0]) - (_unit getvariable [QGVAR(prior), 0])) > 2) then {
|
||||||
playSound "ACE_EarRinging_Heavy";
|
if (ACE_time > GVAR(time3)) then {
|
||||||
GVAR(isEarRingingPlaying) = true;
|
GVAR(beep2) = false;
|
||||||
[
|
};
|
||||||
{GVAR(isEarRingingPlaying) = false;}, [], 7.0, 0.25
|
if (!GVAR(beep2)) then {
|
||||||
] call EFUNC(common,waitAndExecute);
|
playSound "ACE_Combat_Deafness";
|
||||||
};
|
GVAR(beep2) = true;
|
||||||
if (_strength > 0.5) exitWith {
|
GVAR(time3) = ACE_time + 5;
|
||||||
playSound "ACE_EarRinging_Medium";
|
};
|
||||||
GVAR(isEarRingingPlaying) = true;
|
};
|
||||||
[
|
|
||||||
{GVAR(isEarRingingPlaying) = false;}, [], 5.0, 0.25
|
_unit setvariable [QGVAR(prior), _prior];
|
||||||
] call EFUNC(common,waitAndExecute);
|
GVAR(volume) = (1 - (_prior / 20)) max 0;
|
||||||
};
|
|
||||||
if (_strength > 0.2) exitWith {
|
if (_prior > 19.75) then {
|
||||||
playSound "ACE_EarRinging_Weak";
|
_unit setvariable [QGVAR(deaf), true];
|
||||||
GVAR(isEarRingingPlaying) = true;
|
} else {
|
||||||
GVAR(isEarRingingPlaying) = true;
|
_unit setvariable [QGVAR(deaf), false];
|
||||||
[
|
};
|
||||||
{GVAR(isEarRingingPlaying) = false;}, [], 3.0, 0.25
|
|
||||||
] call EFUNC(common,waitAndExecute);
|
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;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: KoffeinFlummi, commy2
|
* Author: KoffeinFlummi, commy2, Ruthberg
|
||||||
* Handles deafness due to explosions going off near the player.
|
* Handles deafness due to explosions going off near the player.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -16,12 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_damage", "_strength"];
|
PARAMS_2(_unit,_damage);
|
||||||
|
|
||||||
_unit = _this select 0;
|
private ["_strength"];
|
||||||
_damage = _this select 1;
|
_strength = 0 max _damage;
|
||||||
|
|
||||||
_strength = (_damage * 2) min 1;
|
|
||||||
if (_strength < 0.01) exitWith {};
|
if (_strength < 0.01) exitWith {};
|
||||||
|
|
||||||
[{_this call FUNC(earRinging)}, [_unit, _strength], 0.2, 0] call EFUNC(common,waitAndExecute);
|
[{_this call FUNC(earRinging)}, [_unit, _strength], 0.2, 0] call EFUNC(common,waitAndExecute);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_silencer", "_audibleFireCoef", "_audibleFire", "_loudness", "_strength", "_vehAttenuation"];
|
private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_muzzles", "_weaponMagazines", "_muzzleMagazines", "_ammoType", "_initSpeed", "_ammoConfig", "_caliber", "_parentClasses"];
|
||||||
|
|
||||||
PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo);
|
PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo);
|
||||||
|
|
||||||
@ -30,10 +30,11 @@ if (!GVAR(enableCombatDeafness)) exitWith {};
|
|||||||
//Only run if firedNear object is player or player's vehicle:
|
//Only run if firedNear object is player or player's vehicle:
|
||||||
if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {};
|
if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {};
|
||||||
if (_weapon in ["Throw", "Put"]) exitWith {};
|
if (_weapon in ["Throw", "Put"]) exitWith {};
|
||||||
|
if (_distance > 50) exitWith {};
|
||||||
|
|
||||||
_vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)};
|
_vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)};
|
||||||
|
|
||||||
if (_distance < 1) then {_distance = 1;};
|
_distance = 1 max _distance;
|
||||||
|
|
||||||
_silencer = switch (_weapon) do {
|
_silencer = switch (_weapon) do {
|
||||||
case (primaryWeapon _firer) : {(primaryWeaponItems _firer) select 0};
|
case (primaryWeapon _firer) : {(primaryWeaponItems _firer) select 0};
|
||||||
@ -47,10 +48,47 @@ if (_silencer != "") then {
|
|||||||
_audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire");
|
_audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire");
|
||||||
};
|
};
|
||||||
|
|
||||||
_audibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFire");
|
_weaponMagazines = missionNamespace getVariable [format[QEGVAR(common,weaponMagazines_%1),_weapon], []];
|
||||||
|
if (count _weaponMagazines == 0) then {
|
||||||
|
_muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles");
|
||||||
|
_weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
|
||||||
|
{
|
||||||
|
if (_x != "this") then {
|
||||||
|
_muzzleMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines");
|
||||||
|
_weaponMagazines append _muzzleMagazines;
|
||||||
|
};
|
||||||
|
} forEach _muzzles;
|
||||||
|
missionNamespace setVariable [format[QEGVAR(common,weaponMagazines_%1),_weapon], _weaponMagazines];
|
||||||
|
};
|
||||||
|
|
||||||
_loudness = _audibleFireCoef * _audibleFire / 64;
|
_magazine = "";
|
||||||
_strength = _vehAttenuation * (_loudness - (_loudness/50 * _distance)); // linear drop off
|
{
|
||||||
|
_ammoType = getText(configFile >> "CfgMagazines" >> _x >> "ammo");
|
||||||
|
if (_ammoType == _ammo) exitWith {
|
||||||
|
_magazine = _x;
|
||||||
|
};
|
||||||
|
} forEach _weaponMagazines;
|
||||||
|
|
||||||
|
if (_magazine == "") exitWith {};
|
||||||
|
|
||||||
|
_initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
|
||||||
|
_ammoConfig = (configFile >> "CfgAmmo" >> _ammo);
|
||||||
|
_parentClasses = [_ammoConfig, true] call BIS_fnc_returnParents;
|
||||||
|
_caliber = getNumber(_ammoConfig >> "ACE_caliber");
|
||||||
|
_caliber = switch (true) do {
|
||||||
|
case ("ShellBase" in _parentClasses): { 80 };
|
||||||
|
case ("RocketBase" in _parentClasses): { 200 };
|
||||||
|
case ("MissileBase" in _parentClasses): { 600 };
|
||||||
|
case ("SubmunitionBase" in _parentClasses): { 80 };
|
||||||
|
default {
|
||||||
|
if (_caliber <= 0) then { 6.5 } else { _caliber };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) * _audibleFireCoef / 5;
|
||||||
|
_strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance)); // linear drop off
|
||||||
|
|
||||||
|
//systemChat format["%1 : %2 : %3", _strength, _initSpeed, _parentClasses];
|
||||||
|
//systemChat format["%1 : %2 : %3", _weapon, _magazine, _initSpeed];
|
||||||
|
|
||||||
if (_strength < 0.01) exitWith {};
|
if (_strength < 0.01) exitWith {};
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_effectType", "_newAttenuation", "_turretConfig", "_turretPath", "_vehicle"];
|
||||||
|
|
||||||
_vehicle = vehicle ACE_player;
|
_vehicle = vehicle ACE_player;
|
||||||
|
|
||||||
if (isNull _vehicle) exitWith {};
|
if (isNull _vehicle) exitWith {};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: commy2 and esteldunedain
|
* Author: commy2 and esteldunedain and Ruthberg
|
||||||
* Updates and applys the current deafness. Called every 0.1 sec from a PFEH.
|
* Updates and applys the current deafness. Called every 0.1 sec from a PFEH.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -15,19 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
#define STRENGHTODEAFNESS 3
|
|
||||||
#define MAXDEAFNESS 1.1
|
|
||||||
|
|
||||||
private ["_recoverRate", "_volume"];
|
private ["_recoverRate", "_volume"];
|
||||||
|
|
||||||
// Exit if combat deafness is disabled
|
// Exit if combat deafness is disabled
|
||||||
if !(GVAR(enableCombatDeafness)) exitWith {};
|
if !(GVAR(enableCombatDeafness)) exitWith {};
|
||||||
|
|
||||||
// Check if new noises increase deafness
|
// Check if new noises increase deafness
|
||||||
if (GVAR(newStrength) * STRENGHTODEAFNESS > GVAR(currentDeafness)) then {
|
GVAR(newStrength) = (((ACE_player getvariable [QGVAR(dv), 0]) min 20) / 20) ^ 2;
|
||||||
GVAR(currentDeafness) = GVAR(newStrength) * STRENGHTODEAFNESS min MAXDEAFNESS;
|
if (GVAR(newStrength) > GVAR(currentDeafness)) then {
|
||||||
|
GVAR(currentDeafness) = GVAR(newStrength);
|
||||||
};
|
};
|
||||||
GVAR(newStrength) = 0;
|
|
||||||
|
|
||||||
// Recover rate is slower if deafness is severe
|
// Recover rate is slower if deafness is severe
|
||||||
_recoverRate = 0.01;
|
_recoverRate = 0.01;
|
||||||
|
BIN
addons/hearing/sounds/backblast_ring.ogg
Normal file
BIN
addons/hearing/sounds/backblast_ring.ogg
Normal file
Binary file not shown.
BIN
addons/hearing/sounds/deafness.ogg
Normal file
BIN
addons/hearing/sounds/deafness.ogg
Normal file
Binary file not shown.
BIN
addons/hearing/sounds/flashbang_ring.ogg
Normal file
BIN
addons/hearing/sounds/flashbang_ring.ogg
Normal file
Binary file not shown.
BIN
addons/hearing/sounds/muzzleblast_ring1.ogg
Normal file
BIN
addons/hearing/sounds/muzzleblast_ring1.ogg
Normal file
Binary file not shown.
BIN
addons/hearing/sounds/muzzleblast_ring2.ogg
Normal file
BIN
addons/hearing/sounds/muzzleblast_ring2.ogg
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user