Added GetDistGainFromSoundLevel native to SDKTools (bug 5066, r=dvander).
Added GetDistGainFromSoundLevel native to SDKTools (
bug 5066, r=dvander).
1.1 --- a/extensions/sdktools/vsound.cpp Sat Sep 03 14:11:38 2011 -0400
1.2 +++ b/extensions/sdktools/vsound.cpp Sat Sep 03 14:18:08 2011 -0400
1.3 @@ -782,6 +782,14 @@
1.4 return 1;
1.5 }
1.6
1.7 +static cell_t smn_GetDistGainFromSoundLevel(IPluginContext *pContext, const cell_t *params)
1.8 +{
1.9 + int decibel = params[1];
1.10 + float distance = sp_ctof(params[2]);
1.11 +
1.12 + return sp_ftoc(engsound->GetDistGainFromSoundLevel(soundlevel_t)decibel, distance));
1.13 +}
1.14 +
1.15 sp_nativeinfo_t g_SoundNatives[] =
1.16 {
1.17 {"EmitAmbientSound", EmitAmbientSound},
1.18 @@ -795,5 +803,6 @@
1.19 {"AddNormalSoundHook", smn_AddNormalSoundHook},
1.20 {"RemoveAmbientSoundHook", smn_RemoveAmbientSoundHook},
1.21 {"RemoveNormalSoundHook", smn_RemoveNormalSoundHook},
1.22 + {"GetDistGainFromSoundLevel", smn_GetDistGainFromSoundLevel},
1.23 {NULL, NULL},
1.24 };
2.1 --- a/plugins/include/sdktools_sound.inc Sat Sep 03 14:11:38 2011 -0400
2.2 +++ b/plugins/include/sdktools_sound.inc Sat Sep 03 14:18:08 2011 -0400
2.3 @@ -257,6 +257,15 @@
2.4 bool:updatePos = true,
2.5 Float:soundtime = 0.0,
2.6 any:...);
2.7 +
2.8 +/**
2.9 + *Calculates gain of sound on given distance with given sound level in decibel
2.10 + *
2.11 + * @param soundlevel decibel of sound, like SNDLEVEL_NORMAL or integer value
2.12 + * @param distance distance of sound to calculate, not meter or feet, but Source Engine`s normal Coordinate unit
2.13 + * @return gain of sound. you can multiply this with original sound`s volume to calculate volume on given distance
2.14 + */
2.15 +native Float:GetDistGainFromSoundLevel(soundlevel, Float:distance);
2.16
2.17 /**
2.18 * Called when an ambient sound is about to be emitted to one or more clients.