Gravity Special

By Richard Clark

1/4 Gravity in Action
Figure 1: 1/4 Gravity in Action

One of the things that bothered me about Doom maps was the fact that the gravity was always the same, no matter the environment. However, that has changed with ZDoom. ZDoom has implemented an easy-to-use gravity special so now the level designer can be much truer to real world conditions.

Map Layout in WadAuthor
Figure 2: Map Layout in WadAuthor

Figure 2 shows the map layout in the example wad, grav.wad. The numbers in Figure 2 are just for illustrative purposes and do not represent real sector or line numbers. Sector #3, has a floor height of 128. Normally, you would not be able to jump over a sector of that height, but sector #1 has 1/4 normal gravity. The illustration in Figure 1 shows the player imitating Superman by leaping over tall sectors in a single bound. :)

The gravity for sector #1 is constant at 1/4 and is set via an OPEN script:

#include "zcommon.acs"

script 1 OPEN
    // One-fourth gravity
    Sector_SetGravity(1, 0, 25);

An OPEN script is a script that is executed during map load.

Sector_SetGravity tag, integral-part, fractional-part

Gravity is calculated according to the following equation (from the ZDoom reference): sv_gravity * (integral-part + fractional-part * 0.01), where sv_gravity is a cvar that defines normal gravity. Half normal gravity would be:

Sector_SetGravity(1, 0, 50);
sv_gravity * (0 + 50 * .01)
sv_gravity * (50 * .01)
sv_gravity * (.50)

You can see that using the above equation, you would be multiplying sv_gravity by half, which is what you would expect.

Once the player get into sector #2, (s)he cannot get back into sector #1 because the gravity is normal in that sector and the player cannot jump high enough.

However, using the switch, the gravity of sector #2 to will be set to 1/4 normal allowing the player to jump over the high floor of sector #3.

Using a Switch to Change Gravity
Figure 3: Using a Switch to Change Gravity

Figure 3 illustrates the switch set up. The Sector_SetGravity special is tagged to sector #2's tag, and is marked repeatable and player uses. Once the player uses the switch, (s)he will be able to jump over the high floor of sector #3.

I decided that I didn't want the gravity to stay at 1/4 normal for sector #2, so when the player crosses the line marked in Figure 2 as line #1, the gravity is set back to normal.

Using a Line to Change Gravity
Figure 4: Using a Line to Change Gravity

The line is marked as repeatable and is set to activate when the player crosses the line. If the player jumps back into sector #2 after crossing line #1, (s)he will find that gravity is back to normal and in order to jump over sector #3, the switch will have to be used again.

Using the gravity special is quite easy but really adds a nice touch to the map.


ZDoom reference by Randy Heit.