-
Notifications
You must be signed in to change notification settings - Fork 739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ported the ACE2 ear ringing logic #1609
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
833634f
Ported the ACE2 ear ringing logic
ulteq eacd8e5
Removed debug output
ulteq feec8a1
Removed debug output
ulteq db68b6c
Increased loudness of missles and rockets.
ulteq 38dca2b
New loudness calculation for different ammo types
ulteq b6a710d
Implemented a proper magazine lookup routine
ulteq 2509f1d
Missing privates
ulteq d9722db
Abort if distance > 50m
ulteq 6d4f58c
weapon magazines caching
ulteq 3427f65
Removed debug output
ulteq 022f928
Fixed a bug in the caching routine
ulteq badfc40
Reset 'deaf' on respawn
ulteq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,56 +1,92 @@ | ||
/* | ||
* Author: KoffeinFlummi, commy2 | ||
* Creates ear ringing effect with set strength. | ||
* Author: KoffeinFlummi, commy2, Rocko, Rommel, Ruthberg | ||
* Ear ringing PFH | ||
* | ||
* Arguments: | ||
* 0: Unit (player) <OBJECT> | ||
* 0: unit <OBJECT> | ||
* 1: strength of ear ringing (Number between 0 and 1) <NUMBER> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [clientExplosionEvent] call ace_hearing_fnc_earRinging | ||
* [_unit, _strength] call ace_hearing_fnc_earRinging | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
private ["_unit", "_strength"]; | ||
if (GVAR(DisableEarRinging)) exitWith {}; | ||
|
||
PARAMS_2(_unit,_strength); | ||
|
||
_unit = _this select 0; | ||
_strength = _this select 1; | ||
if (isNull _unit) exitWith {}; | ||
if (_strength < 0.05) exitWith {}; | ||
|
||
if (_unit getVariable ["ACE_hasEarPlugsin", false]) then { | ||
_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 (!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 (((_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; | ||
}; | ||
|
||
if (GVAR(DisableEarRinging)) exitWith {}; | ||
|
||
if (_strength > 0.75) exitWith { | ||
playSound "ACE_EarRinging_Heavy"; | ||
GVAR(isEarRingingPlaying) = true; | ||
[ | ||
{GVAR(isEarRingingPlaying) = false;}, [], 7.0, 0.25 | ||
] call EFUNC(common,waitAndExecute); | ||
}; | ||
if (_strength > 0.5) exitWith { | ||
playSound "ACE_EarRinging_Medium"; | ||
GVAR(isEarRingingPlaying) = true; | ||
[ | ||
{GVAR(isEarRingingPlaying) = false;}, [], 5.0, 0.25 | ||
] call EFUNC(common,waitAndExecute); | ||
}; | ||
if (_strength > 0.2) exitWith { | ||
playSound "ACE_EarRinging_Weak"; | ||
GVAR(isEarRingingPlaying) = true; | ||
GVAR(isEarRingingPlaying) = true; | ||
[ | ||
{GVAR(isEarRingingPlaying) = false;}, [], 3.0, 0.25 | ||
] call EFUNC(common,waitAndExecute); | ||
}; | ||
// 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; |
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loudness also needs to take into account the presence of supressors/silencers, which are attachments in A3.