Knowledge Base - Two Story Building
Two Story Building
As everyone knows, the Doom engine is a 2D engine. You cannot have sectors over sectors which prevented 3D type structures like bridges and rooms over rooms. That is, until now. By using a Dehacked Patch, the Transfer Heights special and some ingenuity, I have created a very convincing room over room map. Basically, I have extended the K²Bridge effect to include a whole room.
The sample wad, twostory.zip has the example map, Dehacked patch and a Cyan colored bitmap that replaces a set of sprites in the game.
Figure 1 shows the outside portion of the map. The lift to the left leads to the second floor while the door leads to the first floor. Figure 2 shows the first floor of the building. The elevator in the background leads to the second floor. Figure 3 shows the second floor, directly over the first floor, with a passage that leads to the outside area where the lift is located.
The map is a bit complicated so I will take my time and go over it in detail. Refer to Figure 4 for the map layout.
The first step is to create the appropriate sectors. The sectors marked 0 to 256 will contain the two floors, while the other sectors will be regular Doom sectors. Notice that there are three control sectors on the map. These sectors contain a linedef that is marked with the Transfer_Heights special. Each line is tagged to the appropriate sector listed in Figure 4.
In order to be a convincing effect, the first floor must have a ceiling at 128 units and the second floor must have a floor at 128 units. The sprites marked Bridge are hanging sprites dehacked to a width of 128 and a height of 0. When placing the sprite in the map, the Z parameter is set to 128. Since this sprite (GOR2A0) normally hangs from the ceiling, this will position the sprite at the 128 unit level. The sprite also blocks the player, so the player can walk on top of it. In order to make it invisible, I replaced the picture with a 1 pixel X 1 pixel cyan patch.
The map still needs to have a floor and ceiling drawn at the 128 unit level to complete the illusion. This is accomplished by using the Transfer_Heights special. The control sectors have a floor of 128 and a ceiling height of 256. The Transfer_Heights is what is also used in the Deep Water effect and is used exactly the same here. By using appropriate textures, you can put a ceiling and floor to each level of the room. Figures 2 and 3 show the deep water effect drawing the ceiling and floor respectively.
So far the effect looks quite good and the player can walk around on the first and second floors easily. However, there are some problem areas, the first being the elevator. In order to keep the floor from disappearing when you step off the elevator into the first floor, it has to have its own control sector set to the same heights as the sectors containing the two floors. This is set by the second control sector from the left.
The other problem is the sectors with the sprites labelled blocking. Figure 5 shows the two sectors that contain the blocking sprites.
The blocker sprite is (GOR1A0) is dehacked to a width of 32 and a height of 128. The sprite also blocks the player but it is placed with a Z parameter of 0. Also notice the yellow lines in Figure 5. These lines have a main texture that is upper pegged. If these blockers and textures were not present you could see and walk into the main entrance hallway and the elevator entrance ruining the illusion. Figures 6 show the two areas with the textures removed.
As Figure 6 illustrates, these flaws can really ruin the two story effect. However, by using the texture pegged to the ceiling and using the blocking sprite, the illusion is preserved.
There is one last flaw that is unfortunately, unavoidable. When the player moves from the outside area into the door hallway, the ceiling flickers as you move from a sector that has does not have a transfer heights special to one that does. What I have done is dropped the light level in the hall so that unless the player is looking for it, the change isn't noticeable.
The third control sector from the left is used to paint the floor and ceiling of the hallway leading from the door, to match the two story sectors.
This effect is fairly easy to do, once you understand the sprite settings and how to use the Transfer_Heights special. It just takes some time to map out the floors and cover the flaws. Using ZDoom, Doom isn't limited to a 2D environment any longer.