WAD Resource Basics


------------------------------------------------------------------------
These pages of the guide cover the fundamental building blocks of a WAD file: its resources.
------------------------------------------------------------------------


1. WAD Levels 

Each of the three episodes of the registered version of DOOM ('Knee-deep...', 'Shores of Hell' and 'Inferno') is divided into a number (9 actually) of different maps or missions. DOOM II players will know that DOOM II is divided into 32 missions (only 30 in some countries). Each of these missions is usually referred to as a DOOM 'level'. Do not confuse this use of the term 'level' with the level of skill/difficulty at which the mission is being played: the map for each mission contains sufficient information for all 5 levels of difficulty. 

Each DOOM mission has a unique E_M_ (Episode/Mission) identifier which appears in the bottom left corner of the automap (next to the mission's name) during play. These number from E1M1 at the beginning of 'Knee-deep...' and progress through to E3M9 in the 'secret' level of 'Inferno'. DOOM.WAD contains the maps for all 27 DOOM missions (it's not surprising that it's over 10Mb, is it?). DOOM II maps are numbered in a different way. Not being divided into episodes, each of DOOM II's 30 levels are given a MAPxx identifier (with xx being a 2-digit number in the range 01 to 30). Within a WAD file, an E_M_ or MAP__ header (or resource) is used to indicate that all following data (until another such resource is encountered) refers to the corresponding level during play.

Raven Software's Heretic program employs the same level designation system as DOOM, using the E_M_ resource to identify the level, while Hexen uses the DOOM II MAPxx resource. Provided that your editor is DOOM II (and/or Heretic) compatible, it should handle the differences automatically.

Although external PWADs can contain replacement maps for any of the original missions, some editors will not allow you to create replacements for level E1M1 to E1M9. This to comply with id Software's request that editors shall not work with the shareware version of the game.

It is usually easiest when building a multi-level WAD to develop just one level at a time, keeping these in separate WADs until they are all finished. Most editors will allow you to glue these separate WADs together into one super-WAD when they are all tested and ready for distribution. There is nothing to stop you from just distributing your WADs as single-level WADs though -- given the vast amount of work that goes into a good level, this is what most designers prefer to do.



2. Lines as Resources

If you look carefully at DOOM's automap, you will notice that what it shows is a series of (generally) interconnecting straight lines. There are no curves anywhere. (If you think you can see some, just zoom in a bit and take a closer look.) Thisis true throughout all versions and developments of the game. It is this series of straight lines which forms the basis of any DOOM level map. Within a WAD file, these lines are broken down and arranged into a series of resources, which together provide DOOM with the information necessary for the correct rendering of its world. Fortunately, it is not necessary to understand the mechanism by which the DOOM engine performs this magic, only to have a basic understanding of the fairly simple resources which it uses. A good editor will further simplify the concepts that the would-be map-builder needs to grasp by not troubling the designer unnecessarily with detail which can be computed and assigned automatically.



3. The LINEDEF Resource

Each line of a DOOM level map is specified in the WAD file by a resource called a LINEDEF (for 'Line definition'). Each LINEDEF specifies to the DOOM engine vital information about just one of the lines of the map: information such as where the line runs; what the line represents; whether the line does anything special as the player reaches it and so on. Information about LINEDEF attributes are given in the next section: full details of what can be specified in a LINEDEF is given in the LINEDEF reference pages of this guide.



4. The VERTEX Resource

The actual location of a line in DOOM space is determined by the location of its ends (obvious really!): these end locations are specified in the WAD file through another resource, called a VERTEX. The VERTEX is the simplest of WAD resources to understand: it consists of nothing more than an X- (easting) and a Y- (northing) co-ordinate. DOOM's co-ordinate system is a simple 2-dimensional space (there being no height information here) running from -32768 to +32767 in each dimension. Each co-ordinate unit equates to about 1.25 inches on the virtual ground of DOOM, which means that, in theory at least, each level's gaming space could occupy an area in excess of 1 mile square. In practice, though, levels have to be much smaller than this. 

A good editor should allow the map designer to largely forget about the DOOM co-ordinate system. You should only need to use them to gauge the rough size of the rooms and objects (pillars, doors and such) and check on the alignment of the items that you are drawing. You should not need to concern yourself unduly with the business of generating VERTEXes and LINEDEFs, either, as much of this should be taken care of automatically by the editor. All you should need to do is draw lines with the editor generating appropriate VERTEXes and LINEDEFs for you.



5. The SIDEDEF Resource

If you are familiar with Matt Fell's Unofficial DOOM specs, you will know that the WAD files hold another important resource related to line drawing, the SIDEDEF. SIDEDEFs tell the DOOM engine how lines look when viewed from their side by the player - in other words, how whatever is represented by the line should be rendered on the screen. There is more about SIDEDEFs in the next section of this guide.

Some editors take the (altogether reasonable) view that a SIDEDEF is really just another property of a LINEDEF and will show all appropriate SIDEDEF information whenever you're working with a LINEDEF. This is generally a natural way to work: the combined SIDEDEF and LINEDEF information is usually just termed a LINE. To give you a better understanding of the way LINEDEFs operate, however, it is useful to continue to draw the distinction between LINEDEFs and SIDEDEFs in this overview of the WAD resource structures.



6. One or Two SIDEDEFs to the LINEDEF?

As it is perfectly possible for some LINEDEFs to be viewed by the player from either side, the possibility exists that any particular LINEDEF may require two different SIDEDEFs: one to cater for each of the different views from the two sides of the line. If is impossible for a player to get 'behind' any particular line, then the 'back' of the line will not be need a SIDEDEF (if the player can't see the 'back' of the line, the DOOM engine will never need to render it on screen) and space can be saved in the WAD file. There is more information on whether lines need to be 1- or 2-sided in later pages.



7. LINEDEFs as vectors

It is important to realise that for the purpose of assigning SIDEDEFs, LINEDEFs in WAD files are all vectored: in other words, lines in DOOM space run in particular directions, from one VERTEX to another. The reason for this is that there has to be some way of identifying which side of a LINEDEF a particular SIDEDEF is attached to. Lines are therefore regarded as having a "right" side and a "left" side. These sides are defined from the perspective of someone looking along the direction of the line: simply imagine yourself standing on the 'from' VERTEX, looking towards the 'to' VERTEX:

<Picture: Sorry, you'll just have to imagine it!>

Fig 1: Imagine you're looking along the line: the tick mark shows the line's right-hand side.


Any LINEDEF with only one SIDEDEF must have that SIDEDEF attached to its 'right' side. To help you with this, most editors watch the way you draw your lines and mark in some way the direction of the LINEDEFs that are created. This may consist of drawing an arrow-head at one end of the line, showing the direction in which the LINEDEF 'runs', or the right side of the LINEDEF may be marked in a particular way - by means of a short tick protruding from that side of the line, for instance:

<Picture: DEU example>

Fig 2: DEU's view of four lines drawn in a clockwise manner...

<Picture: Waded example>

Fig 3: Waded's view of the same four lines




8. 'Right' as 'Front'

Sometimes in this guide, a line's "right" side is referred to as its "front", because it is often more helpful to think in terms of the player's view of the line. Similarly, I may talk of the "back" of a line when what I mean is really the "left" side in DOOM spec parlance.

Allowing single-sided LINEDEFs is one way of cutting down the overall size of WAD files, because it reduces the number of SIDEDEFs that are needed. The penalty to be paid is that the map designer needs to give thought to the actual line-drawing process to ensure that all lines travel in the correct direction. The implications of all this LINEDEF-handedness are covered in the Putting it all together section of this guide, which also give some simple guidelines for making sure your lines always run the right way. If you've chosen the right editor, you shouldn't need to worry about getting the odd line wrong though, because it should be easy to flip lines around at any time.



9. The SECTOR Resource

All this talk about 2-dimensional game space may be puzzling or worrying you - after all, isn't DOOM one of the best 3-dimensional gaming engines around? DOOM's (pseudo-)third dimension enters though the use of SECTORs. A SECTOR is an area of the map into which a player can move (or see) which is completely enclosed by SIDEDEFs. Apart from the lines enclosing its area, each SECTOR has floor and a ceiling specification associated with it, as well as a lighting intensity. It is also possible to set some special (usually unhealthy) actions which affect the player while occupying the SECTOR. Most wondrous of all, SECTORs can be animated. It is through the versatility of DOOM's SECTOR actions that most of the special effects so characteristic of the best DOOM levels are implemented. SECTORs can be set to exhibit certain characteristics all of the time (they do damage to the player, or their light levels flicker etc) or only when certain triggers activate them. Triggers are explained next.



10. Triggers and Tags 

The triggers that cause particular SECTORs to respond in some way to particular actions are not stored in the WAD as a separate resource but are, in fact, merely a characteristic of particular LINEDEFs. Some triggers know automatically (because of their type) which SECTOR to activate; others require their 'target' SECTOR(s) to be identified by means of tags. Tags are simply arbitrary identification numbers which are attached to both the trigger and the target - the DOOM engine matches them up when the trigger is activated. Because tag numbers can be chosen arbitrarily, a good editor should take care of tag maintenance for you and should not require you to keep track of what numbers are in use and where they are. Full details of all known trigger types (also known as line-types, because they are always attached to lines) are given in the Trigger-types pages of this guide.



11. The TEXTURE Resource

The graphic patterns which the DOOM engine paints on floors, walls and ceilings are held in a variety of TEXTURE resources. The editing and introduction of new TEXTUREs for use in your own WAD files is not a simple matter: most editors do not provide such facilities - you will need additional utilities to achieve such effects. It is recommended that beginners become thoroughly familiar with the use of existing TEXTUREs before they contemplate adding any of their own. A good editor will allow you to preview the standard TEXTUREs, and their alignment on your walls, though. The Applying TEXTUREs: Making Walls, Floors and Ceilings Look Right pages of this guide contains more information about this resource. 



12. The SEG, SSECTOR, NODE, REJECT and BLOCKMAP Resources

If you've read Matt Fell's Unofficial DOOM Specs, you will know that the DOOM engine requires a whole lot more information about DOOM levels before it can render them correctly on the screen. In addition, information needs to be arranged in particular ways and a lot of pre-calculations need to have been performed, if we want the engine to work its magic in anything approaching real time. A good editor should take care of all of these additional complications automatically, recalculating and building as necessary such esoteric wonders as the BSP tree and its associated SEG, NODE, SSECTOR, REJECT and BLOCKMAP resources. Many editors leave the calculation of these resources to external or add-on NODE and REJECT builders. Check the documentation to see whether yours does or not.



13. The THING Resource

DOOM geography is all very well and good but without its collection of monsters to waste and goodies to collect, it's all just so much scenery. All editors let you populate and decorate your DOOM levels with a collection of goodies (and baddies), all grouped together in WAD files as THING resources. THINGs are divided up into 9 categories: Players; Enemies; Gore; Weapons; Ammunition; Power-ups; Keycards; Obstacles (or Decorations) and Others - see the THING reference pages for details. Each THING also has a set of attributes associated with it.

Editors should let you place any of these items in any location in a level: clever ones will make sure you've not put THINGs where they won't fit. You can have as many or as few THINGs in a level as you fancy (in theory: obviously, there will be some upper limit but no-one seems to know what it is). Themore there are, though, the harder DOOM has to work to keep track of them all. If there are more than about 64 in view at one time, DOOM cannot cope and you will find that some of your objects flicker in and out of existence. Before that, though, you may find that the level has become unplayable as it slows to a crawl. There is also a danger of having too much information for DOOM's save buffer if there are too many THINGs in your levels: this renders the level impossible to save. Your WADs will not be popular if players can't save their games.

One THING which must be present for a WAD to be usable is a (single) Player 1 Start Position: without this DOOM doesn't know where the player is and then all sorts of dreadful things can happen. Far, far worse than if the Spider Boss gets you, believe me!