TrenchBroom Help - Working With Textures

# Creating Entity Definitions

## "DEF" Format

### Point Entities

This format is the simplest way of creating entity definitions for the editor to use. Here is an example of a DEF for a Point Entity

/*QUAKED item_shells (0 .5 .5) (0 0 0) (32 32 32) BIG
model(":maps/b_shell0.bsp");
model(":maps/b_shell1.bsp" 0 0 spawnflags = 1);
20 shells for both Shotgun and SuperShotgun.
Flags:
"BIG"
gives 40 instead of 20
Keys:
"target"
entity to trigger when picked up
"targetname"
entity name
*/

Here are the components:

/*QUAKED
This tells the editor that this is the beginning of an entity definition. It must always be present at the start of the first line.

item_shells
This is the name of the entity; in more technical terms, it's classname. The classname must be one word and can contain only letters, numbers and _. It cannot begin with a number. It must have a matching entry in the progs.dat of the mod you are creating this definition for or it will do nothing in the game.
Another point of note is how Trenchbroom organizes entities in the context menu. Entities who's classnames have prefixes before the first underscore(_) will be grouped together in a submenu.

(0 .5 .5)
This tells the editor what colour the entity's bounding box should be in the viewport. It is helpful to colour entities that share similar traits the same colour. The proper syntax for this section are three decimal numbers between 0 and 1 bounded by opening and closing () braces. The numbers follow the standard RGB method of defining a colour: the first number is how much red to mix in, the second is how much green, and the third is how much blue.

(0 0 0) (32 32 32)
The next two sets of numbers are vectors representing the mins and maxs of this point entity. In the case of this entity, the entity's bounding box starts at (0 0 0) and goes to (32 32 32). Note that these do not have to be positive. The ammo box is not centered on the origin of the entity in this case. A setting of (-16 -16 0) and (16 16 32) would center the bounding box of the origin horizontally.

BIG
This is a spawnflag and will appear in the smart editor in Trenchbroom. More than one spawnflag can be defined by placing them one after another on the same line with a space separating them. Note that if you need to skip a spawnflag (eg: bit values 1, 2 and 8 but not 4), you would need to put a dummy flag (usually an X) in the unwanted value's place.

20 shells for both Shotgun and SuperShotgun.
Flags:
"BIG"
gives 40 instead of 20
Keys:
"target"
entity to trigger when picked up
"targetname"
entity name
This is simply a description of the entity. It is only for users to read so that they can understand how the entity works and does nothing in the editor.

*/
This tells the editor that this is the end of the entity definition. It is required at the end of all entity definitions.

### Brush Entities

Here is an example of a DEF for a Brush Entity:

/*QUAKED func_illusionary (0 .5 .8) ?
A simple entity that looks solid but lets you walk through it.
Does not block light.
*/

Here are the components:

/*QUAKED
Unchanged from point entities, this tells Trenchbroom that it is the start of a new definition.

func_illusionary
Same as with point entities, this is the classname.

(0 .5 .8)
This tells the editor what colour the entity's bounding box should be in the viewport. It is helpful to colour entities that share similar traits the same colour. The proper syntax for this section are three decimal numbers between 0 and 1 bounded by opening and closing () braces. The numbers follow the standard RGB method of defining a colour: the first number is how much red to mix in, the second is how much green, and the third is how much blue.

?
This tells the editor that this entity is a brush entity. In other words, it contains brushes, for example doors, lifts and triggers. Note that unlike the point entity definition, the brush entity definition is missing the two sets of vectors. This is because brush entities can be any size and that size is determined by the brushes it contains.

A simple entity that looks solid but lets you walk through it.
Does not block light.
Again, this is simply a description of the entity.

*/
Unchanged from point entities, this tells the editor that this is the end of the entity definition and is required at the end of all entity definitions.

## "FGD" Format

The FGD format is a more complicated definition format and so will take more time to describe.

### Inheritance

The FGD format implements inheritance. What this means is that you can create templates which you can then use to quickly add parts of a definition to other definitions.