This tutorial will explain how to use materials to make custom textures play different sounds when you run on them or shoot at them. Materials will add a lot of depth to your map and increase the level of immersion for players, and can be used to balance your map for games such as Counter-Strike in which sound effects play a key part.
Usage of the materials file
The sound effect that plays when a player interacts with a surface is determined by the materials file. It's a plaintext file which you can find or create in the game's sound folder (Half-Life\game\sound\materials.txt
The materials file contains a list of most of the textures in the game. Each line is reserved for each texture and is prefixed by a specific character to determine which texture type the game will match the texture to. A couple of texture types unique to Counter-Strike are included in the following table, be sure to check your particular materials file for the game you are working with as you may have more options than this.
|Snow (cstrike only)|
|Grass (cstrike only)|
Additionally, only the first 12 characters of the texture's name are needed for most games built with this engine. One exception is Counter-Strike, while still checking the first 12 characters for bullet impact sounds, will actually use the full length of the name for footstep sounds.
Distributing materials with your map
Players that download your map in multiplayer won't be able to download the materials configured for it, they will only hear the default sounds for your custom textures. It's not possible to force a player to download your materials file in online play, but there are some workarounds.
Sharing your file
The easiest method is to share your own materials file, or the relevant lines from it, and expect players to manually install it. Packing your own materials file with a large archive is not recommended as players might accidentally overwrite changes they've made to their own file.
Using default texture names
Another method is to copy the exact name of a default texture and use it for the name of your custom texture. Make sure the default texture you choose is already configured in the materials file, as not all of them are. For example, your custom texture would be called
, which is already a default texture from halflife.wad
In order for the map editor to always display your custom texture instead of the default one with the exact name, make sure your custom WAD is loaded before the default one in the configuration settings. However, the game can still load the default WAD into memory first, ignoring the custom texture from your WAD. The best solution for this is to use the
compile parameter for your custom WAD. When loading your map, the game will prioritise the embedded custom texture
and it will be loaded every single time.
Another solution is to avoid using the default WAD altogether in your editor. When you export the map for the compiler, the map editor will create a keyvalue in the
entity which contains the entire list of the WADs in use by the editor. You can see this list in the compile log, excluding unused WADs:
Wad files required to run the map: "halflife.wad;materialstest.wad;cs_havana.wad;"
If you don't use any textures from the default WAD and remove it from the list, the game won't load the default WAD into memory and only load your custom WAD instead:
Wad files required to run the map: "halflife.wad;materialstest.wad;"
Default texture names as a prefix
If you find a default texture with at least 12 characters in its name, such as
, you can use the first 12 characters as a prefix for the name of your own custom texture, for example
. This is because Half-Life will only check the first 12 characters of a texture's name before matching it to the materials file. The following is a list of texture types which have textures with at least 12 characters in their names. You can build upon these names for your custom textures.
While this method works in Half-Life, it won't work for all games. In the case of Counter-Strike, the game matches all possible characters of the texture's name for footsteps. However, it still checks only the first 12 characters for bullet impacts.