Timed linedef executor/Upper Unpegged

From SRB2 Wiki
Jump to navigation Jump to search

This tutorial will explain how to set up a timed linedef executor through the use of the Upper Unpegged flag. Setting the Upper Unpegged flag on a linedef executor give that linedef executor a delay. The duration of the delay, in tics, is set by the sum of the floor and ceiling height of the linedef's back sector. In addition to simple delays, this allows mappers to create chains of multiple timed effects, as well as looped effects that repeat indefinitely.

An alternative to the Upper Unpegged method is to use gargoyle boxes. See Timed linedef executor > Comparison for a comparison of the two methods.

Simple delay

The setup for a delayed linedef executor. Click image to enlarge.

We will start by setting up a simple delayed effect: a button that raises another sector's floor two seconds after being pressed. Make a simple test map and add two sectors to it. Choose one of them as the button sector and give it tag 1. The other sector is the one whose floor will be raised; give it tag 2. Since its floor will later be raised, you also need to add a lower texture to its outer sides.

Next you need to set up the linedef executor. Give the button sector the Trigger Linedef Executor (Floor Touch) effect so that it acts as a trigger sector. Now create a control sector outside the level boundaries. Choose one of its linedefs as the trigger linedef; give it tag 1 and linedef type 302, Trigger Linedef Executor – Once. Choose another linedef as the linedef executor command and give it tag 2. There are several linedef types that can be used to raise floors; for this tutorial we will use linedef type 405, Move Floor According to Front Texture Offsets. As the name implies, the speed and distance to move the target sector's floor is controlled by the linedef's front X and Y offsets. The X offset sets the speed; a good value for this is 64. The Y offset controls by how many fracunits the target sector will be raised; a good value for this is 128.

If you test the map now, stepping on the button sector should immediately raise the other sector's floor by 128 fracunits. Now we want to delay this effect. Select the linedef with type 403 and give it the Upper Unpegged. Setting this flag will tell SRB2 to delay the linedef executor effect. The duration of the delay, in tics (35 tics = 1 second), is set by the sum of the floor and ceiling height of the linedef's back sector.

Since our linedef doesn't have a back sector yet, you need to create one for it, either by drawing another sector and dragging it around until it overlaps with the linedef executor control sector, or by using Draw Lines Mode in Zone Builder to draw the back sector directly. After drawing the new sector, make sure that the linedef executor's back side faces it. Now you can set the delay in the new sector. We want to delay the effect by two seconds, so set the floor height to 0 and the ceiling height to 70. If you test your map now, there should be a delay of two seconds before the floor is raised.

Note that if a linedef executor with the Upper Unpegged flag doesn't have a back side, the game will crash.

Looped effect

The setup for a linedef executor loop. Click image to enlarge.

Timed linedef executors can also be used to create effects that repeat in an infinite loop. In this section, we will modify the effect from the previous section to create a looped effect. In addition to raising the floor after two seconds, we will lower it again after two more seconds and then call the trigger linedef again to repeat the effect. This will create an infinite loop in which the floor moves up and down periodically.

First we need to set up the effect that will lower the floor again. This works just like with the previous linedef executor: Select another linedef in the control sector and give it linedef type 405 as well as tag 2. For the front X offset, use 64 again so that the floor moves with the same speed as before. For the front Y offset, use -128 so that the floor moves down by 128 fracunits, back to its original position. Now give the linedef the Upper Unpegged flag to delay the effect. Create a back sector for it and set its floor heights to 0 and its ceiling height to 140. The effect will now execute four seconds after the button is pressed, which is two seconds after the floor is raised.

Now we want to loop the effect. The idea is to use linedef type 450, Execute Linedef Executor (specific tag). When triggered, this linedef will call a trigger linedef with the specified tag. By adding this effect to our control sector and tagging it to the control sector's trigger linedef, we can create a linedef executor that calls itself again after being finished, creating an infinite loop.

Select another unused linedef in our control sector and give it type 450. Our trigger linedef has tag 1, so give the new linedef tag 1 as well. Now the linedef executor will call itself again, creating a loop. However, if you were to test your level right now, the game would freeze as soon as you press the button. The problem is that linedef type 450 has no delay, so it is executed immediately once the trigger linedef is activated. This means that it will call the trigger linedef again in the same tic, so the linedef executor will trigger itself again and again before advancing to the next tic, causing the game to get stuck in an infinite loop. To avoid this, you need to add a delay to the linedef with type 450 as well. As usual, give it the Upper Unpegged flag and add a back sector. We want the floor to be raised and lowered every two seconds. To achieve this, we need to call the trigger linedef after a delay of four seconds, at the same time as we are starting to lower the floor. Give the back sector a floor height of 0 and a ceiling height of 140.

However, there is one problem left to solve. If you test the map now, you will see that the floor is raised and lowered once, but then the effect stops working. The reason for this is that we used the "Once" type for our trigger linedef, so it can't be triggered again. The ideal trigger type to use here would be "Each Time", but unfortunately, linedef type 450 doesn't work with "Each Time" trigger. Instead, you will have to use linedef type 300, Trigger Linedef Executor – Continuous. The problem with the "Continuous" type is that it will be called in every tic as long as the player is touching button. This will lead to strange behavior. We want the player to trigger the linedef executor only once, by pressing the button. Afterwards, it should only be triggered by itself so that it runs in a loop.

To achieve this, we need another control sector. Give one of its linedefs type 302 and the next unused tag (which should be 3). Now change the tag of the button sector to 3 as well. Now the button will trigger our new linedef executor with the "Once" type instead of the one that runs in a loop. Select another linedef in our new control sector and give it type 450 and a tag of 1. Now this linedef will call the original linedef executor once the player presses the button. The last step is to change the type of the original trigger linedef to 300. Now the effect will work as intended. The original linedef executor now has the "Continuous" type, so now it can call itself again and run in a loop, but the new linedef executor has the "Once" type, so the player can only trigger the effect once.

This setup works for looped effects that are triggered by the player. To create a loop that starts as soon as the level is loaded, change the type of the new trigger linedef to linedef type 399, Trigger Linedef Executor – Level Load.

Dynamically changing the delay

Since the delay is controlled by the back sector's floor and ceiling height, it's possible change the delay of a timed linedef executor dynamically during the level by using another linedef executor to move the sector's floor or ceiling. Linedef type 400 and linedef type 401 are best suited for this, since they change the floor/ceiling height immediately instead of raising/lowering it over time.

In loops or chains consisting of multiple timed effects, changing the delays of the individual effects also allows you to change the order in which they are executed.

Limitations

  • In a sequence of loop consisting of multiple effects, you cannot add or remove specific effects dynamically. If you want to do this, set up a gargoyle box and use linedef type 409 to change the tags of the trigger sectors that trigger the individual effects.
  • Loops or sequences of multiple effects created with the Upper Unpegged method cannot be stopped and restarted dynamically. To do this, use a gargoyle box with accelerative scrollers and dynamically set their speed to 0.

Sample

Sample 1

Example file: ex_timedlinedefexecutor_upperunpegged_delay.wad (MAP01)
How to use
  • You may load this file into your favorite map editor, such as Zone Builder. Select MAP01 as the map to load.
  • You may also load this file in the game:
    1. Save ex_timedlinedefexecutor_upperunpegged_delay.wad into the addons folder of your SRB2 directory.
    2. Start SRB2, go to the Addons menu, and then select ex_timedlinedefexecutor_upperunpegged_delay.wad.
    3. Start the game in Single Player mode.
    4. Press the Console button (~), and type in the command MAP MAP01 to access the example map.
  • When you load this file in the game, it replaces Greenflower Zone Act 1.


Sample 2

Example file: ex_timedlinedefexecutor_upperunpegged_loop.wad (MAP01)
How to use
  • You may load this file into your favorite map editor, such as Zone Builder. Select MAP01 as the map to load.
  • You may also load this file in the game:
    1. Save ex_timedlinedefexecutor_upperunpegged_loop.wad into the addons folder of your SRB2 directory.
    2. Start SRB2, go to the Addons menu, and then select ex_timedlinedefexecutor_upperunpegged_loop.wad.
    3. Start the game in Single Player mode.
    4. Press the Console button (~), and type in the command MAP MAP01 to access the example map.
  • When you load this file in the game, it replaces Greenflower Zone Act 1.