WDFUSE Tutorial - Scripting II

From DF21 Wiki

Doors

Now it is time to go over making and interacting with doors. Keep in mind that everything in Dark Forces that moves is an elevator. This means that doors as well, are just different variations of elevators. One important to keep remember is that while you can always make a door with INF logic, it is much easier to just set the Flag 1 value to 2 (Door).

With that out of the way lets continue to the DOORS1 room.

For this part you may want to move the Player Start so you start immediately in this room.

In front of you are three doors. Lets look at the logic of the one on the left called DOOR1

seq
  class: elevator door
seqend

If you run this in the game you will realize that this is a normal door. In fact, it is identical to you just setting flag value 2 in your Sector Editor.

Look at DOOR2 in the middle. It behaves exactly the same but it makes a different sound. That's because it is a different type of elevator.

seq
  class: elevator inv
      speed: 30
      event_mask: 32
    stop: 0 hold
    stop: 16 5
seqend

You can see it is an elevator of type elevator inv which moves the ceiling altitude. In this case from height 0 to 16. You interact with it by nudging the line from the outside (event_mask 32). This is yet another, albeit more complicated way of making a door.

Now the reason the audio is different for this door is because all elevators have different default audio assigned to them. Here is a nice chart showing all the default values of by elevator type.

(elevs change_light, change_wall_light, scroll_floor, scroll_ceiling,  and scroll_wall)
| sound: 1 0
| sound: 2 0
| sound: 3 0

(elevs move_floor, move_fc, basic, basic_auto, change_offset,  door_inv and bottom half 
of door_mid)
| sound: 1 elev2-1.voc
| sound: 2 elev2-2.voc
| sound: 3 elev2-3.voc

(elevs move_ceiling, inv, morph_move1, morph_move2, morph_spin1,  morph_spin2, move_wall
, rotate_wall and top half of door_mid)
| sound: 1 door2-1.voc
| sound: 2 door2-2.voc
| sound: 3 door2-3.voc

(elevator door)
| sound: 1 door.voc
| sound: 2 0
| sound: 3 0

(trigger standard)
| sound: 0

(triggers switch1, single and toggle)
| sound: switch3.voc


Lets walk to DOOR 3 . You will notice that it moves from top to bottom. In reality it is just a standard elevator move_floor but is built as a door.

seq
  class: elevator move_floor
      sound: 1 DOOR2-1.VOC
      speed: 10
      event_mask: 32
    stop: 16 hold
    stop: 0 5
seqend

We've changed the sound effect so it sounds more like a door instead of an elevator default audio.

Take a closer look and you will see that the walls are not anchored. This is the same problem that you've seen earlier in the tutorial. Remember, you can fix this by adding the Flag 16 (Wall Anchored flag).

Trigger Door Opens

Now