Expert Compile Setup
by Leperous (view all articles)

unrated
Configure advanced compile to run with extra parameters etc.
by Leperous (view all articles)

unrated

To have extra control over how your maps are compiled, you may want to run an expert compile on your map.
Before doing so, you need to configure Hammer so that paths to your build programs are correct. Go to the Hammer options "Build Programs" tab, and set the BSP, VIS and RAD executables to be $SteamUserDirsourcesdkbinvbsp.exe, etc. Set your Game executable to $SteamDirSteam.exe. Finally, set the place compiled maps in this directory to be your mod's map directory- for Half-Life 2 deathmatch, this is the $SteamUserDirhalf-life 2 deathmatchhl2mpmaps directory.
Now go to your compile screen (F9) and access the expert compile screen by clicking the "expert" button at the bottom. If Half-Life 2 has not automatically been set up, you will be presented with a blank screen, otherwise you can skip to the next section (extra parameters).
Click "new" to add new compile/run commands to the left hand window. We will need 5 of these.
Select the first one in your list, and click the "Cmds" button on the right to add an actual command. Select "BSP Program" from the list- this will tell Hammer to run the BSP program you specified earlier. But we need to tell it to run on your map, so add new "Parms"- we want "Map Path", followed by a backslash , and then "Map Filename" (with/without extension).
NOTE Currently the compile tools need a game specified with a -game $gamedir command, so add this to the parameters. $gamedir corresponds to the "Game Directory" field in Hammer options, and you must ensure there is a GameInfo.txt properly configured for your game in that directory. So for HL2DM, set the Game Directory to $SteamUserDirhalf-life 2 deathmatchhl2mp and make sure there's a gameinfo.txt in that directory.
The parameters window should then read -game $gamedir $path$file:
Now, we want our second command to be VIS program, and the one after that RAD program (with the same parameters).
Next, we need to copy our compiled BSP into the game map directory (which we specified earlier) in order to play it. Add a "copy file" command, with parameters $path$file.bsp $bspdir$file.bsp (using the "Map Path", "Map Filename (with extension)", "BSP directory" etc. parms, and note the .BSP extensions I've added manually).
Our final command should be to run the game, which will actually be Steam. Add a Game program command with parameters -applaunch #appid -developer 1 -console 1 -map $file, where #appid is the Steam application ID- for example, 320 corresponds to HL2DM and 220 to HL2SP. You can find out what they are by telling Steam to create a shortcut on your desktop to them, and right clicking and checking the file path:
Now, we should be done. Tick all the boxes on the left, as well as the "use long filenames" box for each command, and click "Go!":
If you want to run extra compile parameters on your map, such as -glview with VIS, then simply type them into the relevant parameters window (preceded by a hyphen -), so your parameters window should read, for example, -game $gamedir $path$file -glview.
There are also some extra game parameters which are worth using.
Configure Hammer
Before doing so, you need to configure Hammer so that paths to your build programs are correct. Go to the Hammer options "Build Programs" tab, and set the BSP, VIS and RAD executables to be $SteamUserDirsourcesdkbinvbsp.exe, etc. Set your Game executable to $SteamDirSteam.exe. Finally, set the place compiled maps in this directory to be your mod's map directory- for Half-Life 2 deathmatch, this is the $SteamUserDirhalf-life 2 deathmatchhl2mpmaps directory.

Expert Compile
Now go to your compile screen (F9) and access the expert compile screen by clicking the "expert" button at the bottom. If Half-Life 2 has not automatically been set up, you will be presented with a blank screen, otherwise you can skip to the next section (extra parameters).
Click "new" to add new compile/run commands to the left hand window. We will need 5 of these.
Select the first one in your list, and click the "Cmds" button on the right to add an actual command. Select "BSP Program" from the list- this will tell Hammer to run the BSP program you specified earlier. But we need to tell it to run on your map, so add new "Parms"- we want "Map Path", followed by a backslash , and then "Map Filename" (with/without extension).
NOTE Currently the compile tools need a game specified with a -game $gamedir command, so add this to the parameters. $gamedir corresponds to the "Game Directory" field in Hammer options, and you must ensure there is a GameInfo.txt properly configured for your game in that directory. So for HL2DM, set the Game Directory to $SteamUserDirhalf-life 2 deathmatchhl2mp and make sure there's a gameinfo.txt in that directory.

The parameters window should then read -game $gamedir $path$file:

Now, we want our second command to be VIS program, and the one after that RAD program (with the same parameters).
Next, we need to copy our compiled BSP into the game map directory (which we specified earlier) in order to play it. Add a "copy file" command, with parameters $path$file.bsp $bspdir$file.bsp (using the "Map Path", "Map Filename (with extension)", "BSP directory" etc. parms, and note the .BSP extensions I've added manually).
Our final command should be to run the game, which will actually be Steam. Add a Game program command with parameters -applaunch #appid -developer 1 -console 1 -map $file, where #appid is the Steam application ID- for example, 320 corresponds to HL2DM and 220 to HL2SP. You can find out what they are by telling Steam to create a shortcut on your desktop to them, and right clicking and checking the file path:

Now, we should be done. Tick all the boxes on the left, as well as the "use long filenames" box for each command, and click "Go!":

Extra parameters
If you want to run extra compile parameters on your map, such as -glview with VIS, then simply type them into the relevant parameters window (preceded by a hyphen -), so your parameters window should read, for example, -game $gamedir $path$file -glview.
There are also some extra game parameters which are worth using.
- -deathmatch 1 starts the game in deathmatch mode
- -sv_lan 1 tells the game to start a LAN game, so other people can't join your level
- -sv_cheats 1 so cheats are enabled