How do I add more Map Planes to my game?
Most modern Wolfenstein 3D Editors allow for editing maps with more than just the Walls and Objects planes. But to use this, a minor change needs to be made to the engine itself.
This assumes you've started a new DOS project that successfully builds in Borland C. If you haven't yet, then click here to start.
Tutorial
This tutorial is referenced from WDC's Help Files, written by Adam Biser.
Open up ID_CA.H
and locate this line, fairly close to the top:
#define MAPPLANES 2
Add the amount of extra planes you need. For example, if you need two more planes:
#define MAPPLANES 4
If you choose to add more than 3 map planes, you will need to make a couple of extra changes.
A little further down the file is the following code structure:
typedef struct { long planestart[3]; unsigned planelength[3]; unsigned width,height; char name[16]; } maptype;
Change to the following:
typedef struct { long planestart[MAPPLANES]; unsigned planelength[MAPPLANES]; unsigned width,height; char name[16]; } maptype;
Changing the number in planestart
and planelength
to MAPPLANES
links it to the variable definition we changed earlier. So if you add more map planes in future, you can skip this step and just change #define MAPPLANES
.
There's one more change to make. Open ID_CA.C
and look for the mapfiletype structure:
typedef struct { unsigned RLEWtag; long headeroffsets[100]; byte tileinfo[]; } mapfiletype;
We're going to add a new line:
typedef struct { unsigned RLEWtag; int numplanes; // added long headeroffsets[100]; byte tileinfo[]; } mapfiletype;
Once you've made all these changes, save the project and build your exe file.
How do I use extra planes?
The extra planes won't actually do anything yet. To make them have an effect, look at the following line
#define MAPSPOT(x,y,plane) (mapsegs[plane][((y)*180)+(x)])
This line (Defined in WL_DEF.H
) lets you call the value of a tile's plane using the code MAPSPOT(x,y,plane)
. x
and y
stand for the coordinates of the map tile, and plane
represents the map plane you want to check the value of.
Substitute the values with the coordinates for the tile you would want to target and what plane to check, minus 1. The reason the numbers are reduced by one, is because the engine considers 0
to be the first entry number. Thus, (0,0)
would be the coordinates for the tile in the top left corner.
For example, if you wanted to check the value of the fourth plane the second tile of the first row from the top of the map, you would call MAPSPOT(1,0,3)
. When the game checks the
Let's say you wanted the game to check that tile when the player dies, and determine the amount of ammo they start with by the fourth plane.
Go to WL_GAME.C
and find this code in the Died function.
gamestate.health = 100; gamestate.weapon = gamestate.bestweapon = gamestate.chosenweapon = wp_pistol; gamestate.ammo = STARTAMMO; gamestate.keys = 0; pwallstate = pwallpos = 0; gamestate.attackframe = gamestate.attackcount = gamestate.weaponframe = 0;
Change the ammo line to read as follows
gamestate.ammo = MAPSPOT(1,0,3);
When the player dies, the game will check this code, which will direct it to check that map tile. The numerical value of the tile will be the amount of ammo the player will receive on that particular map. This means you can customize it per level from within the map editor, instead of hardcoding it individually.
To learn how to set up WDC's map editor to use extra planes, click here.