forked from acemod/ACE3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hearing - Improve and cleanup code (acemod#9933)
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
109 additions
and
96 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
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,44 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: KoffeinFlummi, commy2, johnb43 | ||
* Get the loudness of ammo. | ||
* However, because `initSpeed` is a magazine attribute, the magazine name needs to be used instead of the ammo. | ||
* | ||
* Arguments: | ||
* 0: Magazine <STRING> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* "30Rnd_65x39_caseless_mag" call ace_hearing_fnc_getAmmoLoudness | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_magazine"]; | ||
|
||
GVAR(cacheAmmoLoudness) getOrDefaultCall [_magazine, { | ||
private _magazineConfig = configFile >> "CfgMagazines" >> _magazine; | ||
private _ammo = getText (_magazineConfig >> "ammo"); | ||
private _initSpeed = getNumber (_magazineConfig >> "initSpeed"); | ||
|
||
private _cfgAmmo = configFile >> "CfgAmmo"; | ||
private _ammoConfig = _cfgAmmo >> _ammo; | ||
private _caliber = getNumber (_ammoConfig >> "ACE_caliber"); | ||
|
||
_caliber = switch (true) do { | ||
// If explicilty defined, use ACE_caliber | ||
case (inheritsFrom (_ammoConfig >> "ACE_caliber") isEqualTo _ammoConfig): {_caliber}; | ||
case (_ammo isKindOf ["ShellBase", _cfgAmmo]): {80}; | ||
case (_ammo isKindOf ["RocketBase", _cfgAmmo]): {200}; | ||
case (_ammo isKindOf ["MissileBase", _cfgAmmo]): {600}; | ||
case (_ammo isKindOf ["SubmunitionBase", _cfgAmmo]): {80}; | ||
default {[_caliber, 6.5] select (_caliber <= 0)}; | ||
}; | ||
|
||
private _loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) / 5; | ||
TRACE_5("building cache",_ammo,_magazine,_initSpeed,_caliber,_loudness); | ||
|
||
_loudness | ||
}, true] |