-
-
Notifications
You must be signed in to change notification settings - Fork 459
New functions for SDKTools to get information from game_sound files #65
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
Conversation
…ormation from game_sound files.
extensions/sdktools/vsound.cpp
Outdated
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.
Duplicate line?
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.
Overwrote the wrong line when I was adding natives actually... copy/pasted the GetDistGainFromSoundLevel line twice, overwrote the second one with {"PrecacheScriptSound", smn_PrecacheScriptSound}, then overwrote that with {"GetGameSoundParams", smn_GetGameSoundParams},
Not sure if I can append a Pull Request or if I have to make a new one... guess I'll find out.
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.
Apparently making a new commit automatically updates the pull request... I hated that behavior in bitbucket, I'm certainly not hating it any less here.
|
Fixed an issue where I'd left a second copy of the GetDistGainFromSoundLevel native instead of the PrecacheScriptSound native. |
If you use a branch per PR, rather than master, it's actually a very nice feature. |
extensions/sdktools/vsound.cpp
Outdated
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.
It might be wise to also check !edict->IsFree().
return GetParametersForSoundEx's return value instead of always true.
|
@psychonic Well, if I knew it would do that in advance, then maybe. Problem is, I didn't... and it's unexpected behavior if you don't know it's going to happen. |
|
Let not head too far offtopic 😺 |
|
@voided There is (assuming I saw it), but it's too late to change it by the time you see it, because you've already opened the pull request. |
|
Oops. I didn't notice the last commit. Looks alright enough to me. Let's give it a go on master. |
New functions for SDKTools to get information from game_sound files (r=psychonic).


This is an updated version of the code from bug 5942
Basically, it consists of two natives:
PrecacheScriptSoundandGetGameSoundParams.native bool:PrecacheScriptSound(const String:soundname[]);PrecacheScriptSoundcaches all sounds associated with a game sound that aren't already cached.GetGameSoundParamstakes a game sound name and fetches the fields from game_sounds.txt (and a game's other game_sound files) into the channel, soundLevel, volume, pitch, and sample fields. entity is used to determine the gender of the sound if a particular sound has genders. It will return false if the sound wasn't found. Note that sample will be random on game_sounds that have a rndwave section.In addition, there are several new stocks that serve as wrappers for
GetGameSoundParams:EmitGameSound,EmitGameSoundToAll,EmitGameSoundToClient, andEmitAmbientGameSound. These are all based on the EmitSound wrappers of the same name and take roughly the same arguments, but with the game sound name instead of the sample.These wrap
GetGameSoundParamsandEmitSound/EmitAmbientSoundas appropriate. All of them return false ifGetGameSoundParamsreturns false.Standard expected usage is something like this:
Note: Most game sounds are precached by the game itself on map start, but this isn't guaranteed. For instance, TF2 doesn't cache the above sound on non-MvM maps. Therefore, it's recommended to use PrecacheScriptSound, which checks if a sound is precached before precaching it.