Materials.txt: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Language subpage}} | {{Language subpage}} | ||
{{file|sounds/materials|txt}} is a text file used in {{goldsrc|4}} to dictate what sounds are made when stepping on certain textures. | {{file|sounds/materials|txt}} is a text file used in {{goldsrc|4}} to dictate what sounds are made when stepping on certain textures. | ||
{{modernImportant|The material handling code is hard-coded in the Half-Life DLL files.}} | |||
The system operates through a single file called “valve/sound/materials.txt” found within the primary installation folder of the Half-Life game. This file contains a series of lines that assign texture names to corresponding material types using a one-letter code. For example, the letter ‘V’ represents ventillation, ‘D’ represents dirt, ‘M’ represents metal, and so on: | The system operates through a single file called “valve/sound/materials.txt” found within the primary installation folder of the Half-Life game. This file contains a series of lines that assign texture names to corresponding material types using a one-letter code. For example, the letter ‘V’ represents ventillation, ‘D’ represents dirt, ‘M’ represents metal, and so on: | ||
Line 32: | Line 32: | ||
==Prefix Characters== | ==Prefix Characters== | ||
When the engine compares the materials.txt file to a map texture, it first removes any “texture prefix” characters from the map texture. Specifically, it removes a leading “+0” or “-0” (or any other digit or letter). It can also remove one of the characters “!”, “~”, “{”, or a space before making the comparison. Practically, this means that an entry like “G CHAIN_LINK” will match various texture names, including | When the engine compares the materials.txt file to a map texture, it first removes any “texture prefix” characters from the map texture. Specifically, it removes a leading “+0” or “-0” (or any other digit or letter). It can also remove one of the characters “!”, “~”, “{”, or a space before making the comparison. Practically, this means that an entry like “G CHAIN_LINK” will match various texture names, including: | ||
<source lang=cpp>+0CHAIN_LINK | |||
-2CHAIN_LINK | |||
+A~CHAIN_LINK | |||
~CHAIN_LINK | |||
+1{CHAIN_LINK</source> | |||
Similar to the 12-character limit, this quirk can be leveraged to add new textures without replacing existing ones by adding an unused prefix. For example, to include another wood texture, a texture could be named “-1OUT_WD.” This will match the existing entry “OUT_WD” from materials.txt while keeping the original “OUT_WD” from the halflife.wad file available as well. | Similar to the 12-character limit, this quirk can be leveraged to add new textures without replacing existing ones by adding an unused prefix. For example, to include another wood texture, a texture could be named “-1OUT_WD.” This will match the existing entry “OUT_WD” from materials.txt while keeping the original “OUT_WD” from the halflife.wad file available as well. | ||
It is advisable to avoid using prefixes with special meanings, such as “!” (indicating “liquid”), “-0” (indicating “randomly tiled”), and “{” (indicating “semi-transparent”). | It is advisable to avoid using prefixes with special meanings, such as “!” (indicating “liquid”), “-0” (indicating “randomly tiled”), and “{” (indicating “semi-transparent”). |
Revision as of 04:27, 9 July 2023


sounds/materials.txt
is a text file used in GoldSrc to dictate what sounds are made when stepping on certain textures.

The system operates through a single file called “valve/sound/materials.txt” found within the primary installation folder of the Half-Life game. This file contains a series of lines that assign texture names to corresponding material types using a one-letter code. For example, the letter ‘V’ represents ventillation, ‘D’ represents dirt, ‘M’ represents metal, and so on:
// Half-Life Texture Types. Modify this file only if texture names are changed!
// 'M' metal, 'V' ventillation, 'D' dirt, 'S' slosh liquid
// 'T' tile, 'G' grate (Concrete is the default), 'W' wood, 'P' computer, 'Y' glass
V SILO2_COR
D OUT_GRVL1
M SILO2_P2
By specifying the appropriate texture name in the file, the corresponding material type will be used for the associated surface. If a texture is not defined in the file, the default concrete sounds will be applied. It is important to note that this file is universal and affects all texture names used in any map within the game mod. Additionally, it cannot be overridden with custom entries specific to individual maps.
There are several approaches to overcoming this limitation:
- Accept the default sounds for custom maps and do not make any changes.
- Personally modify the materials.txt file. However, all players and servers must share the altered file, so creating a mod with a customized materials.txt file is a possible solution.
- Override the materials for objects by utilizing brush entities that allow material selection. Currently, only func_pushable and func_breakable entities offer this capability. By using func_breakable with the “Only Trigger” attribute, the object can be made unbreakable without assigning an actual trigger.
- Name custom textures in a way that matches existing entries in the materials.txt file. Textures included in the BSP file take precedence over those in WAD files, meaning that custom textures can override the default Half-Life textures.
Please note that the information provided here pertains specifically to the game Half-Life and its modding capabilities.
There are certain quirks within the system that can be utilized by mappers to simplify the process of adding new textures. It should be noted that all Half-Life textures have a maximum limit of 15 characters for their names, so when implementing these methods, it is important to ensure that the new texture names still adhere to this limit.
Character Limit
The header of the materials.txt file provides information indicating that only the first 12 characters of a texture name are used. This is interesting for mappers because it allows for the addition of numerous custom textures without the need to overwrite existing ones. By using an existing 12-character material name from the list as a prefix for a new texture, the first 12 characters will match. For example, “CRETE2_FLR03” is listed as a “Grate” type texture and its name is 12 characters long. If a custom texture is created with the name “CRETE2_FLR03_NU,” it will still produce the sound associated with a “Grate” because the first 12 characters match. However, “ELEV1_FLR” is also listed but cannot be used in the same manner. If a custom texture named “ELEV1_FLR_MyFlr” is created, only the first 8 characters will match. This quirk is also utilized by certain default Half-Life textures to allocate material sounds to multiple textures through a single entry, such as “DRKMTLT_WALL.”
Prefix Characters
When the engine compares the materials.txt file to a map texture, it first removes any “texture prefix” characters from the map texture. Specifically, it removes a leading “+0” or “-0” (or any other digit or letter). It can also remove one of the characters “!”, “~”, “{”, or a space before making the comparison. Practically, this means that an entry like “G CHAIN_LINK” will match various texture names, including:
+0CHAIN_LINK
-2CHAIN_LINK
+A~CHAIN_LINK
~CHAIN_LINK
+1{CHAIN_LINK
Similar to the 12-character limit, this quirk can be leveraged to add new textures without replacing existing ones by adding an unused prefix. For example, to include another wood texture, a texture could be named “-1OUT_WD.” This will match the existing entry “OUT_WD” from materials.txt while keeping the original “OUT_WD” from the halflife.wad file available as well. It is advisable to avoid using prefixes with special meanings, such as “!” (indicating “liquid”), “-0” (indicating “randomly tiled”), and “{” (indicating “semi-transparent”).