Batch Files

Tutorial collection, comprehensive listings on main site.

Batch Files

Postby Tutorial on Mon Mar 07, 2005 6:10 pm

category
Miscellaneous

description
Create automated batch files for compiling your map.

keywords
batch, file, files, compile, compiling.

What is a batch?

A batch-file is a bunch of commands. like a list of shortcuts. the thing is, you can use all dos-commands (or as much as you can call them dos-commands in winxp) to do what you want it to do

What will it help me?

A lot. or very little. for Half-Life just compiling maps. you can compile maps without using Hammer, thus freeing up lots of RAM and a little of CPU that the compiling programs can use so much better :D
Also, you can use all those extra options you only can with expert compile mode

So?

Your maps will be compiled much faster. you will not notice any difference on small maps, but the bigger the map, the bigger the difference. it can save hours of compiling! Also, using certain options, you can do other things while compiling. You can add commands to shut down your pc or clean up useless files after compiling, or make a backup of your map before you compile it.

So, how does this work?
It's simple. start by opening a text editor, like notepad (I like it because it's simple, fast and easy to use). but wordpad or ms word will do just as good.

Make an empty file and you can start adding commands. but you don't know which? Ok, i'll list a few

To start a console-program: (eg. C:\windows\startme.exe)
"C:\windows\startme.exe"
(remember to include the ["]'s if your path or filename has any spaces like in \program files\lots of spaces.exe. this is for all commands

to delete a file (eg. C:\delme.txt) the command is:
del C:\delme.txt

to copy files: (eg. c:\replaceme.txt to D:\newdir\replaceme.txt)
copy C:\replaceme.txt D:\newdir

you can find lots more here, if your interested or want to make your pc do freaky stuff automatically.

so, how do we compile a map using this?
simple, we start each compile program (vbsp, vvis and vrad) using a batch, and a console will report the progress

when making a compile program we must start with:

----
%echo off
----
then we can add the commands for each compile program

they are:
----
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vbsp.exe"
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vvis.exe"
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vrad.exe"
----
however, this will only start the programs, they have no iea where to find your map! we tell this by adding that behind the command:

----
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vbsp.exe" C:\dm_traptown.vmf
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vvis.exe" C:\dm_traptown.vmf
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vrad.exe" C:\dm_traptown.vmf
----
assuming you also have a map called dm_traptown.vmf on your C:\root. fill in the dir of your map, dont forget to change the emailname-directory and your done

save the text file next. click save as and then at the name give it a name like: ["mybatch.bat"]. the "'s are so that the text editor add the bat extension instead of the txt extension.

now click the batch file and it will start doing its work.
but you want to add other command like: make run go very fast. thats explained best by the makers so heres a quote of them:


====
VBSP: Makes the basic BSP structure, adds entities and brushes
====

usage : vbsp [options...] mapfile
example: vbsp -onlyents c:\hl2\hl2\maps\test

Common options (use -v to see all options):


-v (or -verbose): Turn on verbose output (also shows more command
line options).

-onlyents : This option causes vbsp only import the entities from the .vmf
file. -onlyents won't reimport brush models.
-onlyprops : Only update the static props and detail props.
-glview : Writes .gl files in the current directory that can be viewed
with glview.exe. If you use -tmpout, it will write the files
into the \tmp folder.
-nodetail : Get rid of all detail geometry. The geometry left over is
what affects visibility.
-nowater : Get rid of water brushes.
-low : Run as an idle-priority process.
-linuxdata : Force it to write physics data for linux multiplayer servers.
It will automatically write this data if it finds certain
entities like info_player_terrorist, info_player_deathmatch,
info_player_teamspawn, info_player_axis, or info_player_coop.

-vproject <directory> : Override the VPROJECT environment variable.
-game <directory> : Same as -vproject.

Other options :
-novconfig : Don't bring up graphical UI on vproject errors.
-threads : Control the number of threads vbsp uses (defaults to the # of
processors on your machine).
-verboseentities: If -v is on, this disables verbose output for submodels.
-noweld : Don't join face vertices together.
-nocsg : Don't chop out intersecting brush areas.
-noshare : Emit unique face edges instead of sharing them.
-notjunc : Don't fixup t-junctions.
-noopt : By default, vbsp removes the 'outer shell' of the map, which
are all the faces you can't see because you can never get
outside the map. -noopt disables this behaviour.
-noprune : Don't prune neighboring solid nodes.
-nomerge : Don't merge together chopped faces on nodes.
-nomergewater: Don't merge together chopped faces on water.
-nosubdiv : Don't subdivide faces for lightmapping.
-micro <#> : vbsp will warn when brushes are output with a volume less
than this number (default: 1.0).
-fulldetail : Mark all detail geometry as normal geometry (so all detail
geometry will affect visibility).
-leaktest : Stop processing the map if a leak is detected. Whether or not
this flag is set, a leak file will be written out at
<vmf filename>.lin, and it can be imported into Hammer.
-nolinuxdata : Force it to not write physics data for linux multiplayer
servers, even if there are multiplayer entities in the map.
-bumpall : Force all surfaces to be bump mapped.
-snapaxial : Snap axial planes to integer coordinates.
-block # # : Control the grid size mins that vbsp chops the level on.
-blocks # # # # : Enter the mins and maxs for the grid size vbsp uses.
-dumpstaticprops: Dump static props to staticprop*.txt
-dumpcollide : Write files with collision info.
-luxelscale # : Scale all lightmaps by this amount (default: 1.0).
-lightifmissing : Force lightmaps to be generated for all surfaces even if
they don't need lightmaps.
-keepstalezip : Keep the BSP's zip files intact but regenerate everything
else.

====
VVIS: Calculates what parts of the map are visible from what parts
====
usage : vvis [options...] bspfile
example: vvis -fast c:\hl2\hl2\maps\test

Common options:

-v (or -verbose): Turn on verbose output (also shows more command
-fast : Only do first quick pass on vis calculations.
-mpi : Use VMPI to distribute computations.
-low : Run as an idle-priority process.
env_fog_controller specifies one.


-vproject <directory> : Override the VPROJECT environment variable.
-game <directory> : Same as -vproject.
Other options:
-novconfig : Don't bring up graphical UI on vproject errors.
-radius_override: Force a vis radius, regardless of whether an
-mpi_pw <pw> : Use a password to choose a specific set of VMPI workers.
-threads : Control the number of threads vbsp uses (defaults to the #
or processors on your machine).
-nosort : Don't sort portals (sorting is an optimization).
-tmpin : Make portals come from \tmp\<mapname>.
-tmpout : Make portals come from \tmp\<mapname>.

====
VRAD: Light your map
====

usage : vrad [options...] bspfile
example: vrad c:\hl2\hl2\maps\test

Common options:

-v (or -verbose): Turn on verbose output (also shows more command
-bounce # : Set max number of bounces (default: 100).
-fast : Quick and dirty lighting.
-low : Run as an idle-priority process.
-mpi : Use VMPI to distribute computations.
-rederror : Show errors in red.

-vproject <directory> : Override the VPROJECT environment variable.
-game <directory> : Same as -vproject.

Other options:
-novconfig : Don't bring up graphical UI on vproject errors.
-dump : Write debugging .txt files.
-dumpnormals : Write normals to debug files.
-threads : Control the number of threads vbsp uses (defaults to the #
or processors on your machine).
-lights <file> : Load a lights file in addition to lights.rad and the
level lights file.
-noextra : Disable supersampling.
-debugextra : Places debugging data in lightmaps to visualize
supersampling.
-smooth # : Set the threshold for smoothing groups, in degrees
(default 45).
-dlightmap : Force direct lighting into different lightmap than
radiosity.
-stoponexit : Wait for a keypress on exit.
-mpi_pw <pw> : Use a password to choose a specific set of VMPI workers.
-nodetaillight : Don't light detail props.
-centersamples : Move sample centers.
-luxeldensity # : Rescale all luxels by the specified amount (default: 1.0).
The number specified must be less than 1.0 or it will be
ignored.
-loghash : Log the sample hash table to samplehash.txt.
-onlydetail : Only light detail props and per-leaf lighting.
-maxdispsamplesize #: Set max displacement sample size (default: 512).

Basically, you ust add [space]-option to get a desired effect
like in this example:

----
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vbsp.exe" C:\dm_traptown.vmf
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vvis.exe" -fast C:\dm_traptown.vmf
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vrad.exe" -fast C:\dm_traptown.vmf
----

You see that both vrad and vvis are ordered to run the fast option. you can use all the options mentioned above this way. just remember to put the options before the map path and they should work.

Note for people familiar with the hl1 compilers: youll notice csg and bsp are combined in one program. also, vis has lost its -full option and for rad yull notice supersampling (the -extra option) is default.

So thats all to it. the compile will do everything it does when using hammer, including making a log and portal files. one thing though, you cant compile without running steam. you need to have steam running but thats it.

lastly two examples of batch files:
a simple one:

----
@echo off
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vbsp.exe" C:\dm_traptown.vmf
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vvis.exe" -fast C:\dm_traptown.vmf
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vrad.exe" -fast C:\dm_traptown.vmf
pause
----

note: the pause option makes sure the console doesnt dissappear before you press an any key. handy when the tools encounter an error during compile which stops them (and as soon as they are stopped, the console screen dissappears and you cant see the error-report)

now a batch that also copies the map to the map dir before compiling, making sure the bsp is in the right dir when you start your game:

----
@echo off
copy "C:\Program Files\Steam\SteamApps\emailname\sourcesdk\hl2mp_sample_content\maps\dm_tarptown.vmf" "C:\Program Files\Steam\SteamApps\emailname\half-life 2 deathmatch\hl2mp\maps"
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vbsp.exe" "C:\Program Files\Steam\SteamApps\emailname\half-life 2 deathmatch\hl2mp\maps\dm_traptown.vmf"
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vvis.exe" "C:\Program Files\Steam\SteamApps\emailname\half-life 2 deathmatch\hl2mp\maps\dm_traptown.vmf"
"C:\Program Files\Steam\SteamApps\emailname\sourcesdk\bin\vrad.exe" "C:\Program Files\Steam\SteamApps\emailname\half-life 2 deathmatch\hl2mp\maps\dm_traptown.vmf"
pause
----

I hope that was clear and not too long.

zombie@computer
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Postby Sauce on Mon Jul 03, 2006 7:05 am

thanks zombie!
Image
Blink wrote:Do you watch porn and decide you don't need to have sex because you've seen the ending? :-D

zombie@computer wrote:what retarded countries measure in stones anyway?
or feet? or inches? Your dick is a lot longer in cms
User avatar
Sauce
Senior Member
Senior Member
 
Joined: Sat Nov 26, 2005 4:36 am
Location: Australia

Postby krunchy on Mon Oct 02, 2006 10:40 pm

Nice, but this batch will allow you to drag and drop the VMF onto it so you don't need to edit it every time you want to compile a map.

Code: Select all
@echo off

:: Compiles the map.
"%sourcesdk%\bin\vbsp.exe" %1
"%sourcesdk%\bin\vvis.exe" %1
"%sourcesdk%\bin\vrad.exe" %1

:: Copies the compiled BSP to %VPROJECT%'s maps folder.
copy "%1" "%vproject%\maps\"

:: This is here so the window doesn't close and allows you to read the compile log.
pause
krunchy
Dumpling
Dumpling
 
Joined: Mon Oct 02, 2006 10:34 pm

Re: Batch Files

Postby theremin on Wed Mar 12, 2008 10:33 am

Doesnt work for me, I must be doing something wrong:

I type:
%echo off
"C:\Program Files\Steam\steamapps\jesuslizard\sourcesdk\bin\vbsp.exe" "C:\Program Files\Steam\steamapps\jesuslizard\sourcesdk_content\cstrike\mapsrc\town03.vmf"
"C:\Program Files\Steam\steamapps\jesuslizard\sourcesdk\bin\vvis.exe" "C:\Program Files\Steam\steamapps\jesuslizard\sourcesdk_content\cstrike\mapsrc\town03.vmf"
"C:\Program Files\Steam\steamapps\jesuslizard\sourcesdk\bin\vrad.exe" "C:\Program Files\Steam\steamapps\jesuslizard\sourcesdk_content\cstrike\mapsrc\town03.vmf"

and get the error: "C:\Program Files\Steam\steamapps\jesuslizard\sourcesdk\bin\vrad.exe" is not recognised as an internal or external command, operable program or batch file.
theremin
Just Joined
Just Joined
 
Joined: Wed Mar 12, 2008 10:24 am

Re: Batch Files

Postby krainert on Mon Apr 21, 2008 7:05 am

Okay... Here's a long one, so hold on tight!

--


@ECHO off
SET SUBJECT="[Map dir - example: C:\Maps\dm_ihasamaplol]"
SET SOURCE="[Tools source dir - example: C:\Programmer\Steam\steamapps\sourcesdk\bin\orangebox\bin]"
SET DESTINATION="[Destination game dir - example: C:\Programmer\Steam\steamapps\USER\half-life 2 episode two\ep2"]"
ECHO [ BATCH COMPILER ]
ECHO.
ECHO Compiling...
ECHO.
ECHO.
ECHO --------------------------------
ECHO [Settings]
ECHO --------------------------------
ECHO.
ECHO Subject: '%SUBJECT%'
ECHO VBSP source: '%SOURCE%\vbsp.exe'
ECHO VVIS source: '%SOURCE%\vvis.exe'
ECHO VRAD source: '%SOURCE%\vrad.exe'
ECHO Game directory: '%DESTINATION%'
ECHO Map directory: '%DESTINATION%\maps'
ECHO VMF file: '%SUBJECT%.vmf'
ECHO BSP file: '%SUBJECT%.bsp'
ECHO.
ECHO.
ECHO --------------------------------
ECHO [VBSP]
ECHO --------------------------------
ECHO.
"%SOURCE%\vbsp.exe" -novirtualmesh -game "%DESTINATION%" "%SUBJECT%.vmf"
ECHO.
ECHO.
ECHO --------------------------------
ECHO [VVIS]
ECHO --------------------------------
ECHO.
"%SOURCE%\vvis.exe" -game "%DESTINATION%" "%SUBJECT%.bsp"
ECHO.
ECHO.
ECHO --------------------------------
ECHO [VRAD]
ECHO --------------------------------
ECHO.
"%SOURCE%\vrad.exe" -game "%DESTINATION%" "%SUBJECT%.bsp"
ECHO.
ECHO.
ECHO --------------------------------
ECHO [Final]
ECHO --------------------------------
ECHO.
COPY "%SUBJECT%.bsp" "%DESTINATION%\maps"
ECHO.
ECHO.
PAUSE


--

This one works as a dynamic compiler sinse you only have to edit the three first lines when compiling a new map. Also, you get a lot of handy formatting (if anything appearing in a CMD window can be descripted as such).
User avatar
krainert
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Thu Dec 20, 2007 2:57 pm
Location: Denmark

Re: Batch Files

Postby shLep on Tue Apr 07, 2009 12:31 am

Hi,
I'm very new to configuring any kind of batch file.
I tried to use some examples given above but without much luck. I think its because im running under a mod.

Whether i use the drag and drop method, or the dymanic example, it always returns errors that materials could not be found. Could someone please help explain what my batch files are missing?

Code: Select all
@echo off

:: Compiles the map.
"%sourcesdk%\bin\orangebox\bin\vbsp.exe" %1
"%sourcesdk%\bin\orangebox\bin\vvis.exe" %1
"%sourcesdk%\bin\orangebox\bin\vrad.exe" %1

:: Copies the compiled BSP to %VPROJECT%'s maps folder.
copy "%1" "%vproject%\maps\"

:: This is here so the window doesn't close and allows you to read the compile log.
pause


or,

Code: Select all
@ECHO off
SET SUBJECT="C:\mymod\mapsrc\lvl1_01c"
SET SOURCE="C:\Games\Valve\Steam\SteamApps\myusername\sourcesdk\bin\orangebox\bin"
SET DESTINATION="C:\Games\Valve\Steam\SteamApps\SourceMods\mymod"
ECHO [ BATCH COMPILER ]
ECHO.
ECHO Compiling...
ECHO.
ECHO.
ECHO --------------------------------
ECHO [Settings]
ECHO --------------------------------
ECHO.
ECHO Subject: '%SUBJECT%'
ECHO VBSP source: '%SOURCE%\vbsp.exe'
ECHO VVIS source: '%SOURCE%\vvis.exe'
ECHO VRAD source: '%SOURCE%\vrad.exe'
ECHO Game directory: '%DESTINATION%'
ECHO Map directory: '%DESTINATION%\maps'
ECHO VMF file: '%SUBJECT%.vmf'
ECHO BSP file: '%SUBJECT%.bsp'
ECHO.
ECHO.
ECHO --------------------------------
ECHO [VBSP]
ECHO --------------------------------
ECHO.
"%SOURCE%\vbsp.exe" -novirtualmesh -game "%DESTINATION%" "%SUBJECT%.vmf"
ECHO.
ECHO.
ECHO --------------------------------
ECHO [VVIS]
ECHO --------------------------------
ECHO.
"%SOURCE%\vvis.exe" -game "%DESTINATION%" "%SUBJECT%.bsp"
ECHO.
ECHO.
ECHO --------------------------------
ECHO [VRAD]
ECHO --------------------------------
ECHO.
"%SOURCE%\vrad.exe" -game "%DESTINATION%" "%SUBJECT%.bsp"
ECHO.
ECHO.
ECHO --------------------------------
ECHO [Final]
ECHO --------------------------------
ECHO.
COPY "%SUBJECT%.bsp" "%DESTINATION%\maps"
ECHO.
ECHO.
PAUSE


The source installation of mymod is off the C: drive.
The mod itself is under the sourcemods directory (see above).
It seems that both materials and models from hl2 arent being found.
any suggestions?

Example of Errors seen (basically for every texture or prop):

material "tools/toolsnodraw" not found.
Material not found!: TOOLS/TOOLSNODRAW
Error loading studio model "models/props_c17/handrail04_long.mdl"!
etc, etc..
shLep
Just Joined
Just Joined
 
Joined: Tue Apr 07, 2009 12:25 am

Re: Batch Files

Postby zombie@computer on Tue Apr 07, 2009 5:59 pm

add

CD /d %source%

after you set %source%. Apparently valve changed some stuff forcing you to need to change the active directory to the location of the compile tools to work correctly.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Batch Files

Postby migedith on Wed Apr 15, 2009 3:26 am

I'm getting the same errors that shLep was getting...

missing materials. Before it runs vvis.exe, vbsp.exe crashes, and i'm assuming it didn't finish.

Here is what my .bat looks like

Code: Select all
@echo off

CD /d C:\Program Files (x86)\Steam\steamapps\jb1013\sourcesdk\bin\orangebox\bin
:: Compiles the map.
"vbsp.exe" "C:\Program Files (x86)\Steam\steamapps\SourceMods\nomansland\maps\water.vmf"
"vvis.exe" "C:\Program Files (x86)\Steam\steamapps\SourceMods\nomansland\maps\water.vmf"
"vrad.exe" "C:\Program Files (x86)\Steam\steamapps\SourceMods\nomansland\maps\water.vmf"

:: Copies the compiled BSP to %VPROJECT%'s maps folder.
copy "%1" "C:\Program Files (x86)\Steam\steamapps\SourceMods\nomansland\maps\"

:: This is here so the window doesn't close and allows you to read the compile log.
pause


Do i have to custom set all of the material paths and stuff into the batch file?
Sains of the Old Republic
A Christian Republic Guild
Visit Our Website
migedith
Member
Member
 
Joined: Sun Oct 22, 2006 5:03 am

Re: Batch Files

Postby zombie@computer on Wed Apr 15, 2009 6:30 pm

try using the -game path/to/your/mod/dir switch
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Batch Files

Postby Evil Scotsman on Wed Aug 12, 2009 2:39 pm

If any of you are missing materials and have vbsp crashing on you then try using this program.

VBCT

It's quite brilliant and easy to use.
Evil Scotsman
Regular
Regular
 
Joined: Thu Nov 27, 2008 9:34 pm

Return to Tutorials

Who is online

Users browsing this forum: No registered users