# Slope

A slope.

In SRB2, slopes are surfaces that aren't strictly horizontal but go upwards or downwards at an angle. They are supported since v2.1.15.

There are two ways to define slopes in SRB2: Sector-based slopes require two adjacent sectors with different floor or ceiling heights and are angled to make up the height difference between the two sectors. Vertex-based slopes are defined to go through three points that can be placed anywhere in the map. Sector-based slopes are faster to set up, but vertex-based slopes are more versatile and can be used to create geometry that isn't possible with sector-based slopes. Additionally, linedef specials exist that copy the slope of one sector to another.

This article will teach you how to create slopes in SRB2. While you can make maps with slopes in any map editor, Zone Builder is the only one that renders slopes in 3D mode and recognizes the linedef and Thing types used to make them.

## Sector-based slopes

To create a sector-based slope, create two adjacent sectors that share a single linedef. Now you need to decide which of the two sectors you want to slope and whether you want to slope the floor or the ceiling (or both). In this example, we will slope the floor of the shared linedef's front sector. Give the shared linedef type 700. This will define a slope on the front sector that starts at the front sector's floor height and moves upwards or downwards to meet the back sector's floor height at the shared linedef. Experiment with the floor heights of both sectors until you get the slope you want.

The linedef type that you give to the shared linedef determines which sector and which surface is sloped. In our example, we chose linedef type 700, which slopes the front sector's floor. The following is a list of all available types:

Linedef type Sloped surfaces Example WAD
700 Front sector floor File:Ex ld700 slopefrontsidefloor.wad
701 Front sector ceiling File:Ex ld701 slopefrontsideceiling.wad
702 Front sector floor and ceiling File:Ex ld702 slopefrontsidefloorandceiling.wad
703 Front sector floor and back sector ceiling File:Ex ld703 slopefrontsidefloorandbacksideceiling.wad
710 Back sector floor File:Ex ld710 slopebacksidefloor.wad
711 Back sector ceiling File:Ex ld711 slopebacksideceiling.wad
712 Back sector floor and ceiling File:Ex ld712 slopebacksidefloorandceiling.wad
713 Back sector floor and front sector ceiling File:Ex ld713 slopebacksidefloorandfrontsideceiling.wad

By default, sector-based slopes are dynamic; they will always be defined by the heights of two adjacent surfaces. If you change the height of one of the surfaces at runtime, for example via linedef type 400, the slope will automatically move along with it. This way, you can create dynamically moving slopes. If you give a linedef with one of the above slope specials the No Tails flag, the slope of its associated sector will not be dynamic; it will stay in place regardless of the heights of the two surfaces that the slope was created with.

## Vertex slopes

To create a vertex-based slope, first create a sector that you want to slope. Again you need to decide whether you want to slope the floor or the ceiling of the sector. In this example, we will slope the floor. Select one of the sector's linedefs. If it faces inwards, give it linedef type 704, which slopes the front sector's floor. If it faces outwards, give it linedef type 714, which slopes the back sector's floor. If you want to slope the ceiling instead, use linedef types 705 or 715, respectively.

To define the slope of our sector, we will define a plane in 3D space. This can be done by supplying three points that the plane must go through. In SRB2, these three points are represented with so-called slope vertices, which are Things of Thing type 750. Place three such Things on the map at the points that you want the plane to go through. Give the linedef with the slope special an unused tag and set the Angle value of the slope vertices to that tag. The game will then calculate the plane defined by the three slope vertices and use it to define the slope of the sector. Note that the slope vertices don't necessarily have to be placed inside the sector that you want to slope; they can be placed anywhere in the map. Experiment with the positions and heights of the slope vertices until you get the slope you want.

If you give the linedef with the slope special the No Knuckles flag, the game will search for the associated slope vertices differently: Instead of searching for three slope vertices whose Angle matches the linedef's tag, it will search for one slope vertex that matches the tag, one that matches the X offset of the sidedef that faces the sloped sector (i.e. the front sidedef if the front sector is being sloped and the back sidedef if the back sector is being sloped) and one that matches the sidedef's Y offset. This makes it possible to share slope vertices between different slopes; it is also useful for making dynamic vertex-based slopes (see below).

The following table outlines the available linedef types for vertex-based slopes and the surfaces they slope:

Linedef type Sloped surfaces Example WAD
704 Front sector floor File:Ex ld704 slopefrontsidefloorbyvertices.wad
705 Front sector ceiling File:Ex ld705 slopefrontsideceilingbyvertices.wad
714 Back sector floor File:Ex ld714 slopebacksidefloorbyvertices.wad
715 Back sector ceiling File:Ex ld715 slopebacksideceilingbyvertices.wad

### Dynamic vertex slopes

By default, vertex-based slopes are not dynamic; they will stay in place even if their slope vertices are moved. You can make a vertex-based slope dynamic by giving the linedef with the slope special the No Tails flag; the slope will then move along with its slope vertices. In order to dynamically change the height of the slope vertices, you need to use linedef type 799, Set Tagged Dynamic Slope Vertex to Front Sector Height.

For each slope vertex whose height you want to change dynamically, create a control sector, give one of linedefs linedef type 799 and set the linedef's tag to the Angle value of the slope vertex. Set the floor height of the control sector to the height that you want the slope vertex to have initially, before it is moved. The height of the slope vertex will now be controlled by the floor height of the control sector; the height of the slope vertex Thing itself will be ignored. This means that if the control sector's floor is moved at runtime, the slope vertex will move along with it, thus dynamically changing the slope. In order to change the control sector's floor height dynamically, you can use linedef executors like linedef type 403 or continuous floor movers like linedef type 54.

Note that linedef type 799 controls the height of all slope vertices whose Angle value matches the linedef's tag. The default setup of vertex-based slopes requires that all slope vertices belonging to a slope have the same Angle value. If you use linedef type 799 on such a slope, the slope will become flat since all slope vertices are set to the same height. Therefore, dynamic vertex-based slopes should use the No Knuckles flag, which allows the slope vertices to have different Angle values.

## Copied slopes

Instead of defining a new slope for a sector, it's also possible to copy the slope of another sector to the current sector. To do this, give one of the linedefs of the current sector linedef type 720 (for copying the floor slope), 721 (for copying the ceiling slope) or 722 (for copying both). Make sure that the linedef faces inwards, since all three linedef types slope the front sector. Then, tag the linedef to the sector that contains the slope you want to copy. The plane that defines that sector's slope will be copied to create the slope of the current sector.

The following table outlines the available linedef types for copied slopes and the surfaces they slope:

Linedef type Sloped surfaces Example WAD
720 Front sector floor File:Ex ld720 copyfrontsidefloorslope.wad
721 Front sector ceiling File:Ex ld721 copyfrontsideceilingslope.wad
722 Front sector floor and ceiling File:Ex ld722 copyfrontsidefloorandceilingslope.wad

Note that the properties of the tagged sector's slope will be passed on to the front sector's copy of the slope. For instance, if the original slope was dynamic, the front sector's copy of the slope will also be dynamic and will move whenever the original slope does. If the original slope had slope physics turned off, the copied slope will also have slope physics turned off.

## FOF slopes

Both sector-based slopes and vertex-based slopes can be used on FOFs:

• To use a vertex-based slope on an FOF, give the slope special to one of the control sector's linedef. Then, place the slope vertices inside the map and tag them like you would normally.
• To use a sector-based slope on an FOF, create a new sector adjacent to the FOF's control sector that shares one linedef with it. Then you can set up the slope like you would for a normal in-map sector by giving the shared linedef a slope special and setting the floor/ceiling heights of the two sectors. However, the problem with this method is that the position of the slope depends on the position of the control sector, which can make it difficult to line up the slope with the in-map FOFs. Therefore, vertex-based slopes may be more convenient for FOFs, since you place the slope vertices inside the map itself.

## Texture skewing

When a middle texture is attached to a sloped surface, it will automatically be skewed to match the angle of the slope. By default, middle textures are attached to the ceiling, so they will be skewed according to the ceiling's slope. You can attach a middle texture to the floor instead by set the Lower Unpegged flag or the Peg Midtexture flag on the linedef (but not both). If you want to disable the skewing effect, set the No Midtexture Skew flag.

Upper and lower textures are not skewed by default, but you can enable skewing by setting the Slope Skew flag on the linedef. A texture will always be skewed towards the surface it is pegged to: The lower texture will be skewed towards the higher of the two adjacent floor by default. If the Lower Unpegged flag is set, it will be skewed towards the lower floor instead. The upper texture will be skewed towards the lower of the two adjacent ceilings by default. If the Upper Unpegged flag is set, it will be skewed towards the higher ceiling instead.

The textures of FOFs cannot be skewed at the moment.