- edit
- /
- history
- /
- upload files
Sound Replacement
Submitted by: Outerbeast on 06 Sep 2023 12:54
Last updated by: Outerbeast on 06 Oct 2023 12:14
Sound Replacement guide
Version 1.5
By Mad Jonesy
Before you start, make sure you have downloaded and installed the following programs:
- Valve Hammer
- Pakscape (availiable from http://collective.valve-erc.com)
Introduction
In this guide, I will take you through using a pre-created sound replacement file through to constructing your own short sound replacement file, following a set of rules.
Finally, I will document how to use global sound replacement files and how to replace sentences.
Sven Co-op 3.0 (and after) features coding that allows for the mapper (and server-side) replacement of sounds in monsters and global entities. This works by using a file that overrides the default sound file paths and directs the game to use one sound instead of another.
For an example of sound replacement, download the below map and files (you will need Winzip or some other archive extraction program to view the file).
Check out the pack, there are several file types included:
hungerslave readme.txt
This is the readme file, included by the pack compiler to give credits for all the files as well as give instructions. Always try to get as much information about a model/sound replacement before you try to use it in a map.
slv_**.wav
These are the sound files that will be used to replace the default sounds for the alien slave.
hungerslave.txt
The sound replacement file. Look inside and you will see the following:
"aslave/slv_alert1.wav" "hungerslave/slv_alert1.wav"
"aslave/slv_alert3.wav" "hungerslave/slv_alert3.wav"
"aslave/slv_alert4.wav" "hungerslave/slv_alert4.wav"
"aslave/slv_die1.wav" "hungerslave/slv_die2.wav"
"aslave/slv_pain1.wav" "hungerslave/slv_pain1.wav"
"aslave/slv_pain2.wav" "hungerslave/slv_pain2.wav"
"aslave/slv_word1.wav" "hungerslave/slv_word1.wav"
"aslave/slv_word2.wav" "hungerslave/slv_word2.wav"
"aslave/slv_word3.wav" "hungerslave/slv_word3.wav"
"aslave/slv_word4.wav" "hungerslave/slv_word4.wav"
"aslave/slv_word5.wav" "hungerslave/slv_word5.wav"
"aslave/slv_word6.wav" "hungerslave/slv_word6.wav"
"aslave/slv_word7.wav" "hungerslave/slv_word7.wav"
"aslave/slv_word8.wav" "hungerslave/slv_word8.wav"
"!SLV_IDLE0" "hungerslave/slv_word1.wav"
"!SLV_ALERT0" "hungerslave/slv_alert1.wav"
"!SLV_ALERT3" "hungerslave/slv_word2.wav"
What this all means will be covered later when we discuss creating a sound replacement file from scratch.
Hungerslave**.mdl
The monster model itself. This is used to replace the default model.
Hungerslave.jpg
Just a picture of the model, not necessary for the file to work, but handy if someone likes to see what the model looks like without having to actually put it into a map.
soundrep.bsp/.rmf
The map files, bsp is the compiled map, rmf is the map file that can be viewed in Valve Hammer.
For an example of sound replacement in action, open up the example map, soundrep.bsp. The map shows two Alien Slaves, one of them replaced to be like a "They Hunger" Skeleton. Both of the Slaves are friendly, so feel free to beat both of them up with a crowbar to hear the differences in pain and death sounds sounds.
As you could see in the example map, changing the sounds for one monster does not mean that the sounds for all monsters of that type are replaced. You could have several varieties of the same monster type, each using a different sound-set and model, in the same map.
Open svencoop/maps/soundrep.rmf. This is the map file for soundrep.bsp. Take a look around the map and check out the two monster entities. The Alien Slave on the left is the default friendly Alien Slave, the Alien Slave on the right is the model/sound replaced version.
Entity settings for the Model/Sound Replaced Alien Slave
These settings are the only differences between the original Alien Slave and the "They Hunger" alien slave.
Is Player Ally: Yes
In-game Name: Undead
Blood Color: Red
Custom Model: models/hunger/hungerslave.mdl
Sound Replacement file: hungerslave.txt
Try setting the Alien Slave on the left (the default friendly Alien Slave) to be the same as the one on the right (the "They Hunger" alien slave) by entering the above settings into the monster. Compile and play. Both the Alien Slaves should be the same.
Note: Try changing the 'Is Player Ally' setting to 'No' for one of the monsters to hear a few more replaced sounds, such as 'attack' and 'alert' sounds.
By now, you probably appreciate that sound replacement is a very powerful tool for mappers. For example, "They Hunger" for Sven Co-op is using sound replacement to recreate all the They Hunger monsters, no further coding is being used.
Creating a basic sound replacement file
For the next section of this guide, you will create a sound replacement file that will make a headcrab use the ultra-squeeky sounds of a snark. You will require a program like pakscape (recommended) to view the various files.
Using pakscape, click on File, Open, and browse to the Half-Life/Valve/Pak0.pak file, this is where the majority of Half-Life's sounds are kept.
Look at the directory for the Headcrab sounds (kept in sounds/headcrab/), there are 16 sounds in total. Some monsters can have over a hundred sounds, so the headcrab has a relatively small range of sounds. The headcrab sounds are divided up into different types:
hc_alert*.wav (1-2)
- Sounds played when a headcrab see's the player/hostile
hc_attack*.wav (1-3)
- Sounds played when the headcrab attacks a target (in this case, the crabs leap attack)
hc_die*.wav (1-2)
- Sounds played when the headcrab is killed
hc_headbite.wav
- Sound played when the headcrab hits a target with its attack
hc_idle*.wav (1-5)
- Sound played when the headcrab cannot see a target and is not performing any other action
hc_pain*.wav (1-3)
- Sound played when the headcrab takes some damage, but is not killed
Double-click on some of these sounds, you should recognise most of them if you have played Half-Life/Sven Co-op.
Most monsters share similar file formats, for example, the zombie folder contains a zo_idle and a zo_alert, it is usually easy to work out which sounds are used for what purpose due to Valve's file naming style.
Open a new text document in notepad, its time to start your sound replacement file, begin by listing all of the sound files in the following format:
"filedirectory/soundfilename.wav"
Every line will start off with "headcrab/", the quote marks are important. I'll start you off with the filenames for the headcrabs attack and die sounds, finish the list for the headbite, idle and pain sounds (copy + paste is your friend here).
"headcrab/hc_alert1.wav"
"headcrab/hc_alert2.wav"
"headcrab/hc_attack1.wav"
"headcrab/hc_attack2.wav"
"headcrab/hc_attack3.wav"
……
You should now have a list of 16 sounds files, all in the above format. Now it is time to choose which sounds to use to replace the headcrab sounds. You can use any sounds for monster replacement, but it is preferable to choose sounds that aren't *too* different for the monster (a headcrab that sounded like a scientist would be very strange). I am going to use the snark sounds.
The monster sounds aren't always kept in a folder that has the same name as the monster name, in this case, the snark sounds are kept in a folder called "squeek", the HW Grunt sounds are kept in a folder called "hassault" and the bullsquid sounds are kept in a folder called "bullchicken".
The sounds in the "squeek" folder are as follows:
"squeek/sqk_blast1.wav"
"squeek/sqk_deploy1.wav"
"squeek/sqk_die1/wav"
"squeek/sqk_hunt1.wav"
"squeek/sqk_hunt2.wav"
"squeek/sqk_hunt3.wav"
You might have noticed that there are 16 sounds to be replaced, but only 6 snark sounds to replace them with. It is very unlikely you will always have the right number of sounds when using sound replacement, so it is necessary to make the best of what you have. I decided on the following:
- To leave the headcrab idle sounds as the default, and delete them from my sound replacement file.
- Replace the "headcrab/hc_headbite.wav" sound with the "squeek/sqk_deploy1.wav" sound
- Replace both "headcrab/hc_die1.wav" and headcrab/hc_die2.wav" with "squeek/sqk_die1.wav"
- Replace all the "headcrab/hc_alert*.wav" sounds with "squeek/sqk_hunt1.wav"
- Replace all the "headcrab/hc_attack*.wav" sounds with "squeek/sqk_hunt2.wav"
- Replace all the "headcrab/hc_pain*.wav" sounds with "squeek/sqk_hunt3.wav"
Try following these instructions, leaving a space between the original sound path and the new file path in the format: "filedirectory/soundfilename.wav" "newfiledirectory/newsoundfilename.wav"
If you followed the instructions correctly, you should end up with a file exactly like this:
"headcrab/hc_alert1.wav" "squeek/sqk_hunt1.wav"
"headcrab/hc_alert2.wav" "squeek/sqk_hunt1.wav"
"headcrab/hc_attack1.wav" "squeek/sqk_hunt2.wav"
"headcrab/hc_attack2.wav" "squeek/sqk_hunt2.wav"
"headcrab/hc_attack3.wav" "squeek/sqk_hunt2.wav"
"headcrab/hc_die1.wav" "squeek/sqk_die1.wav"
"headcrab/hc_die2.wav" "squeek/sqk_die1.wav"
"headcrab/hc_headbite.wav" "squeek/sqk_deploy1.wav"
"headcrab/hc_pain1.wav" "squeek/sqk_hunt3.wav"
"headcrab/hc_pain2.wav" "squeek/sqk_hunt3.wav"
"headcrab/hc_pain3.wav" "squeek/sqk_hunt3.wav"
Save your sound replacement file in your Svencoop/sound/soundrep/ folder with the filename 'snarkcrab.txt'. Note that soundrep is the name of the map in this case and NOT the folder where all sound replacement files should go. If a map was called "mymap", the sound replacement file would go into the 'Svencoop/sound/mymap/' folder.
Now it is time to test out your Sound Replacement file, open soundrep.rmf and create a monster_headcrab in the middle of the room. Give it the following settings:
In-Game Name: SuperCrab
Custom Health: 200
Sound Replacement File: snarkcrab.txt
Save and compile, now when you play the map, hopefully the sound replaced headcrab and alien slaves should fight to the death, all with custom sounds.
Advanced sound replacement
In this section, I will cover:
- Global sound replacement
- Sentence files
- The limits of sound replacement
- Some hints/tips for sound replacement
Global sound replacement
There are two forms of sound replacement:
[b]Global[/b] - This includes some weapon sounds, ambience sounds, player movement sounds and all monster sounds. Pretty much all sounds then.
[b]Per-Item[/b] - This allows you to replace the sounds for an individual monster/some weapons.
Global sound replacement allows you to change all the sounds for all the monsters, which makes this very useful if you plan on a large number of identical sound replacements.
Open up the example map 'Svencoop/maps/soundrep.rmf', open up each of the Alien Slaves and clear the 'Sound Replacement file' setting so that it is blank. Now, open up the map properties in Valve Hammer (Map/Map Properties) and select the 'Global Sound Replacement file' setting, set it to 'hungerslave.txt' (no quotes). Compile and run.
As you could see, both monsters used the hungerslave.txt sound replacement settings, even though nothing was set for each individual monster.
Global sound replacement can be used to replace ladder sounds, jump sounds, item sounds (such as healing/HEV charger sounds) and so on. While not all sounds can be replaced, it is still possible to customise the game to a high degree.
You can replace multiple monsters in a global sound replacement file, just combine all
Replacing Sentence files
For some monsters (in particular, human grunts, barney and scientists), Half-Life uses a file called sentences.txt to allow monsters to string sound files together.
Open up the sentences.txt file in Svencoop/sounds.
Example sentences.txt entry:
SC_HEAL2 scientist/youneedmedic, letstrythis
'SC_HEAL'
Sentence name
'scientist/youneedmedic'
Name of the first sound file that the sentence uses (notice that a .wav file extension is not needed)
', letstrythis'
Second sound file that the sentence will play, there is no need to specify the folder again.
The comma inbetween the first and second wav name is not needed, but tells the game to pause before playing the next sound.
When the player uses a scientist, the game will notice that the player is injured, then play one of the SC_HEAL sentences.
To replace scientist, grunt, barney or Otis sounds, you will more than likely need to replace a sentence file.
IMPORTANT: The sentence file takes priority over any sound replacement files unless you change the sentences using a sound replacement file (covered below). So if you replace any sound file that is PART of a sentence, the game will still play the original sentence, ignoring the sound file.
The way to correctly replace sentences is in this format:
"!sentencename" "newsoundfolder/newsoundname.wav"
The '!' is needed to make the code recognise that you are replacing a sentence file.
To make the scientist scream for help when the player tries to get health, you will need to make an entry into the sentence file as follows:
"!SC_HEAL2" "scientist/noo.wav"
Note: While the original sound was made up of two sound files, you can only replace it with a single sound file, there is no way to replace any sound with more that one sound, this is an unfortuate limit of sound replacement.
Also, you cannot use a sentence to replace any sound or another sentence in a sound replacement file. Trying to use '"scientist/noo.wav" "!SC_HEAL2"' will simply lead to an error when loading the map as sentences cannot be precached.
Limits of sound replacement
- Footstep sounds cannot be replaced, this is because they are controlled by the materials.txt file.
- For weapons, only crowbar and wrench sounds can be sound replaced, this is due to all other weapons being client-side, there is an option for setting a sound replacement file in all weapon entities, but this only works for the weapon_wrench and weapon_crowbar.
- Some sentence files are made up of more than one wav file, it is not possible to replace the file with more than one wav file.
A full list of sounds that cannot be replaced can be found here: https://github.com/R4to0/scstuff/wiki/Unreplaceable-client-side-sounds
Hints/tips for sound replacement
- If you don't have a sound to replace for a monster/item, you can blank it out by replacing the sound file with a sound called "null.wav". This is a dummy wav file and causes no sound will be played.
- Sound replacement files don't have to be in a folder the same as the mapname, using ../ in front of the sound replacement filename in worldcraft will cause it to look up to a higher directory.
So if your map is called 'anymap', setting the sound replacement file for a monster as '../anyfoldername/soundreplacement.txt'
will cause the game to look for
'svencoop/sound/anyfoldername/soundreplacement.txt'
rather than
'anymap/soundreplacement.txt'
Summary of how to use sound replacement:
For any wav sound file:
- "filedirectory/soundfilename.wav" "newfiledirectory/newsoundfilename.wav"
For any sentence:
- "!sentencename" "newsoundfolder/newsoundname.wav"
- Remember, sentences have priority over wav files, so check to see if the monster type uses any sentences by looking in the sentences.txt file.
Using the sound replacement file:
- Save as a text document, in a directory with the same filename as your map in the Sven Co-op sound folder. For example 'svencoop/sound/mapname/soundrep.txt'
- If you wish to replace a single monster, change monster 'Sound Replacement File' property to the name of the textdocument, for example 'hungerslave.txt'
- If you wish to replace all sounds globally, change the map 'Global Sound Replacement file' property to the name of the text document, for example 'globalsound.txt'
Finally:
If you have any questions or comments on sound replacement, please feel free to PM me through the Sven Co-op forums using this link.
http://www.svencoop.com/forums/private.php?action=newmessage&userid=2
Mad Jonesy
Feedback
Rate this tutorial
0 / 5 (0 votes)
Reviews
Comments & discussion
Rules:
- Feedback should be constructive.
- For discussion not related to this tutorial, post in the forum.
- If you need help installing tutorials, please read the installation guide.
}