Snarkpit Articles


Many times in the forums you will hear someone say ?don?t compile with Hammer@#$!!!!?. Now to a beginner that may not make a lot of sense as I get the feeling that many people do not seem to understand that it is the compile tools (hlcsg, hlbsp, hlvis/netvis, hlrad) that do all the work. Hammer is simply a user interface that attempts to make compiling more user-friendly.

There are any number of different user interfaces for compiling half life maps. Besides being done through Hammer, it cam be done through a third party GUI such as HLCC (graphical user interface), a DOS window, or a batch file. In every case you end up with the same finished product. Whatever interface you use the tools of your choice (ZHLT/MHLT/XPHLT) are run in the same order with a variety of command switches to customize the end result to your needs ( e.g. ?wadinclude, -bounce? etc.- see your tools documentation.htm file for more info).

So if they all do the same thing why is one way better than another? The answer is resources and neatness. In order to run Hammer/HLCC/ZHLT-GUI, your computer has to allocate memory for the interface that could be better spent speeding up the compile. Compiling in Hammer is particularly bad because it not only uses up a lot of RAM, it also locks up the editor. Compiling from a DOS window is very resource efficient, and it?s nice to have direct access to the tools because there is no chance of errors being caused by the vagaries of a GUI. However, you have to call each tool individually which is very annoying and not overly practical if you?re in the habit of doing overnight compiles. Meet the batch file.

A batch file is a series of DOS commands that are executed in sequence. If you are scared of command prompt don?t run! We are going to build a batch file that makes compiling as easing as dragging and dropping you?re mapname.map file. You should also note that Windows XP can still do this as it has its own DOS prompt (of sorts).

The first thing you have to do is create a new plain text document. I called mine compile.bat; .BAT files are the standard for small, DOS applications. Now open it up in notepad or your favourite text editor.

In the below image, you will see my batch file. There are numbers associated with each command. The text below the image explains each command and references its number in the sequence.



  1. The double colons (:smiley before the number designate the line as a comment. It is therefore skipped in the execution of the file.

  2. The ?echo off? command is an instruction telling the computer not to print commands to the screen. The ?@? symbol is necessary to tell computer that the ?echo off? command is effective at this line. Otherwise ?echo off? would itself be displayed.

  3. This command is the key to the convenience of the batch file. Batch files can take an argument, which can be a file or a variable. In our case the argument is the mapname.map file. ?%1? always refers to this first argument in a batch file, but to make things clearer I am assigning the first argument (%1) the name ?mapfile?.

  4. This command sets the root directory for your *.wad files. This is not a necessary command; it simply specifies a default directory for your textures. Obviously, choose whatever directory is best for you or omit this step entirely.

  5. Call HLCSG with a couple of command switches of your choice:
    Now we are ready to start calling the tools you want to use. I?m using the 15th build of XP-Cagey?s tools. The file path points to that particular version of HLCSG. Obveously, you should fill in the correct path to whatever tools you are using. All the tools take the mapname.map file as an argument, and various command switches after that. An example of the typical calling sequences would be ?hlcsg.exe mapname.map ?comand_switch?.

    However, what if I want to compile a different map? Using the above calling sequence I?d have to go into the batch file and change the map name and path every time! Do not despair. We already have the solution to this problem in the batch file argument (see step 3).

    Because I have designated the first argument to the batch file as ?mapfile? and we know that we will be giving the map to be compiled as the first argument of the batch file, all maps we might want to compile can now be referred to as ?mapfile?. A schematic diagram of this trick is shown below.



    The ?%? symbols are required before and after the word ?mapfile? to let the system know that ?mapfile? as a user defined label.

  6. Calls HLBSP as with HLCSG

  7. ?VIS

  8. ?RAD

  9. Prints ?Completed?? to the screen.

  10. Stops the DOS window form closing immediately upon completion.


Now, to use the batch file you can do one of two things:

  1. Go into DOS command prompt and type batchfilename.bat mapname.map and the whole compile sequence set forth in the batch file will run, assuming all your directories are correct and that your map is in the same folder as the compilers! (If it is not, and supposing you keep all your maps in the same directory, it might be worth adding the path to that directory in the batch file to compile and copy commands)

  2. Drag and drop your mapname.map file onto the batch file!


Notes:

All paths and file names must be WITHOUT SPACES. Folders should ideally be in DOS format, where you take the first 6 letters of it (ignoring spaces) and add ~1 at the end- type 'dir' at the command prompt to see what you should use.

The location of your batch file does not matter, although it might be a good idea to give it its own separate directory.

To change compile options or tools, just edit the batch file. You might consider having several different files such as, LeakCheck.bat, FastCompile.bat, NormalCompile.bat, and FinalCompile.bat each with your favorite tools and command switches for its purpose. And without any 'programming' knowledge here, you can define a single compile parameter by copying step 3 (e.g. SET rad_options = %2)

This method of compiling can be used to easily transport the compile process to a different computer, such as maybe the uber fast ones at school.... Just remember that you will need all of the textures, and if the path to those textures is different from what it was in your Hammer config you will need to edit the .map file (text format) accordingly.


Post ReplyView Topic
Discussion
0 starsPosted by Foxpup on Wed Dec 29th 2004 at 1:47am

There's a lot more info on this in the Worldcraft/VHE manual...
0 starsPosted by Cash Car Star on Wed Oct 6th 2004 at 9:07pm

Whoa, new rating system. Or not new and I just haven't looked at a tutorial in half a year. Either way, batch compiling = win. Things like putting the words on 3D boxes in your schematics diagram amuse me, but it's common practice in presentations.
0 starsPosted by fokker on Sun Oct 3rd 2004 at 4:54am

Very handy, though it was long I think it was necessary to explain exactly what needs to be done (it doesn't leave anyone asking any more questions).
0 starsPosted by Orpheus on Sat Sep 25th 2004 at 5:02pm

TB, I struggled hard with my HLCC tut.. to me it was imperative to remain as simple as possible.. I feel that I succeeded, snarkpit concurred.. BUT if my goal had been only to appease snarkpit, I wouldn't have needed to post it at all, since I seem to have the admiration of most here without it.. My goal was to help everyone, within and without the pit.. Only one person without the pit commented, and commented very badly..

You may have chosen much better than I..
if I might add though, you should illustrate 2 fully functional bat files, one for a fast compile, and one to show a fully tweaked compile.. this IMO would be the most beneficial of all the information.. no offense intended, or taken smiley

[EDIT] I tied your tutorial with mine TB.. this way, you,forceflow and i are all covered smiley
0 starsPosted by Forceflow on Fri Sep 24th 2004 at 8:45pm

Good tut
0 starsPosted by crockett on Thu Sep 23rd 2004 at 11:28pm

It's good to know I'm not the only one compiling with a batch fille smiley I find it easier to follow by typing in the map name rather than using parameters such as %mapname%

Good tutorial though
0 starsPosted by fizscy46 on Thu Sep 23rd 2004 at 9:35pm

Finally. I have been waiting forever for someone to actually explain the commands to put in the bat file. Now I can compile my G-Man Death 2nd and 3rd levels at school on the servers smiley

It'll probably still take 2 weeks and then fail
0 starsPosted by Crono on Thu Sep 23rd 2004 at 6:07am

Steam is the exact same as non-steam in this regard. Just, instead of saying "halflife.exe" you say "steam.exe"

That's pretty much it, almost everything in steam can be executed through the 'applaunch' argument.

The only problem I've come across is how to do the whole command line argument to a batch file thing. That and Hammer's executable abilities are rather limited, but I'm sure it's easy. I'll write something up once I get it going properly.

[EDIT]
By the way, to use spaces you put the path inside double quotes
[/EDIT]
0 starsPosted by omegaslayer on Thu Sep 23rd 2004 at 4:26am

Well I thought it was a 10/10
[author]
Posted by Tracer Bullet on Wed Sep 22nd 2004 at 5:51pm

Orph- It is long. Much more so than I had intended. However, I think it is better to explain to people not only what to do and how to do it, but also why each step is needed. Especially for beginners, I felt it was best not to assume any knowledge of BAT files. I myself only just learned to do this, and I was trying to cover all the questions I had in figuring it all out.
Also, no hard feelings about the rating. 8/10 is a perfectly respectable score, and anyway, what would be the point of a rating system if everything was rated 10/10?

Crono - I didn't think of automating it through hammer. And since I was using steam (yes I know I was using WON file paths) I discarded the idea of automatic startup. Is there a way to do that in Steam?
Good ideas though, you obviously know allot more about it than I do. As I said, this was my second batch file ever so I'm not well versed in what all is possible.
Post ReplyView Topic