Materials.txt

is a text file used in to dictate what sounds are made when stepping on certain textures, as well as what sounds to make when attacking those textures.
== Description ==
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.
List of values:
Prefix	Means
M 	Metal
V 	Metal (ventilation)
D 	Dirt
S 	Slime
T 	Tile
G 	Grate
W 	Wood
P 	Computer
Y 	Glass
N 	Snow ( only)
X 	Grass ( only)
C 	Concrete
F 	Flesh
Usage example:
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.
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.
== Quirks==
There are certain quirks within the system that can be utilized by mappers to simplify the process of adding new textures.
===Character Limit===
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. 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, indicating:
* "!" ("liquid")
* "-0" ("randomly tiled")
* "{" ("alpha-tested").
== See also == 
* Converting materials.txt to Source
== External links ==
* Greg's documentation
Category:GoldSrc
Category:Files
Category:GoldSrc Textures