Changing HL2's Pistol Reload Created 6 years ago2018-06-18 20:05:55 UTC by SiMpLeToN SiMpLeToN

Created 6 years ago2018-06-18 20:05:55 UTC by SiMpLeToN SiMpLeToN

Posted 6 years ago2018-06-18 20:05:55 UTC Post #339950
I am brand spanking new to the Source modding scene. Let that sink in for a second. You'll have to forgive my naiveté haha. For my first trick, I would like to change Half-Life 2's pistol reload sound. That's it. I have the sound, I have the source code (I am actually looking at it right now, phew), and I have the sourcemod (which I'm assuming I needed to create). HOW the HECK do I actually change it?

sp/src/game/server/weapon_pistol.cpp was my first stop. After some digging, I stumbled upon some repeated references to SOUNDENT.h. This seems to be how the game puts sounds into the environment.

I've even found functions inside pistol.cpp that seem to hint at where the sound comes from or something: WeaponSound( RELOAD ) is the one I'm particularly interested in. But, I can't find out how to change which sound files it points at. I can't even find what object RELOAD is.

I have my mod's sound folder set up as sound/weapons/pistol/pistol_reload1.wav, just like the original. Is this all I had to do? The problem then becomes how I test it. My mod has no maps inside of it. I just want Half-Life 2 as is but with my new sound.

Do I have to find all the original .bsps and plug them into my mod? That seems illegal. There has to be a way to make this mod just a plugin that uses inheritance or something. Don't know if any of that made sense, but I'm really lost here, lol. The only thing about Half-Life 2 I want to change is this one little thing. I obviously can't package all of HL2 into my mod just to change that...
Posted 6 years ago2018-06-18 21:20:36 UTC Post #339951
Changing the reload sound shouldn't need any code changes. If you only want to change the sound itself, and don't care about volume, pitch, attenuation or those sorts of things, just replacing the sound file itself should work just fine. If you want to do more advanced changes, you can edit the soundscript files. The file that has all of the weapon sounds in Half-Life 2 is "scripts/game_sounds_weapons.txt", and the entry for the pistol reload sound is "Weapon_Pistol.Reload".

To test the sound, you need a map. If your mod is using the Source SDK Base, then you probably don't have any of the stock Half-Life 2 maps and need to create your own. This is actually very easy, and there are plenty of tutorials on this site to get you started. If you're an absolute beginner, you should check out some of the beginner tutorials.

I hope this helps.
Dr. Orange Dr. OrangeSource good.
Posted 6 years ago2018-06-18 23:26:12 UTC Post #339954
Thanks! Very helpful actually. Will a new game_sounds_weapons.txtin my mod completely overwrite the original? Will I need to include game_sounds_weapons.txt in its entirety in my mod's /scripts to preserve the other sounds as well, or do I only need one entry for the one I want to change?
As for mapping, I have used Hammer a good bit before. I am more than confident making a map. I haven't used it in a while, however. Since I've begun messing around with Source, I became aware of some SteamPipe update that "broke" the Source SDK. This means I have to go to the hl2 Steam folder and launch hammer from there, right?

*EDIT
Disregard comments about the .txt. I forgot that when I set up my mod, part of it was including all of /scripts which has game_sounds_weapons.txt in it already.
Posted 6 years ago2018-06-19 11:29:52 UTC Post #339958
Another thing I would like to add after reading your shoutbox messages: if you are only making a small change such as changing a single sound file, you might want to make your mod into a ”custom” mod rather than a full SourceMod.

”Custom” mods are installed into the game’s ”custom” folder, which for Half-Life 2 would be ”Half-Life 2\hl2\custom\”. This sort of mod needs to be in it’s own folder in the custom folder, so the full search path should be ”Half-Life 2\hl2\custom\<name of your mod>\”.

The benefit of this kind of mods is that they are a lot smaller and work more like add-ons rather than full total conversion mods. You can also convert it into a VPK (Valve Pak File) for easier distribution usin the vpk.exe program found in ”Half-Life 2\bin\”.

I hope you found this useful, and best of luck!
Dr. Orange Dr. OrangeSource good.
Posted 6 years ago2018-06-20 04:36:36 UTC Post #339972
This sounds a lot more along the lines of what I wanted to do. Is there a utility out there for converting to VPK? <-- nevermind this; didn't read your post thoroughly enough because you literally gave me the answer to that question. Do I keep the same directory structure as a SourceMod inside the \custom folder i.e. models, maps, materials, sounds, etc. and a gameinfo? Also, would it show up in the Steam library, launch alongside Half-Life 2 automatically, or would I have to execute a .cfg while in-game or something or add a special line to the game's launch properties in Steam?
Posted 6 years ago2018-06-20 17:14:16 UTC Post #339977
The folder structure of your custom addon should be the same as the game structure. However, as I said, the mod needs it's own folder/vpk within the custom folder, so the full search path of your custom reload sound would be "Half-Life 2\hl2\custom\<name of your mod here>\sound\weapons\pistol\pistol_reload1.wav". It's the mod folder itself ("<name of your mod here>") that you would want to convert to a vpk for easier distribution.

You do not need to add a GameInfo.txt and the mod will not show up in the Steam library list. Custom mods are basicly add-ons for the game they are installed to and will work automaticly when the game is launched. The way it works behind the scenes is that the game searches the "custom" folder for any file directories before it searches the game's own files which means they override any files from the base game.
Dr. Orange Dr. OrangeSource good.
Posted 6 years ago2018-06-20 17:20:14 UTC Post #339978
Awesome! Thanks for the help!
You must be logged in to post a response.