WDFUSE Tutorial - Scripting III

From DF21 Wiki
Revision as of 21:23, 2 July 2022 by DF21net (talk | contribs) (Created page with "== Scrolling == Let's continue to the hallway at the top where you can learn about scrolling elevators. Every time you see a flowing river or a waterfall; all of it is performed using the scrolling mechanism. === Scrolling Floors === All flowing water in the game is performed with scrolling floors. Come to the river and take a look. You can hear water flowing. none|thumb|928x928px Lets look at the '''WATER''' sector code. You can see that it is a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Scrolling

Let's continue to the hallway at the top where you can learn about scrolling elevators. Every time you see a flowing river or a waterfall; all of it is performed using the scrolling mechanism.

Scrolling Floors

All flowing water in the game is performed with scrolling floors. Come to the river and take a look. You can hear water flowing.

Lets look at the WATER sector code. You can see that it is a new type of elevator.

seq
  class: elevator scroll_floor
      sound: 2 water1.voc
      angle: 270
      speed: 5
seqend


Elevator Scroll_Floor does what the name implies. It just moves the texture on the floor. You can also see that the elevator has a new parameter called angle - all it does is move the water flow in a particular direction. Additionally, to make a nice soothing sound effect, it has a sound value of a waterflow. This means that anytime you are near this sector you will hear WATER1.VOC .

Scrolling Walls

Continue down the hallway and you will see two walls. The one on the right is scrolling and the one on the left is not.

Lets look at the code of the sector SCROLL. It is an elevator class of scroll_wall.

seq
  class: elevator scroll_wall
      angle: 90
      speed: 30
seqend


Scroll_Wall elevators move a wall along a particular angle and speed. They can be applied to the whole sector or a single wall.

You must be wondering, how come the wall on the left is not moving? It's because for a scroll wall to work properly, you would need to apply a specific flag.

Once the sector is set to be a scroll wall sector you must specify which of the wall sections (TOP / MID / BOT / SIGN ) should scroll. Depending on which you select, they will begin scrolling. To fix the other wall simply change the flag go 128 (Scroll Mid).

Once you fix the other wall you may notice that it scrolls at the same angle as the other one . That's because all the walls always move with the sector's angle command. Lets continue down the hall and around the corner.

Here you will see a sign that changes between different aurebesh letters. Lets look at the texture first.

You will see that it is a long texture divided into three parts. How does Dark Forces render it? Click on the SIGN sector code.

seq
  class: elevator scroll_wall
      angle: 0
      speed: 0
      event_mask: 0
    stop: 0 2
    stop: 43 3
    stop: 86 6
    stop: 0 5
    stop: 43 5
    stop: 86 3
seqend

As you see above, this sector is also a scroll_wall elevator class. However in this case, instead of using a hardcoded angle, it jumps between stops on the texture which are really the vertical offsets. You can see that the height of each sign portion is 43 pixels. The first offset starts with 0 while the second starts with 43 and the last is 86.

To prove that we are just scrolling the texture. Change the floor altitude of the sector to 0 and change the height to 16. Now you can see that the scroll_wall sector just changes the texture offsets as it scrolls.

Lights

You are already familiar that you can change sector or wall ambient lighting. You can also change them using an elevator. Go around the corner and look at the hallway with the changing lights.

This is a simple elevator. If you look at the code you will see that the elevator change_light just has stops that define the value of the light used by the sector.

seq
  class: elevator change_light
    stop: 0 2
    stop: 31 2
seqend

Above, the stop value 0 corresponds to total darkness and value 31 corresponds to full brightness. You can attach a switch trigger to this elevator and turn room lights on and off as you please!

Morphing Elevators

Go around the corner and look at this large room with multiple moving shapes,