Tagging is the process of associating a sector with a linedef in order to achieve a special effect. This is done through the tag property, which is a whole number between 0 and 65,535 that can be given to both linedefs and sectors. If a sector and a linedef have the same tag, they are said to be tagged to each other.
Many special effects in SRB2, such as FOFs, linedef executors and scrolling surfaces, are created by tagging a linedef with a specific action to a sector where the special effect should occur. In this context, the linedef with the action is called the control linedef because it controls the effect, while the sector the effect is applied to is called the target sector. The sector that contains the control linedef is called the control sector; its properties are often used to set additional parameters for the effect.
A tagging setup typically consists of a target sector and a control sector, which includes the control linedef. The control linedef is connected to the target sector by giving both the same tag. This way, the game recognizes that the two are connected and applies the special effect created by the control linedef to the target sector. The type of special effect is set by the control linedef's type (also called action). For example, a control linedef with linedef type 100 will create a solid, opaque, non-shadowcasting FOF in the target sector. See the FOF example WAD for a typical example of tagging.
When hovering over a control linedef or a target sector in Zone Builder, any tagged control linedefs/target sectors will be highlighted and they will be linked together with arrows.
Many special effects require additional parameters to specify the effect further. These are set through the properties of the control linedef and/or the control sector. The most common parameter is the linedef's length; other parameters include the linedef's X/Y distance, textures and offsets, as well as the control sector's floor/ceiling height and flats. The linedef and sector properties that are used as parameters and the way they are used depend on the special effect. Consult Linedef types and the individual articles for each type for information on how to set up specific effects.
Almost any linedef can be used as a control linedef, as long it does not already have a special linedef type used for another effect. Generally, control linedefs and their corresponding control sectors are placed outside the level's boundaries to hide them from the player's view. This allows mappers to manipulate their properties to set parameters for the special effects without having to worry about how the control sectors will appear to the player. While it is possible to place control linedefs and control sector in the main map, there is generally no reason to do so.
A control sector can include more than one control linedef, and in the case of linedef executors this is even required. However, if the sector properties required by different control linedefs conflict, such as two FOFs with different heights, they must be be placed in different control sectors.
The target sector of a special effect is often an in-level sector, but it can also be a control sector for another effect. A common example of this is applying a colormap to a water FOF. In this case, the colormap linedef is tagged to the FOF's control sector.
Not all linedef special effects are tagged to a target sector. Some effects are applied directly to the linedef itself (e.g., wall scrolling and translucent walls). Others need no tag at all, since they are applied to the player or modify a general level settings, such as the level's music or sky. Occasionally, linedef effects are tagged to other linedefs (e.g., linedef type 439, Change Tagged Linedef's Textures) or Things (e.g., many PolyObject-related linedef types) instead of a sector. Unlike linedefs and sectors, Things have no "tag" property, so in these cases the Thing's "Angle" property is used to specify the tag instead.
A tag can be shared by more than one linedef-sector pair. For example, it is often necessary to apply the same effect to multiple sectors, for example to apply a colormap to several sectors or to create one FOF spanning multiple sectors. This is achieved by simply giving multiple target sectors the same tag as the control linedef. This way, the control linedef's effect will be applied to all tagged target sectors.
Similarly, multiple linedef effects can be applied to one target sector. This is done by creating a separate control linedef for each effect and giving all of them the same tag as the target sector.
This principle can be extended to the case where multiple effects are required in multiple sectors, as long as all target sectors use the same set of effects. However, if different subsets of effects are required in different sectors, it is necessary to give them separate tags and create separate copies of the control linedefs with different tags. Usually, these copies can all be placed in the same control sector, unless they require different sector properties.
Target sector type
Some special effects require the target sector to have a specific sector type. A notable example are linedef executor triggers, where the target sector must have one of the "Trigger Linedef Executor" sector types, such as Trigger Linedef Executor (Floor Touch). Other examples include conveyor belts, speed pads and rope hangs.
The tag is a whole number between 0 and 65,535. It may be chosen freely by the map designer. However, there are several reserved tags that have hardcoded properties and therefore should not be used for normal sector tagging. Note that tag numbers -32,768 to -1 may also be used to represent tags numbers 32,768 to 65,535; some map editors will accept negative tags and automatically convert them to the corresponding positive tags.
By convention, a tag of 0 is used for untagged linedefs/sectors. However, it can also be used as a normal tag: If a control linedef has a tag of 0, its effect will be applied to all sectors with tag 0. Giving a control linedef tag 65,535, on the other hand, will make it affect all sectors in a map, even control sectors.