How to Compile Maps using a Batch File

I recommend compiling maps via a batch file, because it gives much better control of the compilation process. I've made the batch file below, which you are welcome to download (or copy from below). Just make sure to change the configuration (the values in blue).

Note: The compilation tools work on map files, not rmf files. Be sure to export your map to a map file in Hammer before starting the compilation.

Compile.bat:

@Echo off

Set     ZHLT_PATH=C:\Program Files (x86)\ZHLT253-17p15
Set    STEAM_PATH=C:\Program Files (x86)\Steam
Set STEAM_ACCOUNT=your@email.com

Set MAP_PATH=C:\Users\You\Documents\Custom Levels\Counter-Strike\cs_test
Set MAP_NAME=cs_test

Set CSG_OPTIONS=-low -noinfo -estimate -chart -cliptype precise -wadautodetect
Set BSP_OPTIONS=-low -noinfo -estimate -chart
Set VIS_OPTIONS=-low -noinfo -estimate -chart -full
Set RAD_OPTIONS=-low -noinfo -estimate -chart -sparse -extra -bounce 4 -smooth 30 -notexscale -dscale 1

Rem *** End of configuration. You don't need to change anything below this line.



If Exist "%MAP_PATH%\%MAP_NAME%.log" Del "%MAP_PATH%\%MAP_NAME%.log"
If Exist "%MAP_PATH%\%MAP_NAME%.err" Del "%MAP_PATH%\%MAP_NAME%.err"

%STEAM_PATH:~0,2%

"%ZHLT_PATH%\hlcsg.exe" %CSG_OPTIONS% "%MAP_PATH%\%MAP_NAME%"
If Exist "%MAP_PATH%\%MAP_NAME%.err" Goto Failed

"%ZHLT_PATH%\hlbsp.exe" %BSP_OPTIONS% "%MAP_PATH%\%MAP_NAME%"
If Exist "%MAP_PATH%\%MAP_NAME%.err" Goto Failed

"%ZHLT_PATH%\hlvis.exe" %VIS_OPTIONS% "%MAP_PATH%\%MAP_NAME%"
If Exist "%MAP_PATH%\%MAP_NAME%.err" Goto Failed

"%ZHLT_PATH%\hlrad.exe" %RAD_OPTIONS% "%MAP_PATH%\%MAP_NAME%"
If Exist "%MAP_PATH%\%MAP_NAME%.err" Goto Failed

If Exist "%MAP_PATH%\%MAP_NAME%.lin" Del "%MAP_PATH%\%MAP_NAME%.lin"
If Exist "%MAP_PATH%\%MAP_NAME%.p0"  Del "%MAP_PATH%\%MAP_NAME%.p0"
If Exist "%MAP_PATH%\%MAP_NAME%.p1"  Del "%MAP_PATH%\%MAP_NAME%.p1"
If Exist "%MAP_PATH%\%MAP_NAME%.p2"  Del "%MAP_PATH%\%MAP_NAME%.p2"
If Exist "%MAP_PATH%\%MAP_NAME%.p3"  Del "%MAP_PATH%\%MAP_NAME%.p3"
If Exist "%MAP_PATH%\%MAP_NAME%.prt" Del "%MAP_PATH%\%MAP_NAME%.prt"
If Exist "%MAP_PATH%\%MAP_NAME%.pts" Del "%MAP_PATH%\%MAP_NAME%.pts"
If Exist "%MAP_PATH%\%MAP_NAME%.wic" Del "%MAP_PATH%\%MAP_NAME%.wic"

Echo.
Echo Compilation finished. Copying the bsp file to CS's maps folder...

Copy "%MAP_PATH%\%MAP_NAME%.bsp" "%STEAM_PATH%\SteamApps\%STEAM_ACCOUNT%\counter-strike\cstrike\maps"

Goto End



:Failed

Echo.
Echo Compilation failed. See %MAP_NAME%.log for details.



:End

Echo.
Echo Hit Enter to quit.

Pause >Nul

[ Top ]