Jungle Fever - Part 1



Written by Mark Haidekker


Editor's Note - This article series by the author of Jungles of Caldoun, will show level makers how to make their own terrific levels - part-by-part. First off, Mark looks at the art of making a custom WAX for your level.

WAX tutorial

Ok, this time we are talking about an endangered species: the WAX animal. Endangered insofar, as in newer engines, like the JK engine, no more WAXes are used, but true 3D polygon models. None the less this article will provide several fundamentals which may also prove useful otherwise.

So, what is a WAX? Generally speaking, it is any changing object in DF: Opponents (e.g. Stromtroopers, but neither the Welder nor the Turret: These are 3DOs!), shields and revives (they change some colors periodically), the extra life (seems to rotate), and scenery stuff (chairs & tables which change when shot). Technically, a WAX is a collection of Frames and an instruction to the engine how to handle them. I don't want to go into details of how the file looks like (if you are interested in that, please look at the WDFUSE DF specs). Instead, I'd like to cover the practical aspects.

First of all, I'd like to explain some terms which are probably familiar to many of you, but anyway...

All operations are based on BMP or PCX images which are standard pixel image formats for Windows. These contain of a square matrix of pixels (e.g. 128 by 64 dots) and a color palette. This means, that you cannot use arbitrary colors, but only those offered by the palette. The first 32 colors of the DF palette are system colors. Color 0 (black) may be transparent, colors 1 to 31 may be made "light-in-the-dark" colors. While this is optional for BMs, this option is always active when converting into WAXes. The remaining colors differ from level to level (this is the reason why many levels contain blue Kells: The Kell was created for the Jabship palette, and some authors used it with e.g. the Secbase palette, forgetting to convert the Kell WAX properly).

BMP files can be converted into BM format (the BM is used for wall and floor texturing), FME format (FMEs are objects like the Death Star Plans - they look the same from all directions), and, of course WAXes. I suggest that you get Alexei Novikov's BMPDF utility or something similar to interconvert DF files and BMP/PCX files, and some drawing program like Corel Draw.

Now, let's start with an easy one. Get the files WAX2.EXE, 2WAX.EXE, and IARMOR.WAX (UNGOBbed from SPRITES.GOB), and type -

These 2 cells are alternatively displayed to give the effect of a blinking shield
WAX2 /m IARMOR.WAX

There will be three new files: IARMOR.TXT, IARMO000.BMP, and IARMO001.BMP. IARMOR.TXT contains information of how the WAX was built (keep it, we'll soon need it), and the BMP files contain the two bitmap images that are periodically interchanged to give the impression of a pulsating green. Now load the two BMPs into your pixel editor (Corel). These two images are alternating periodically. Now change the green colour of one of the images into red, but use a red that comes from the first colors of the palette (light-in-the-dark), and save the file. Back in DOS, type -

2WAX /m IARMOR.TXT

Based on the instructions stored in IARMOR.TXT, a new WAX is now generated. copy the new IARMOR.WAX into your DARK directory and start DF. You'll now have a new shield blinking alternatively in red and green. It certainly looks ugly, but you've just created your first WAX. Good.

Now, let's have a look at the IARMOR.TXT file. It should look like this (please note that I added line numbers and comments):

1- #Generated by WAX2
2-
3- SET INDIR
4- SET OUTDIR
5- SET PALDIR
6-
7- WAX iarmor.WAX This is the output file name
8- PAL Default pal or specify name
9- WAXES 1 There is 1 state in this file
10- 0: Seq8=0,0,0,0,0,0,0,0 fr=3 ItŽs a single-view WAX
11- SEQS 1 and has only one state
12- 0: Frames=0,1 ...which contains 2 frames
13- Frames 2
14- 0: Cell=0 y=-16
15- 1: Cell=1 y=-16
16- Cells 2 And these are the BMPs for
17- 0: bmp=iarmo000.bmp c=0 those frames
18- 1: bmp=iarmo001.bmp c=0

Please ignore the lines 1 to 6 for now. Let's start from the bottom for an explanation:

There are 2 cells (2 bitmap images) defined in lines 16-18. In lines 13-15, these bitmaps are linked to the frames. One cell is one frame. The reason for this is that you could flip a cell, resulting in two different frames which only use one cell (a memory saver). Lines 11 and 12 put the frames together as a sequence.The sequence tells the engine to switch between the frames (line 12) with the frame rate selected in line 10 ("fr=3"). There is one state (I'll explain states later), this means one WAX ("WAXES 1" in line 9) which is linked to the one sequence in the Seq8= statement. So, if you use this WAX as an object with LOGIC: ANIM, the engine already knows what to do.

This works with more than two bitmaps as well, of course.Take, for example, the SMALFIRE.WAX or the BIGFIRE.WAX from Jungles of Caldoun and tear them apart. they contain 3 and 5 bitmaps, respectively. So the only lines youŽd have to change from the IARMOR.WAX to the 3-frame fire are:

The meaning of "Sqe8=" in line 10 will be explained later. "fr=3" in line 10 specifies 3 changes per second.

The two states of a chair: Intact (left) and broken (right)

Now, we'll focus on the objects with LOGIC: SCENERY, e.g. the chair CHAIR.WAX. Take it apart (WAX2 /m CHAIR.WAX) and look at the CHAIR.TXT file. What's the difference? The LOGIC you assign to the object. LOGIC: SCENERY tells the engine to display the first bitmap until the object was hit, then display the second bitmap. We call this a "state". Thus, the logic SCENERY requires two states: Intact and shot. This is reflected in the part that begins with "WAXES 2". There are 2 states, both as single-views, linked to CHAIR000.BMP (intact) and CHAIR001.BMP (damaged).

Let's try a variation of this theme. Have a look at the orchids in Jungles of Caldoun: Throw a TD at them, and they burn down, leaving over some ashes. This means: Normally, the "healthy orchid" BMP is displayed. After being hit, the second state becomes active, and this one contains more than one BMP. These BMPs are displayed in succession, until after the last one THE ENGINE SWITCHES BACK TO THE FIRST ONE. Why it does so is still unclear to me, but as a consequence, the ash heap must be the first BMP in the burn-down sequence. This looks strange, but I think hardly anybody will notice... :-)


Components of a 2-state WAX with a sequence. Left: Intact orchid (static), then: Components
of the Burn-down sequence, ending with a heap of ashes (rightmost)

If you look at the ORCHID.TXT file, youŽll see that the second entry in the SEQS section, "1: FRAMES=1,2,3,4..." is linked via the CELLS section to several bitmaps. These frames are displayed in succession after the orchid was hit (by an explosion - you cannot hit the orchid with laser fire because I set RADIUS: 0).

9- WAXES 2
10- 0: Seq8=0,0,0,0,0,0,0,0 fr=12 ww=111411 wh=111411 Intact state
11- 1: Seq8=1,1,1,1,1,1,1,1 fr=4 Burn down state
12- SEQS 2
13- 0: Frames=0 Only one
14- 1: Frames=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 Sequence of frames
15- Frames 16
16- 0: Cell=0
17- 1: Cell=6
18- 2: Cell=1
19- 3: Cell=2
20- 4: Cell=3
21- 5: Cell=1
22- 6: Cell=2
23- 7: Cell=3
24- 8: Cell=1
25- 9: Cell=2
26- 10: Cell=3
27- 11: Cell=4
28- 12: Cell=4
29- 13: Cell=5
30- 14: Cell=5
31- 15: Cell=6
32- Cells 7
33- 0: bmp=dryplant.bmp
34- 1: bmp=smalfir0.bmp
35- 2: bmp=smalfir1.bmp
36- 3: bmp=smalfir2.bmp
37- 4: bmp=smalfir3.bmp
38- 5: bmp=smalfir4.bmp
39- 6: bmp=smalfir5.bmp

Moreover, although the burn sequence consists of 15 frames, only 6 BMPs are used. In the first part, frames 2 to 10 in lines 18 to 26, repeatedly change between the 3 bitmaps which we already know from the SMALFIRE wax. Then the fire goes out (lines 27 to 31) AND ENDS WITH THE ONE IN LINE 17.

Another variety of LOGIC SCENERY is the EWOK86.WAX. It contains two animated sequences: Both the "intact" and the "shot" state contain multiple frames (bitmaps), so that the Ewok moves while alive, and burns down so pitifully when shot. Poor one. Still even an Ewok WAX only requires two states and is assigned to LOGIC: SCENERY. Have a look at the text file by disassembling the Ewok, so you can see how it works.

Let's try to analyze an easy opponent, the Remote (REMOTE.WAX), or, better, the Caldoun Wasp (CALDWASP.WAX), which has the same logic. If you use DF2, you'll recognize four states in the TXT file:

7- WAX CALDWASP.WAX
8- PAL
9- WAXES 4
10- 0: Seq8=0,1,2,2,3,4,4,5 fr=20 ww=10485 wh=10485 Fly
11- 1: Seq8=0,1,2,2,3,4,4,5 fr=20 ww=10485 wh=10485 Idle
12- 2: Seq8=7,7,7,7,7,7,7,7 fr=4 ww=10485 wh=10485 Hit (weak)
13- 3: Seq8=7,7,7,7,7,7,7,7 fr=4 ww=10485 wh=10485 Hit (strong)

These states are really quite simple: State 1 is the "idle" mode, i.e. when the wasp has not yet spotted its enemy. The states 2 and 3 are identical, it's the Wasp being hit by laser fire and an explosion, respectively. And, finally, state 0 is the wasp flying around. You'll notice one more thing: start DF, turn on LAREDLITE and walk around an enemy. You'll see that the view changes as you walk around. In the idle state, and in some other states, like walking, there are 8 different views, 8 different BMPs that show the enemy from the angles 0 (front), 45, 90, and so on. This is the significance of the "Seq8=" statement in lines 10 and 11. While the wasp looks the same from all directions when dying (lines 12 and 13), there are different views in IDLE and FLYING mode. These views are linked to the frames with the different numbers in the Seq8= part. In this case, use frame 0 for the front view, frame 1 for 45 degrees, frame 2 for 90 and 135 degrees, and so on. Maybe you'll notice that I omitted the half-rear views from 135 and 225 degrees. Who'll see this in the real game...?

The "shot" state only shows a frontal view. This saves memory (any WAX has to be loaded into RAM, of course). Another memory saver is the FLIP option. If you look at the original Remote, you'll realize that there are not too many BMPs. Most views are created from the same BMPs by just flipping them horizontally or vertically.

Now we come to the last part. Let's analyze a Commando. This time, you get 36 separate bitmaps. The Commando, like most "full-scale" opponents has 13 states, but some of them are unused. There are two 8-view-states: idle (line 15) and walking (line 10). Shooting, Shoot follow through, and dying are frontal views only (you never see an opponent shooting in any other direction than at you!). The "Dead" state (line 14) leaves a FME-cadaver: It is another one-view state and turns with you as you walk around it - it behaves like a FME.

7- WAX commando.WAX
8- PAL
9- WAXES 13
10- 0: Seq8=0,1,2,3,4,5,6,7 fr=5 ww=72089 wh=72089 Walk
11- 1: Seq8=8,8,8,8,8,8,8,8 fr=6 ww=72089 wh=72089 Shoot
12- 2: Seq8=9,9,9,9,9,9,9,9 fr=7 ww=72089 wh=72089 Die (weak)
13- 3: Seq8=10,10,10,10,10,10,10,10 fr=7 ww=72089 wh=72089 Die (strong)
14- 4: Seq8=11,11,11,11,11,11,11,11 fr=12 ww=72089 wh=72089 Dead
15- 5: Seq8=12,13,14,15,16,17,18,19 fr=12 ww=72089 wh=72089 Idle
16- 6: Seq8=20,20,20,20,20,20,20,20 fr=6 ww=72089 wh=72089 Shoot follow-thru
17- 7: Seq8=0,0,0,0,0,0,0,0 fr=12 ww=72089 wh=72089 Unused
18- 8: Seq8=0,0,0,0,0,0,0,0 fr=12 ww=72089 wh=72089 Unused
19- 9: Seq8=0,0,0,0,0,0,0,0 fr=12 ww=72089 wh=72089 Unused
20- 10: Seq8=0,0,0,0,0,0,0,0 fr=12 ww=72089 wh=72089 Unused
21- 11: Seq8=0,0,0,0,0,0,0,0 fr=12 ww=72089 wh=72089 Unused
22- 12: Seq8=21,21,21,21,21,21,21,21 fr=6 ww=72089 wh=72089 Getting hit

The Shoot-follow-through state is worth mentioning as it implements the kick of a gun being fired: The Commando's arm goes up with the force of the gun. It makes the opponents more realistic. The states for all opponents are explained in detail in the DF specs. There are special states like the Dianoga looking around (the Caldoun alligator surfacing), the Dark Troopers using the shield or flying, the Reeyees punching, and so on. Please refer to the DF specs (e,g, WDFUSE help function) for these advanced points.

Finally, a few practical hints. You'll never want to create a WAX from scratch. Always try to disassemble a WAX which comes closest to the one you want to create and let BMPDF generate the makefile. Edit the makefile to suit your needs concerning number and name of BMPs. Keep in mind that you use the same palette that you use in the level (e.g. SECBASE.PAL). The (transparent) background should be black (color 0). BMPs should be kept as small as possible to save RAM. Read the text file that comes woth BMPDF - Alexei did a good job to explain the inner workings of WAXes and the conversion programs.

A few words on the bitmaps: If you start to design your own ones, keep in mind that one of the most important aspects is irregularity. Areas of the same color look unreal, sterile. So always provide some shadows, some speckles with similar colors. Look at the BMs to see what I mean.

An opponent is more than a WAX. There are things fired at you, voices are being played. Sometimes, you find ammo after killing an enemy. Although you cannot define new enemy logics (this is now possible with Jedi Knight), you can get a lot out of the existing ones by replacing the WAX and the other resources, especially the accompanying VOCs. In the next issue of Darkness Falls, IŽll write a few words about how to create or record VOCs, the sound files.

And now, why donŽt you go ahead and write a beautiful level? ;-)