-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hearing - Fix explosions not affecting hearing (#10002)
* Have explosions affect hearing * Update fnc_explosion.sqf * Update XEH_postInit.sqf * Update addons/hearing/functions/fnc_explosion.sqf Co-authored-by: PabstMirror <[email protected]> * Update fnc_explosion.sqf * Make EH local * Use sound entry instead --------- Co-authored-by: PabstMirror <[email protected]>
- Loading branch information
1 parent
f3938ba
commit 72f230a
Showing
4 changed files
with
70 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: johnb43 | ||
* Handles deafness due to explosions going off near the player. | ||
* | ||
* Arguments: | ||
* 0: Projectile <OBJECT> | ||
* 1: Explosion position ASL <ARRAY> | ||
* 2: Velocity <ARRAY> (unused) | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [_projectile, [0, 0, 0], [0, 0, 0]] call ace_hearing_fnc_explosion | ||
* | ||
* Public: No | ||
*/ | ||
|
||
// Ignore spectators, curators and alike | ||
if ((getNumber (configOf ACE_player >> "isPlayableLogic")) == 1) exitWith {}; | ||
|
||
params ["_projectile", "_pos"]; | ||
|
||
// Don't allow for distances under 1 | ||
private _distance = ((eyePos ACE_player) vectorDistance _pos) max 1; | ||
|
||
// Fast exit if explosion far away | ||
if (_distance > 100) exitWith { | ||
TRACE_1("too far away",_distance); | ||
}; | ||
|
||
private _ammoConfig = configOf _projectile; | ||
private _explosive = getNumber (_ammoConfig >> "explosive"); | ||
|
||
private _vehAttenuation = [GVAR(playerVehAttenuation), 1] select (isNull objectParent ACE_player || {isTurnedOut ACE_player}); | ||
|
||
TRACE_5("",typeOf _projectile,_distance,_explosive,_audibleFire,_vehAttenuation); | ||
|
||
(if (isArray (_ammoConfig >> "soundHit1")) then { | ||
getArray (_ammoConfig >> "soundHit1") | ||
} else { | ||
getArray (_ammoConfig >> "soundHit") | ||
}) params ["", ["_volume", 1], "", ["_maxDistance", 1500]]; | ||
|
||
if (_distance > _maxDistance) exitWith { | ||
TRACE_2("too far away",_distance,_maxDistance); | ||
}; | ||
|
||
private _strength = _vehAttenuation * _explosive * _volume * _maxDistance / _distance^2; | ||
|
||
TRACE_2("strength",_volume,_strength); | ||
|
||
// Call immediately, as it will get picked up later by the update thread anyway | ||
_strength call FUNC(earRinging); |
This file was deleted.
Oops, something went wrong.