diff --git a/addons/hearing/CfgEventHandlers.hpp b/addons/hearing/CfgEventHandlers.hpp index 9f0acc6c7c..1fe2508fef 100644 --- a/addons/hearing/CfgEventHandlers.hpp +++ b/addons/hearing/CfgEventHandlers.hpp @@ -33,4 +33,4 @@ class Extended_Explosion_EventHandlers { clientExplosion = QUOTE( if (_this select 0 == ACE_player) then {_this call FUNC(explosionNear)}; ); }; }; -}; \ No newline at end of file +}; diff --git a/addons/hearing/functions/fnc_addEarPlugs.sqf b/addons/hearing/functions/fnc_addEarPlugs.sqf index 9253717c11..7cd4661c0f 100644 --- a/addons/hearing/functions/fnc_addEarPlugs.sqf +++ b/addons/hearing/functions/fnc_addEarPlugs.sqf @@ -1,13 +1,17 @@ /* * Author: commy2 - * * Called on unit initialization. Adds earplugs if the unit is equipped with either a really loud primary weapon or a rocket launcher. * - * Argument: - * 0: A Soldier (Object) + * Arguments: + * 0: A Soldier * - * Return value: - * Nothing + * Return Value: + * None + * + * Example: + * [guy] call ace_hearing_fnc_addEarPlugs + * + * Public: No */ #include "script_component.hpp" @@ -19,7 +23,7 @@ _unit = _this select 0; _launcher = secondaryWeapon _unit; if (_launcher != "") exitWith { - _unit addItem "ACE_EarBuds"; + _unit addItem "ACE_EarBuds"; }; // otherwise add earplugs if the soldier has a big rifle @@ -32,5 +36,5 @@ if (isNil "_magazine") exitWith {}; _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo"); if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "audiblefire") > 8) then { - _unit addItem "ACE_EarBuds"; + _unit addItem "ACE_EarBuds"; }; diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index 4581a6fdd9..2460e0fd5c 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -1,13 +1,18 @@ /* * Author: KoffeinFlummi, commy2 - * * Creates ear ringing effect with set strength. * * Arguments: - * 0: strength of ear ringing (Number between 0 and 1) + * 0: Unit (player) + * 1: strength of ear ringing (Number between 0 and 1) * * Return Value: - * none + * None + * + * Example: + * [clientExplosionEvent] call ace_hearing_fnc_earRinging + * + * Public: No */ #include "script_component.hpp" @@ -17,7 +22,7 @@ _unit = _this select 0; _strength = _this select 1; if (_unit getVariable ["ACE_hasEarPlugsin", false]) then { - _strength = _strength / 4; + _strength = _strength / 4; }; GVAR(newStrength) = GVAR(newStrength) max _strength; @@ -28,24 +33,24 @@ if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith { if (GVAR(DisableEarRinging)) exitWith {}; if (_strength > 0.75) exitWith { - playSound "ACE_EarRinging_Heavy"; - GVAR(isEarRingingPlaying) = true; - [ + playSound "ACE_EarRinging_Heavy"; + GVAR(isEarRingingPlaying) = true; + [ {GVAR(isEarRingingPlaying) = false;}, [], 7.0, 0.25 - ] call EFUNC(common,waitAndExecute); + ] call EFUNC(common,waitAndExecute); }; if (_strength > 0.5) exitWith { - playSound "ACE_EarRinging_Medium"; - GVAR(isEarRingingPlaying) = true; - [ + playSound "ACE_EarRinging_Medium"; + GVAR(isEarRingingPlaying) = true; + [ {GVAR(isEarRingingPlaying) = false;}, [], 5.0, 0.25 - ] call EFUNC(common,waitAndExecute); + ] call EFUNC(common,waitAndExecute); }; if (_strength > 0.2) exitWith { - playSound "ACE_EarRinging_Weak"; - GVAR(isEarRingingPlaying) = true; + playSound "ACE_EarRinging_Weak"; GVAR(isEarRingingPlaying) = true; - [ + GVAR(isEarRingingPlaying) = true; + [ {GVAR(isEarRingingPlaying) = false;}, [], 3.0, 0.25 - ] call EFUNC(common,waitAndExecute); + ] call EFUNC(common,waitAndExecute); }; diff --git a/addons/hearing/functions/fnc_explosionNear.sqf b/addons/hearing/functions/fnc_explosionNear.sqf index 8c7b477da0..418916cc8e 100644 --- a/addons/hearing/functions/fnc_explosionNear.sqf +++ b/addons/hearing/functions/fnc_explosionNear.sqf @@ -1,13 +1,18 @@ /* * Author: KoffeinFlummi, commy2 - * * Handles deafness due to explosions going off near the player. * * Arguments: - * -> Explosion Event Handler + * 0: vehicle - Object the event handler is assigned to (player) + * 1: damage - Damage inflicted to the object * * Return Value: - * none + * None + * + * Example: + * [clientExplosionEvent] call ace_hearing_fnc_explosionNear + * + * Public: No */ #include "script_component.hpp" @@ -20,6 +25,6 @@ _strength = (_damage * 2) min 1; if (_strength < 0.01) exitWith {}; [_unit, _strength] spawn { - sleep 0.2; - _this call FUNC(earRinging); + sleep 0.2; + _this call FUNC(earRinging); }; diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index 10e8508617..9b110fbbbb 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -1,13 +1,23 @@ /* * Author: KoffeinFlummi, commy2 - * * Handles deafness due to large-caliber weapons going off near the player. * * Arguments: - * -> FiredNear Event Handler + * 0: Unit - Object the event handler is assigned to + * 1: Firer: Object - Object which fires a weapon near the unit + * 2: Distance - Distance in meters between the unit and firer + * 3: weapon - Fired weapon + * 4: muzzle - Muzzle that was used + * 5: mod - Current mode of the fired weapon + * 6: ammo - Ammo used * * Return Value: - * none + * None + * + * Example: + * [clientFiredNearEvent] call ace_hearing_fnc_firedNear + * + * Public: No */ #include "script_component.hpp" @@ -25,17 +35,17 @@ if (_weapon in ["Throw", "Put"]) exitWith {}; if (_unit != vehicle _unit && {!([_unit] call EFUNC(common,isTurnedOut))}) exitWith {}; _silencer = switch (_weapon) do { - case (primaryWeapon _unit) : {primaryWeaponItems _unit select 0}; - case (secondaryWeapon _unit) : {secondaryWeaponItems _unit select 0}; - case (handgunWeapon _unit) : {handgunItems _unit select 0}; - default {""}; +case (primaryWeapon _unit) : {primaryWeaponItems _unit select 0}; +case (secondaryWeapon _unit) : {secondaryWeaponItems _unit select 0}; +case (handgunWeapon _unit) : {handgunItems _unit select 0}; + default {""}; }; _audibleFireCoef = 1; //_audibleFireTimeCoef = 1; if (_silencer != "") then { - _audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire"); - //_audibleFireTimeCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFireTime"); + _audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire"); + //_audibleFireTimeCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFireTime"); }; _audibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFire"); @@ -47,6 +57,6 @@ _strength = _loudness - (_loudness/50 * _distance); // linear drop off if (_strength < 0.01) exitWith {}; [_unit, _strength] spawn { - sleep 0.2; - _this call FUNC(earRinging); + sleep 0.2; + _this call FUNC(earRinging); }; diff --git a/addons/hearing/functions/fnc_hasEarPlugsIn.sqf b/addons/hearing/functions/fnc_hasEarPlugsIn.sqf index 8fcfe1eeb1..58dc302888 100644 --- a/addons/hearing/functions/fnc_hasEarPlugsIn.sqf +++ b/addons/hearing/functions/fnc_hasEarPlugsIn.sqf @@ -1,18 +1,20 @@ /* * Author: commy2 - * * Check if the unit has earplugs put in. * - * Argument: - * A soldier (Object) + * Arguments: + * 0:Unit (player) * - * Return value: - * Boolean (Bool) + * Return Value: + * Have Earplugs in + * + * Example: + * [ace_player] call ace_hearing_fnc_hasEarPlugsIn + * + * Public: No */ #include "script_component.hpp" -private "_unit"; - -_unit = _this select 0; +PARAMS_1(_unit); _unit getVariable ["ACE_hasEarPlugsin", false] diff --git a/addons/hearing/functions/fnc_putInEarplugs.sqf b/addons/hearing/functions/fnc_putInEarplugs.sqf index 767ec9c698..d5e3867a76 100644 --- a/addons/hearing/functions/fnc_putInEarplugs.sqf +++ b/addons/hearing/functions/fnc_putInEarplugs.sqf @@ -1,20 +1,21 @@ /* - * Author: Hope Johnson - * Edited by commy2 - * - * Puts in / takes out earplugs. + * Author: Hope Johnson and commy2 + * Puts in earplugs. * * Arguments: - * none + * 0:Unit (player) * * Return Value: - * none + * None + * + * Example: + * [ace_player] call ace_hearing_fnc_putInEarplugs + * + * Public: No */ #include "script_component.hpp" -private "_player"; - -_player = _this select 0; +PARAMS_1(_player); // Buds in inventory, putting them in _player removeItem "ACE_EarBuds"; diff --git a/addons/hearing/functions/fnc_removeEarplugs.sqf b/addons/hearing/functions/fnc_removeEarplugs.sqf index 9436807a46..a762f06b47 100644 --- a/addons/hearing/functions/fnc_removeEarplugs.sqf +++ b/addons/hearing/functions/fnc_removeEarplugs.sqf @@ -1,23 +1,24 @@ /* - * Author: Hope Johnson - * Edited by commy2 - * - * Puts in / takes out earplugs. + * Author: Hope Johnson and commy2 + * Takes out earplugs. * * Arguments: - * none + * 0:Unit (player) * * Return Value: - * none + * None + * + * Example: + * [ace_player] call ace_hearing_fnc_removeEarplugs + * + * Public: No */ #include "script_component.hpp" -private "_player"; - -_player = _this select 0; +PARAMS_1(_player); if !(_player canAdd "ACE_EarBuds") exitWith { // inventory full - [localize "STR_ACE_Hearing_Inventory_Full"] call EFUNC(common,displayTextStructured); + [localize "STR_ACE_Hearing_Inventory_Full"] call EFUNC(common,displayTextStructured); }; // Buds already in and removing them. diff --git a/addons/hearing/functions/fnc_updateVolume.sqf b/addons/hearing/functions/fnc_updateVolume.sqf index 187d4ce116..34ea959f39 100644 --- a/addons/hearing/functions/fnc_updateVolume.sqf +++ b/addons/hearing/functions/fnc_updateVolume.sqf @@ -1,4 +1,18 @@ -// by commy2 and CAA-Picard +/* + * Author: commy2 and CAA-Picard + * Updates and applys the current deafness. Called every 0.1 sec from a PFEH. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_hearing_fnc_updateVolume + * + * Public: No + */ #include "script_component.hpp" #define STRENGHTODEAFNESS 3 @@ -6,17 +20,17 @@ // Check if new noises increase deafness if (GVAR(newStrength) * STRENGHTODEAFNESS > GVAR(currentDeafness)) then { - GVAR(currentDeafness) = GVAR(newStrength) * STRENGHTODEAFNESS min MAXDEAFNESS; + GVAR(currentDeafness) = GVAR(newStrength) * STRENGHTODEAFNESS min MAXDEAFNESS; }; GVAR(newStrength) = 0; // 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; - }; + _recoverRate = 0.005; + if (GVAR(currentDeafness) > 0.9) then { + _recoverRate = 0.002; + }; }; // Deafness recovers with time @@ -27,19 +41,19 @@ _volume = (1 - GVAR(currentDeafness) max 0)^2 max 0.04; // Earplugs reduce hearing 50% if ([ACE_player] call FUNC(hasEarPlugsIn)) then { - _volume = _volume min 0.5; + _volume = _volume min 0.5; }; // Reduce volume if player is unconscious if (ACE_player getVariable ["ACE_isUnconscious", false]) then { - _volume = _volume min 0.4; + _volume = _volume min 0.4; }; if (!(missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false])) then { - 0.1 fadeSound _volume; - 0.1 fadeSpeech _volume; - ACE_player setVariable ["tf_globalVolume", _volume]; - ACE_player setVariable ["acre_sys_core_globalVolume", _volume]; + 0.1 fadeSound _volume; + 0.1 fadeSpeech _volume; + ACE_player setVariable ["tf_globalVolume", _volume]; + ACE_player setVariable ["acre_sys_core_globalVolume", _volume]; }; //hintSilent format ["GVAR(currentDeafness), _Volume = %1, %2", GVAR(currentDeafness), _volume];