The Simplest Possible Introduction to Hammer

- By Raeven0
This tutorial was last updated on Feb 26, 2006.

Hi! Welcome to the Simplest Possible Introduction to Hammer. I will shortly guide you through the process of creating this marvellous work of art:



In the process, you will be introduced to the functions of the editor, the names of the objects we place, and methods by which the best maps are built.

First, we must ensure that your editor is properly installed and configured. If you have not already bought HL2, you'll need to buy it before continuing. (Yes, it seems obvious, but many people think they should be able to make maps for the game without actually owning a copy of it.)

Second, provided you have a copy of HL2 installed, you must log in to your Steam account and open the Play Games menu. The item you're looking for is Source SDK:

[OR]


Double-click Source SDK. You can then install and run it. The Source SDK (that is, the software development kit or software developer's kit for the game engine called Source) contains many tools; however, the one we're concerned with right now is the Hammer Editor. The Source SDK (including Hammer) can be loaded in different modes for the different games you've installed:



If the Hammer editor does not start properly, it may be necessary to run the Reset Game Configurations and Refresh SDK Content tools from the Source SDK menu. These will ensure that Hammer is set up properly and that all its files are up-to-date.

Third, after the Hammer Editor has been opened, we must ensure that it is properly configured. (The editor will need to know to where it should save its maps, for instance, and which game you will be mapping for.) So, we'll go to Tools, then Options...



Ideally, the editor will already have set itself up, and your Game Configurations tab will look something like this:



The individual fields (such as Default PointEntity class and Hammer Map Directory) may be different from mine, but they should be functional.

Let's add a new FGD here, so that our mapping can be easier later. In the "Game data files" field, select whatever is currently there, and click "Remove." Download one or both of these, depending on the mod for which you're mapping, and unzip them (with WinZip) to some arbitrary folder, such as Steam/SteamApps/<myaccount>/sourcesdk/bin. Then, click "Add," and specify the file that you just unzipped.

Also, we're concerned with the Build Programs tab:



If you've downloaded CST from http://www.zhlt.tk, this is where you will "install" it: in the BSP Executable field, you will specify cstbsp.exe; in the VIS field, cstvis.exe; etc. CST is more powerful than Valve's default tools, so I recommend it.

Does your "game executable" look different from mine? This is because, out of personal preference, I've chosen to use an alternate method of starting the game. "Game executable" is run when you want to test your map, in order to start the game. Rather than run hl2.exe directly, I opt to tell Steam (by running steam.exe) that I'd like to start a game, and Steam takes care of everything. You can leave the game executable alone.

NOTE! Often, your map editor will break itself for no apparent reason. Sometimes it will give an error such as "missing gameinfo.txt in hl2." Frequently, in order to fix problems such as these, the mapper must run the Reset Game Configurations tool from within the Source SDK dialogue box. If ever you run this tool, you will need to set these Hammer options again, since they will be reset. Isn't mapping fun?

Now, your editor being fully set up, you can begin--

MAKING A MAP

A map (also level, VMF, and other names) in Source (Half-Life 2's game engine) consists of solid blocks floating in empty space. The space between these solid blocks is the space in which players play. Consider making a house out of LEGO blocks:



Our little LEGO men cannot physically get inside their table, nor their floor, nor their walls. The LEGO blocks are merely solid objects, and the LEGO men walk around in the space between the blocks.

Therefore, a cube in which players can walk around would consist of six blocks: one floor, one ceiling, and four walls.

So, let's get started...



My Hammer editor looks different from yours!

That's okay. It won't affect how we make our map.

You should have before you three grids and one black square marked Camera. Those three grids are flat views of the map from different angles. The top view looks straight down on the map (up is north, right is east), the front view looks at it from the east (up is up, right is north), and the side view from the south (up is up, right is east).

Sound complex? Nah, just takes a moment to get accustomed to.



This shape would appear on the grids as:



So, the grids are just your map viewed from different directions, for your editing pleasure.

We should place a floor.



This is your Block Tool. It's used to place solid objects (blocks, but also called brushes). Click the Block Tool icon, then click and drag a square in the grids.



You can manipulate the size of this square by clicking and dragging the solid squares along its perimeter. You can also move the square around by clicking and dragging it (the square itself, not the solid squares along its perimeter). When you're satisfied with the outline of your block, press ENTER, and the block will be placed.

You can change the size of your block later by selecting it (with the selection tool) and exploiting the squares around it.

Want to see your block in the 3D (Camera) view? Click the Camera Tool icon:



Then, click and hold in the Camera view, and use the W/A/S/D keys to fly forward, left, backward, and right. You can turn by moving the mouse or with the arrow keys. If you can't find your block, don't worry; using the Camera Tool, click and drag a line toward your block. A new camera will be placed and your Camera view will be changed to see the map through the new camera.



Wait a minute! That block looks hollow!

The block looks hollow because the camera is set to view the map as a wireframe. The left half of this image is a wireframe:



Obviously, this woman is not hollow. Half of her is simply being viewed as a wireframe.

If you want to see your map as it really looks (with colorful solid objects and no wireframes), click the word Camera, then 3D Textured:



Your block will now look solid.

Well, now you have a solid block floating in space. But that's all you have: a solid block floating in space. Not very useful. Well, let's use that block as a floor and add four walls. Remember, you can use the front and side views to control the height of your blocks. The top view is best for controlling the length and width of a block.

First, however, click the selection tool icon:



Then click anywhere on the grid. This will deselect the block you made, so it looks like a normal part of the map.

Now you can proceed to make walls:









The finished product:



Hey, wait a minute. My walls are made of orange bricks, like my floor! Why aren't they made of something more wall-ey, like red bricks?

We know from our geometry classes that each side of our block is called a face. The image used to "paint" a face is called a texture or a material. This toolbar controls which texture a brush's faces will have by default. You can change a face's texture later by opening the Texture Application Tool; from there you can choose a new texture with the Browse button and "paint" the new texture by right-clicking on a face. For more about the Texture Application Tool, see the Hammer help file.

I'm going to change the textures on my blocks.



I merely opened the Texture Application Tool, clicked "Browse," chose a brick texture, and right-clicked the walls.

One last block, then we'll move to the fun part. Close the Texture Application Tool (if it's not already closed) and make a new block, for the ceiling of your room.



And now, after all that, you have a simple cubic room:



Hoorah, hoorah!

But still, that's all you have. A simple cubic room that consists entirely of blocks floating in space. Perhaps the map needs some entities.

Anything that is not a solid, unmoving block is an entity. This includes spawn points, where players will appear in the map after they die; doors and other moving blocks; fire; monsters; etc.

Entities come in two main types. Point-entities occupy a single point in space. Spawn points, for instance, are point-entities. They define the exact point at which a player can spawn. Monsters are also point-entities: you define the exact point at which there is a monster.

Contrary to point-entities are brush entities or brush-based entities. These are entities that rely on a brush to define them. (Remember, a brush is the same thing as a block.) Rain, for instance, is a brush entity, because the rain needs a volume in which to fall. Most doors are also brush entities.

A brush that is not a brush entity is called a world brush; all world brushes together and the space between them is called the world.

This cubic room needs spawn points, so players can appear in it.

Click the Entity Placement Tool icon:



Then, turn your attention to this toolbar:



It should be near the right side of the Hammer interface.

This toolbar controls the classname of the point-entity you'd like to place. An entity's classname informs the game engine of what the entity is. For instance, rain is referred to by the classname func_precipitation. If the game engine finds an entity with a classname of func_precipitation, it will try to use that entity to emit rain. Concordantly, if the game engine finds an entity with a classname of info_player_start, it will try to spawn players from that entity.

Let's place a spawn point. The classname for a spawn point varies by game. In HL2DM, it's info_player_deathmatch; in HL2 single-player, it's info_player_start; in CS:S, it's info_player_counterterrorist and info_player_terrorist. Simply use the drop-down menu named Objects to select an entity classname:



Placing a point-entity is very easy. Just click anywhere in a grid, then click and drag the green crosshair to the point where you'd like to place an entity.



Then, press ENTER. An entity will be placed at the crosshair.

Repeat the process of placing a point-entity; however, this time, choose the light classname instead of a spawn point. (Note that the classnames are listed alphabetically.) Place a light inside the map along with the spawn point.



Note also that the light bulb and the green man are only cute images designed to make it easy to tell entities apart. When you have a map with 37 point-entities in the same room, for instance, you need a way to tell them apart; the images do just that. The entities themselves take up only one point in space, and that point is usually the X that you see on entities in the 2D views.

Before you continue: a map must be sealed for it to work properly. This means that every part of the map must be inside the hollow space between world brushes, and it also means that there cannot be gaps between world brushes leading to the area outside the map. Confused? Think of it this way. Remember your house made of LEGO blocks? In order for the game engine to run the map properly, it will attempt to fill the LEGO house with JELL-O. However, if there is a gap like this one:



--then the engine cannot fill the house with JELL-O, because it cannot tell the difference between inside the house and outside the house. The engine will therefore not fill the house with JELL-O at all, and the house will not run properly. Such a gap is called a leak, perhaps because all the JELL-O "leaks" out the hole in the house ;)

You cannot block a leak with a brush entity. The only way to plug a leak is with a world brush. Also, having a point-entity outside the map will stop the map from running properly, because this is also a leak.

Now you have a simple cubic room with a spawn point and a light, and no gaps--want to see what it looks like in-game?

If you have not already done so, save the map by clicking File (in the upper-left corner of the Hammer interface), then Save. You will be asked to provide a name for your map. Don't use funny characters like [ ] ( ) < >... in fact, don't use anything but letters, numbers, hyphens -, and underscores _. No spaces, either; a map name must be one word, without spaces.

There's one more tedious thing to do before you can play the map...

Go to File, then Run Map. The dialogue box that appears should look like this:



If that is the case, click the "Expert" button to make the dialogue turn into this:



The words in your dialogue box will probably be a little different from mine. That's okay. The differences won't affect the map.

If Hammer set itself up properly, then this dialogue box should already be filled out and ready to use. This is a series of commands that will be executed one after the other in order to convert your map from Hammer's .VMF format to HL2's .BSP format. Click Go, and let Hammer work.



Hoorah, hoorah!

Now, back to that marvellous work of art I told you you could make...



Surely you can mimic this:



I used the texture brick/brickwall046a for the walls, and concrete/concretefloor015a_c17 for the floor.

I made a sky environment around my map:



--basically by making extensions of the walls with the tools/toolsskybox texture. Then, I put a ceiling on the entire map with the same texture. In some cases, you can forego extending the walls and just use the tools/toolsskybox texture as a ceiling; however, in this case the ceiling would have been too short. Sky brushes (brushes made with this sky texture) are solid!

Next, I lit the map with a light_environment entity. Light_environment causes light to be emitted from all sky brushes in the map, in a particular direction, to imitate real-world lighting conditions.

So, I place a light_environment entity...



Fun fact: if you select the light_environment entity (or any other entity) with the selection tool, then press ALT+ENTER, you will bring up the Object Properties dialogue box.



With this dialogue box, you can change an entity's classname, give it a name (if it supports a name) so other entities can refer to it, and change many things about the entity. Also, the black circle (I call it a compass) in the corner of the object properties dialogue box can be used to control the entity's Yaw (its orientation around the Z axis). See the light_environment page for information about a light_environment entity's properties.

My light_environment has a yaw of 45, a pitch of -30, a brightness of 183 183 213 200, and an ambient of 255 255 255 20.

Now, those stairs! Stairs! Everyone wants to make stairs eventually. The secret to making stairs is realizing that stairs are nothing but blocks short enough to be walked over. There's no special voodoo magic or animal sacrifice involved; just make a block that's short enough to be walked over, and you've got a stair. Do the same thing sixteen times and you've got sixteen stairs.



In order to make blocks shorter than the grid, you'll need to change the size of the grid with the bracket keys []. When you resize objects with the selection tool or make new objects, they will snap to the grid; therefore, making the grid smaller allows you to make objects much shorter. The size of the grid in units is shown in the lower-right corner of the Hammer interface:



Lower your grid size to 16 for this. If you think the grid is too small to work with, you can use the Zoom Tool:



Left-clicking on a grid zooms in, and right-clicking zooms out.

The zoom level for the grid you clicked most recently is shown here:



I will use a zoom level of 0.5 and a grid size of 16 for this. Four basic, 16-unit-high steps:



And one last step, 16 units higher than those (thus 32 units above the ground):



Of course, I didn't actually make these steps in a separate map; I just made the steps separately this time to show you how it's done. When I made the steps, I made them with the rest of the map still visible.

Adding the steps brings us to this:



As for the texture on the sides of the steps, that's concrete/concretetrim001a, with its X and Y Scales set to 0.5 with the Texture Application Tool; also, after I selected the face (by left-clicking it), I aligned it properly by clicking the T button, to align the texture to the Top of the face.

And now: THE EXPLOSIVE BARREL! Everyone loves explosive barrels!

The explosive barrel is made with the prop_physics point-entity. This entity allows you to place a model in your map that can be pushed around and thrown with the gravity gun. (A model is like a bunch of brushes, except it's easier for the game engine to display, and it's much more versatile. Models are separate files from the map itself.) To make an explosive barrel, place a prop_physics point-entity, then open its properties (Alt+Enter, remember?) and set its World Model property to models/props_c17/oildrum001_explosive.mdl.

At this point, we could say you're done; however, now we can optimize the map. To optimize your map is to modify it so that it runs as smoothly as possible. Perhaps the best way to optimize a map is through the use of a func_detail entity.

Func_detail is a brush entity that looks and acts exactly like a world brush. The only differences are that a func_detail is much easier for the engine to display, and that a func_detail does not block leaks.

To make a brush entity, select the brushes you'd like to turn into entities (hold CTRL to select multiple brushes):



Then, press CTRL+T. An entity properties box appears, but the entities in the classname menu are different. They're the brush entities. Choose func_detail from the drop-down list:



Then close the entity properties dialogue box. If you like, you can also turn the steps into a func_detail entity as well, for extra optimization.

It's very useful to turn every brush that's not blocking a leak into a func_detail. That means railings, pillars, walkways, ramps, sometimes whole buildings--anything that isn't blocking a leak should be a func_detail. Doing this has been proven to reduce compile times by over 90 percent. (Compile time refers to the time taken to convert a map from Hammer's VMF format to HL2's BSP format. Compilation is often quite time-consuming because of all the calculations involved.)

One last good Hammer feature: before you compile a map, be sure to run Hammer's Check for Problems (under the Map menu, or ALT+P). Hammer can detect invalid brushes, bad entity properties, and a variety of other bad things. Useful, sometimes.

Well, go on, compile the map just like you did the last one! File --> Run Map



Still need help? Ask your questions in one of our HELP FORUMS
Post A Comment
Name:
Email: Links Not Allowed In Comments
Comment:
What is the capital of France? Need Help?
Comments
Help - Jul 27, 2010
I get an error saying The command failed. Windows reported the error:"The system cannot find the file specified." when i click Go!
annoymus - Apr 12, 2010
can't.... make.... working.... SPAWN!!!
Tommy - Apr 11, 2010
I can't make the side wall! Help me!
Feather - Mar 5, 2010
Great work, I got stuck on others but yours helped me figure it out.
Marcus - May 26, 2009
What about doors and skyboxes, could you make a tut on those?
Rudy - Apr 25, 2009
Map works fine no errors but when i run it, after a while like 1 min or so it diconnects with the message "cliënt timed out". Is there anything i can do about that?
Plz help!
[143 extra comments]
All original content ©2006 EditLife.net. All Rights reserved. All files property of their rightful owners.
Get Firefox! Get Thunderbird! Get Notepad++!