Linedef

From DoomWiki.org

(Redirected from LINEDEFS)
Doom level format

Linedefs are what make up the 'shape' (for lack of a better word) of a map. Every linedef is between two vertices and contains one or two sidedefs (which contain wall texture data). There are two major purposes of linedefs. The first is to divide the map into sectors, and the second is to trigger action specials. When dividing the map into sectors, a two-sided linedef is needed, and this is also required when two parts of the same room must behave differently, such as when there is a change in the height or texture of the floor or ceiling, the light level, or the sector tag or type.

Any area of a map directly behind a one-sided linedef is void space, which is not meant to be occupied by anything, but it can be reached by something that is placed there by the map author or passes through holes in improperly built maps, and the player can additionally use the idclip cheat code or the void glide exploit to reach the void.

There are four ways to trigger the action special of a linedef:

  1. Walkover by a player, monster or both.
  2. "Use" (or "push") (with the space bar, by default).
  3. Shoot (with an impact weapon).
  4. Certain projectiles passing over.

Which of these applies depends on the linedef type number, which also specifies what particular action will occur. Monster triggered linedefs can also be triggered by projectiles added in Doom II as they are not in the hard-coded list of projectiles that should not trigger action specials.

The specified action usually will take place in the sector or sectors that have the same tag number as the linedef. Exceptions to this include local doors (which act on the sector on the other side of the line), special effects that apply to the linedef itself, and the exit-level actions.

Most actions can be specified as either once-only or repeating (by using different linedef types).

Which side is the front or back of a linedef is determined by which vertex is the first vertex. For example, if you were to draw many linedefs with different second vertexes, but the same first vertex, those linedefs would face "clockwise". The front is always 90 degrees to the right / clockwise from the ray you would draw starting from the first point to the second point. To make a linedef face the opposite way, you would flip the vertices.

Linedef structure[edit]

Doom level format[edit]

Each linedef is 14 bytes long.

Offset Size in bytes C99 type [doom 1] Code Description
0 2 int16_t v1 Starting Vertex: Starting (X,Y) coordinate
2 2 int16_t v2 Ending Vertex: Ending (X,Y) coordinate
4 2 int16_t flags Flags: Attribute bits
6 2 int16_t special Linedef type: Special action or behavior
8 2 int16_t tag Tag: Associates sector(s)/line(s) with the special
10 2 int16_t sidenum[0] Front Sidedef [doom 2]
12 2 int16_t sidenum[1] Back Sidedef [doom 2]
  1. The original source code uses type short, which on the PC/DOS platform was a 16-bit signed integer. In the more precise C99 terminology, this would be int16_t. Most source ports and modern utilities change the interpretation of vertex and sidedef indices in this structure to be unsigned (uint16_t). This extends the limits on vertices from 32768 to 65536 items, and on sidedefs (which reserve the 0xFFFF value) from 32768 to 65535 items. Editors such as Doom Builder also often treat tag number and linedef special type as unsigned as well.
  2. 2.0 2.1 The special value -1 (hexadecimal 0xFFFF) is used to indicate no sidedef, in one-sided lines.

Doom 64 level format[edit]

The Doom 64 linedef is the same as the Doom format except for the Flags which are twice the size compared to Doom. Therefore each linedef is 16 bytes long.

Offset Size in bytes C99 type Description
0 2 int16_t Start Vertex
2 2 int16_t End Vertex
4 4 int32_t Flags
8 2 int16_t Special Type
10 2 int16_t Sector Tag
12 2 int16_t Front Sidedef
14 2 int16_t Back Sidedef

Hexen level format[edit]

Each linedef is 16 bytes long.

Offset Size in bytes C99 type [hexen 1] Description
0 2 int16_t Start Vertex
2 2 int16_t End Vertex
4 2 int16_t Flags
6 1 uint8_t Special Type
7 1 uint8_t Argument 1
8 1 uint8_t Argument 2
9 1 uint8_t Argument 3
10 1 uint8_t Argument 4
11 1 uint8_t Argument 5
12 2 int16_t Front Sidedef [hexen 2]
14 2 int16_t Back Sidedef [hexen 2]
  1. The original source code uses types short and byte (an alias for unsigned char). Most source ports and modern utilities change the interpretation of vertex and sidedef indices in this structure to be unsigned.
  2. 2.0 2.1 The special value -1 (hexadecimal 0xFFFF) is used to indicate no sidedef, in one-sided lines.

Linedef flags[edit]

Linedefs contain a two-byte (16 bit) field reserved for various flags. Flags are as follows:

Doom level format[edit]

The original Doom source code defined the following flags.[1] The ML_ prefix appears to stand for "map level".[2]

Bit Decimal Hex Name Description
0 1 0x0001 ML_BLOCKING blocks players and monsters
1 2 0x0002 ML_BLOCKMONSTERS blocks monsters
2 4 0x0004 ML_TWOSIDED two sided
3 8 0x0008 ML_DONTPEGTOP upper texture is unpegged
4 16 0x0010 ML_DONTPEGBOTTOM lower texture is unpegged
5 32 0x0020 ML_SECRET secret (shows as one-sided on automap), and monsters cannot open if it is a door (type 1)
6 64 0x0040 ML_SOUNDBLOCK blocks sound
7 128 0x0080 ML_DONTDRAW never shows on automap
8 256 0x0100 ML_MAPPED always shows on automap

Strife level format[edit]

Strife made several additions to Doom's linedef flags:

Bit Hex Description
9 0x0200 Jumpable railing
10 0x0400 Blocks floating monsters only
11 0x0800 25% foreground / 75% background translucency
12 0x1000 75% foreground / 25% background translucency

Boom level format[edit]

Boom added one flag to Doom's linedef flags:

Bit Hex Description
9 0x0200 The "use" action can activate other linedefs in the back (in Doom the "use" action only activates the closest linedef in the line of sight). Usually called "PassThru".

Hexen level format[edit]

All Doom flags and also the following:

Bit Hex Description
9 0x0200 can be activated more than once
10-12 0x0400 activated when used by player
10-12 0x0800 activated when crossed by monster
10-12 0x0C00 activated when hit by projectile
10-12 0x1000 activated when player bumps into it
10-12 0x1400 activated when crossed by projectile
10-12 0x1800 activated when used by player (with

pass through)

13 0x2000 line can be activated by players and

monsters

14 0x4000
15 0x8000 blocks everything (includes

gunshots & missiles)

See also[edit]

Sources[edit]

References[edit]

  1. id Software (22 December 1997). "Doom source code, doomdata.h." GitHub. Retrieved 2 November 2024.
  2. Ibid, line 36, "Map level types".