Half-Life 2 ms-dos batch compile map file

sat feb 03 2018


Below is a ms-dos batch file that will compile a Half-Life 2 map.
It is easy to configure this for other Source games like DOD:S or CS:S. It will take a vmf file and process it into a ready to play bsp file.
It will work on any recent Steam install, any recent Windows version. It is very convenient.
Save vmf, close Hammer map editor. Open ms-dos command window, execute hl2_compilemap.bat mapname
There are only a few circumstances that require the Hammer map editor to stay open during compile and loading of the new map in game.

@echo off

REM run as hl2_compilemap.bat mapname
REM mapname is $file %1

@echo hl2_compilemap.bat 20170704


set HL2="Half-Life 2"
set SteamUserDir=c:\steam\steamapps\common
set gamedir="c:\steam\steamapps\common\Half-Life 2\hl2"
set HammerVMFDir="c:\steam\steamapps\common\sourcesdk_content\hl2\mapsrc"
set BSPDIR="c:\steam\steamapps\common\Half-Life 2\hl2\maps"
set VBSP=%SteamUserDir%\%HL2%\bin\vbsp.exe
set VVIS=%SteamUserDir%\%HL2%\bin\vvis.exe
set VRAD=%SteamUserDir%\%HL2%\bin\vrad.exe

echo hello echo %HL2% echo %1

cd %gamedir%

%VBSP% -game %gamedir% %HammerVMFDir%\%1
%VVIS% -game %gamedir% %HammerVMFDir%\%1
REM %VRAD% -lights %1.rad -game %gamedir% %HammerVMFDir%\%1
%VRAD% -final -both -StaticPropPolys -TextureShadows -staticproplighting -lights lights.rad -game %gamedir% %HammerVMFDir%\%1
copy %HammerVMFDir%\%1.bsp %BSPDIR%\%1.bsp

echo "ahh the compile is done." %HL2% map echo %1

cd c:\users\username\