This article was converted from a previous version of TWHL and may need to be reviewed
- The formatting may be incorrect due to differences in the WikiCode processing engine, it needs to be revised and reformatted
- Some information may be out of date
- After the article is re-formatted and updated, remove this notice and the Review Required category.
- Some older tutorials are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
Obviously, there are two main components to a game. There are the visual effects and the audio effects, both equally important. As we map for Half-Life, we usually don't have to add any audio effects, since we are mapping for an already coded game. What if you wanted to add your own music or sound effects into the game? Well, we can do this simply through the
ambient_generic entity.
Triggering a SoundLets say you have an electric platform. When the player steps on this platform, you want it to make a sound. Well, This is a simple task. The only difficult part is supplying the sound.
The Sound Half-Life is very specific in its sounds format. The sound must be in .WAV format, which most of them usually are. Make sure that the sound is 8-bit mono, otherwise it will not work properly, or might just not work at all. After you have a sound in the right format, whether you make a custom sound, or find an already made sound, you must put it in the right folder. Refer to the
Making Custom Sounds tutorial for more details on that subject. If you are making a map for Half-Life, it must be in the
valve/sound/ambiencefolder. If you are making a custom MOD, you must create a
sound/ambience folder in order for it to work. Now that you have your sound in the right place, the next step is to use an
ambient_generic to trigger it.
Triggering the SoundNow, you have to create your
ambient_generic. Using the entity tool, put your
ambient_generic in the exact spot where you want it to play. The player can only hear the sound if he is facing in its direction, so in this case, we would place the
ambient_generic right above the electric platform.
Name the entity something like
elec_plat_sound so you can easily remember it. Now that it has a name, create a
trigger_multiple, or a
trigger_once (depending on if you want the sound to play over again if you step on the platform another time). Place the trigger on the platform, where the player must be for the
ambient_generic to play. Make the trigger trigger the
ambient_generic... obviously...
Setting up the sound to playNow you must work with the
ambient_generic itself. Go into its properties and select
WAV name. This next step is usually what causes most people errors: avoid using the browse tool. You should already have put your sound file in the correct folder, and you should already know its name. Instead, type in the path relative to the mod directory sound folder. When Hammer looks for the .WAV file, it assumes you are already in the sound folder. Merely type in
ambience/blah.wav (with a forward slash). This should locate the correct file. Now your sound should play when triggered, but there are some more attributes that you should look at first.
Properties and FlagsGenerally, I leave all the properties at their default state, although you may want to mess around with them sometime. The flags are very important though, and you should make sure they are all correct before compiling.
Play Everywhere pretty much does what it says... it plays everywhere. Beware: this does not mean that the sound will play equally loudly through each speaker (as if you were just listening to an audio file) it only means that the distance you are from the sound does not matter. We will cover how do counter this directional effect. The
Small Radius,
Medium Radius, and
Large Radius checks control how far you can be away and still hear the sound.
Start Silent obviously does what it says as well. If you do not click this flag, the sound will play as soon as the map has loaded. This probably is only effective when doing music, which we will cover next. In our specific example using the electric platform, you must click this flag, or the file will not start when you touch the trigger.
MusicLets say you want some background music in your map. You will still use an
ambient_generic, and a .WAV file, but there is a different technique to doing this effectively.
As we covered before, the player will hear the
ambient_generic as if the sound was being emitted from its position. For background sound, this is highly undesirable, and easily countered. Obviously, the
Play Everywhere flag must be pressed, and the
Start Silent flag must be unchecked.
Create the
ambient_generic that will play the music. Do not name it anything. Create hollowed out brush boxes on each side of your map: one for north; one for east, etc. Copy your
ambient_generic and place one in each of the boxes. Make sure that you do not use too many
ambient_generics, but just enough so that you can always hear the music without noticing the variations in volume.