The surface flags are texture properties that often affect entities in contact with surfaces using such flags. The ‘surfaceparm metalsteps’ parameter from Q3A is a good example.

If you look in the source file game/surfaceflags.h, it has defines for all surface flags. The define is split into a name and a hexadecimal value, for instance SURF_NODAMAGE 0x1. These hexadecimal values are powers of 2 and can be ored together (binary) to form a bit mask. Up to 32 surface flags can be ored together this way.

Example: Making ‘footsteps on grass’ sounds

The following outlines how a custom surface flag can be added and used in a mod. First open up the ‘custinfoparms.txt’ file and add 'grass 0x80000' to the Custom Surfaceflags section as shown in the example file above (0x80000 is the first available unused value in surfaceflags.h for surface flags). Next write a shader script which uses a grass image and has 'surfaceparm grass’. Create a test map with the grass shader covering the ground surface. When you compile the map, add the -custinfoparms parameter to the command line following q3map.

Next, add SURF_GRASS 0x80000 to the source file game/surfaceflags.h in your mod. Now you'll be able to execute a trace and the trace information will be returned in the trace_t structure. If the trace hits a surface with the grass surfaceparm then the SURF_GRASS flag will be set in trace_t->surfaceFlags. Such a trace can be used to trigger playing a sound of a person stepping on grass. For a reference example, see the existing metal steps in the game code.