Tutorials

Batch Files



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 <!-- s:D --><img src="https://www.interlopers.net/forum/images/smilies/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s: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

View comments ( 9 )

Back to top