Sector-based spike tutorial
|This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki bythis article.|
Sector-based spikes are spikes that are created out of level geometry instead of spike Things. While Thing-based spikes are generally preferable, since setting them up is much easier and simpler, sector-based spikes may be useful to improve the framerate in very detailed levels, since they reduce the number of sprites that are rendered on the screen. In previous versions of SRB2, sector-based spikes were required for spiked crushers and spikes that retract into the ground and pop up periodically. However, in the current version, these things can be done with Thing-based spikes as well. This tutorial explains how to make various types of sector-based spikes, including floor, ceiling and FOF spikes, both static and movable.
Static floor spikes are the most basic type of sector-based spikes, as well as the easiest to create. They consist of three parts:
- An in-level sector that holds the spike formations. The player collides with this sector, not the individual spikes. This buffers the spikes and ensures optimal collision detection. For this tutorial, we will assume that the spike formation is rectangular, so the in-level sector must be rectangular as well.
- A control sector containing a fake floor linedef. The actual floor of the in-level sector is set to the height of the spike tips so that they appear as solid to the player. To prevent the in-level sector from obscuring the individual spikes, a fake floor is used to make it appear as if the floor were at ground level.
- The spike sectors. They consist of a triangle with 2 fracunit sides and an 8 fracunit linedef sticking out from each of the three vertices of the triangle. The individual triangles are merged into a single sector.
Drawing this setup is very time-consuming, so it is recommended to copy a spike row from an existing level, such as Greenflower Zone Act 2, and modify it for use in your own level. The spikes in GFZ2 are located roughly at the coordinates (4000, 3500), while the control sector for them is located at roughly (3200, 4500).
The floor of the in-level sector should be 42 fracunits higher than that of the surrounding sectors so that it covers the full height of the spikes. The triangle sectors of the spikes should be at the same height. To give the spikes their characteristic effect, both the in-level sector and the triangle sectors should receive sector type 5, Spikes. The in-level sector, but not the triangle sectors, should be given an unused tag.
Give one of the control sector's linedefs linedef type 63, Fake Floor/Ceiling Planes, and tag it to the in-level sector. Since the ceiling should not be a fake plane, give the control sector the same ceiling height as the in-level sector. The floor height should be at the height of the sectors that surround the in-level sector. Both the ceiling flat and the the floor flat of the control sector should match up with the flats you want to use for the in-level sector.
Now the spikes need to be textured. The linedefs of the triangle sectors should have
SPIKEWAL as their lower back texture. The linedefs sticking out from the triangle sector should should be given
SPIKE1 as their front middle texture and
SPIKE2 as their back middle texture. They also need to have the Lower Unpegged flag checked so that the middle textures align with the floor rather than the ceiling. The triangular sectors should have
GREYFLR as their floor flat.
Movable floor spikes
Movable floor spikes can be used for one of two purposes:
- Retractable spikes that pop out of the floor, then recede.
- Spike crushers that pin the player between spikes and another solid Object.
For each purpose, the construction is slightly different.
Retractable floor spikes
Creating spikes that pop out of the floor and then recede requires a normal set of spikes, a control sector containing a solid, opaque FOF (using linedef type 100), as well as two back-to-back control sectors with two Continuous Floor Mover linedefs.
Tag the FOF control linedef to the target sector containing the spikes. The FOF will provide the collision buffer when the spikes go underground. When the spikes have receded, the player will be able to walk over the area without taking damage. Be sure to texture the block appropriately so that it looks exactly like the floor around it.
Next, tag one Continuous Floor Mover linedef to the in-level sector containing the spikes and the other to the base triangles of the spikes. Set the floor height of one control sector to 42 and the other to -42. This will make the spikes rise and fall constantly.
Test the map. You should be able to run over the floor unharmed when the spikes are not visible.
Floor spike crusher
Creating a floor-based spike crusher is a bit more complicated than retractable spikes. These require a dedicated Fake Floor control sector and two sets of two back-to-back control sectors, one with two Continuous Floor Mover linedefs and the other with just one mover linedef.
Just like with the retractable spikes, tag the two Continuous Floor Mover linedefs to the required parts of the spike sectors. Set the floor height of one sector to 214 and the other to 42. This will cause the spikes to rise, fully contact the ceiling but not go through it, then move back down to the floor.
However, simply testing the map in this form will cause the spikes to appear to extend from the floor as though they were "spears" rather than spikes. This may be a desired effect if attempting to recreate the underwater spears from Labyrinth Zone in Sonic 1 for instance. If a solid crusher base is desired, continue to the next step.
Give the dedicated Fake Floor control sector its own tag. Tag the other floor mover linedef to it. Set one sector's floor to 172 and the other to 0. Notice that these values are simply the other control sectors' values with 42 subtracted. This is so that the Fake Floor will always reveal the spikes, but not reveal anything below that point. That is what causes a solid "crusher" to appear.
Test the map. It should appear as a block jutting from the floor with spikes and their associated damage attached.
Ceiling spikes are created similarly to floor spikes, but because sector effects by default only affect the floor and not the ceiling, linedef type 8, Special Sector Properties, has to be used to apply the effect to the ceiling.
Rather than the floor being 42 fracunits higher than that of the surrounding sectors, the ceiling of the in-level sector and the triangle sectors needs to be 42 fracunits lower than that of the surrounding sectors. Similarly, the ceiling height of the control sector needs to be at the height of the sectors that surround the in-level sector, while the floor height needs to be set to the regular floor height of the in-level sector so that there is no fake floor plane.
The spikes also need to be re-textured to use upside-down sprites. The linedefs of the triangle sectors should have
SPIKEWAL as their upper back texture. The linedefs sticking out from the triangle sector should should be given
SPIKEU1 as their front middle texture and
SPIKEU2 as their back middle texture. They also need to have the Lower Unpegged flag unchecked so that the middle textures align with the ceiling rather than the floor. The triangular sectors should have
GREYFLR as their ceiling flat.
Create a new control sector (or use unoccupied linedefs from the Fake Floor control sector) and give two of its linedefs linedef type 8, Special Sector Properties. One of them should be tagged to the rectangular in-level sector and the other to the spike sectors. Check the Not Climbable flag on both control linedefs. This applies the spike damage to the ceiling rather than the floor.