Batches [Compiling]

For all topics related to using or installing radiant
Post Reply
User avatar
xandaxs
Posts: 959
Joined: Wed Aug 17, 2011 5:22 pm
Location: Oeiras, Portugal

Batches [Compiling]

Post by xandaxs »

[quote=DagF]I played with batch programming about 8 months ago, I was making a small easy program to change my background on my school computer(They bloced the change bacgroundimage :(:().

When I did this I learned about the %1 function in batch. Using this can you make a batch file that will use the filename, path, drive, and type of file as a variable. This is also working for files you drag and slip on the file.

So a month ago did I look it up and I found out you can use %1 much more than I did. I did it because I have to add "-fs_game q3ut4" when I compile with q3map2toolz so... xD

%1 will be a reference to the file with drive, path, name and file extension.
Eg: "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe"

%1 can be broken down to %~d1, %~p1 and %~n1 (there are more, referring to file extension date and so but we don't need them now.)

%~d1 -Is the drive to the batch file or the file you drop on the batch file.
Eg: "C:\"

%~p1 -Is the path to the batch file or the file you drop on the batch file.
Eg: " urtmapping\q3map_2.5.16_win32_x86\"

%~n1 -Is the name to the batch file or the file you drop on the batch file.
Eg: " q3map2"

More about this can be read here: http://www.microsoft.com/resources/docu ... x?mfr=true

By using this can we easily modify our compile.bat we find in our mapping folder.
This is what my compile.bat looks like now:

Code: Select all

"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -meta -fs_basepath "C:\urtmapping" -fs_game q3ut4 "C:\urtmapping\q3ut4\maps\lighttest_a_a5.map"
"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -vis -fs_basepath "C:\urtmapping" "C:\urtmapping\q3ut4\maps\lighttest_a_a5.bsp"
"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -light -fs_basepath "C:\urtmapping" "C:\urtmapping\q3ut4\maps\lighttest_a_a5.bsp"

By using %~d1, %~p1 and %~n1 can we make a file that will compile the .map file dropped on it.

This is somewhat what it should look like:

Code: Select all

"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -meta -fs_basepath "C:\urtmapping" -fs_game q3ut4 "%~d1%~p1%~n1.map"
"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -vis -fs_basepath "C:\urtmapping" "%~d1%~p1%~n1.bsp"
"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -light -fs_basepath "C:\urtmapping" "%~d1%~p1%~n1.bsp"

Now it's only for you to drag the map you want compiled on to the batch file.
This isn't really useful for URT 4.0 or 4.1 but for HD there are no other way to compile yet?

I have modified mine file a bit and I can now do a compile then just go on the surface sound straight away:

Code: Select all

@echo off
"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -fs_basepath "C:\urtmapping" -fs_game q3ut4 "%~d1%~p1%~n1.map"
"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -vis -fs_basepath "C:\urtmapping" -fs_game q3ut4 "%~d1%~p1%~n1.bsp"
"C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -light -fs_basepath "C:\urtmapping" -fs_game q3ut4 "%~d1%~p1%~n1.bsp"
pause
cls
echo ******************************
echo Surfacesound for %~n1
echo ******************************
pause
cls
start "Making .surface file" /low /B /wait "C:\urtmapping\q3ut4\surface_sound\bsp.exe" -se %1 %~d1%~p1%~n1.surface
start "Opening surface sounds" /low /B surfacesounds.surface "C:\Program Files (x86)\Windows NT\Accessories\wordpad.exe"
Start "Editing . surface file" /low /B /wait %~d1%~p1%~n1.surface "C:\Program Files (x86)\Windows NT\Accessories\wordpad.exe"
start "Applying .surface file to .bsp" /low /B /wait "C:\urtmapping\q3ut4\surface_sound\bsp.exe" -si %1 %~d1%~p1%~n1.surface
echo Done!
pause

This is basically the script I found at Del's wiki http://gotdelirium.com/wiki/index.php?t ... ch_Scripts
Just modified to use %1 commands. I have made a folder named surface_sound where I got the bsp.exe file.

As an end will I use the example at Del's wiki and change it so it will be using this function.

Code: Select all

@echo off
set map=null_c22
echo Compiling: %map%
start "BSP: %map%" /low /B /wait "G:\Games\utils\Q3map2\q3map2_fs_20g\FS_q3map_Radbump_2a.exe" -meta -fs_basepath "G:\Games\UrbanTerror" -fs_game q3ut4  "G:\Games\UrbanTerror\q3ut4\maps\%map%.map"
start "VIS: %map%" /low /B /wait "G:\Games\utils\Q3map2\q3map2_fs_20g\FS_q3map_Radbump_2a.exe" -vis -saveprt -fs_basepath "G:\Games\UrbanTerror" -fs_game q3ut4  "G:\Games\UrbanTerror\q3ut4\maps\%map%.bsp"
start "RAD: %map%" /low /B /wait "G:\Games\utils\Q3map2\q3map2_fs_20g\FS_q3map_Radbump_2a.exe" -light -bounce 9 -fast -patchshadows -samples 2 -radbump -shade -fs_basepath "G:\Games\UrbanTerror" -fs_game q3ut4 "G:\Games\UrbanTerror\q3ut4\maps\%map%.bsp"
g:
cd g:games\urbanterror\q3ut4\maps
bsp -si %map%.bsp null_c22.surface
start "BSPC: Compiling %map%.aas" /low /B /wait "G:\Games\quake3\Tools\bspc.exe" -forcesidesvisible -optimize -bsp2aas "G:\Games\UrbanTerror\q3ut4\maps\%map%.bsp"

- this was taken from here: http://gotdelirium.com/wiki/index.php?t ... ch_Scripts

This is what it could have been changed to:

Code: Select all

@echo off
echo Compiling: %~n1
start "BSP: %~n1" /low /B /wait "G:\Games\utils\Q3map2\q3map2_fs_20g\FS_q3map_Radbump_2a.exe" -meta -fs_basepath "G:\Games\UrbanTerror" -fs_game q3ut4  "%~d1%~p1%~n1.map"
start "VIS: %~n1" /low /B /wait "G:\Games\utils\Q3map2\q3map2_fs_20g\FS_q3map_Radbump_2a.exe" -vis -saveprt -fs_basepath "G:\Games\UrbanTerror" -fs_game q3ut4  "%~d1%~p1%~n1.bsp"
start "RAD: %~n1" /low /B /wait "G:\Games\utils\Q3map2\q3map2_fs_20g\FS_q3map_Radbump_2a.exe" -light -bounce 9 -fast -patchshadows -samples 2 -radbump -shade -fs_basepath "G:\Games\UrbanTerror" -fs_game q3ut4 "%~d1%~p1%~n1.bsp"
g:
cd g:games\urbanterror\q3ut4\maps
bsp -si %~n1.bsp %~n1.surface
start "BSPC: Compiling %~n1.aas" /low /B /wait "G:\Games\quake3\Tools\bspc.exe" -forcesidesvisible -optimize -bsp2aas "%~d1%~p1%~n1.bsp"

This is just an example, I have not tested the last code. It is just a practice example I did to show how simple this is to do.

If there is anything that is not clear, or things you wonder about this. Post a reply, pm or mail me.
If there is anything in this "tutorial", please do tell me and I will change it so it's right.

I hope this will be handy for some of you :)
DagF[/quote]

__________________________________________________________________________________

[quote=ValkoVer]Batch file im using to compile ut4_gloom, including infamous -fixaas switch:

Code: Select all

@DEL /Q "E:\mapmaker\q3ut4\maps\ut4_gloom_b2.aas"

"E:\mapmaker\q3ut4\GTKradiant\q3map2.exe" -fs_basepath "E:\mapmaker" -fs_game "q3ut4" -meta -skyfix -v "E:\mapmaker\q3ut4\maps\ut4_gloom_b2.map"
"E:\mapmaker\q3ut4\GTKradiant\q3map2.exe" -fs_basepath "E:\mapmaker" -fs_game "q3ut4" -vis -saveprt -v "E:\mapmaker\q3ut4\maps\ut4_gloom_b2.map"
"E:\mapmaker\q3ut4\GTKradiant\FS_q3map_Radbump_4a.exe" -fs_basepath "E:\mapmaker" -fs_game "q3ut4" -light -fast -radbump -shade -v -bounce 8 -filter -gamma 2 -samples 8 "E:\mapmaker\q3ut4\maps\ut4_gloom_b2.map"

E:
cd E:\mapmaker\q3ut4\maps
bsp -si ut4_gloom_b2.bsp ut4_gloom.surface

"E:\mapmaker\q3ut4\GTKradiant\q3map2.exe" -fs_basepath "E:\mapmaker" -fs_game "q3ut4" -meta "E:\mapmaker\q3ut4\maps\ut4_gloom_bot.map"
"E:\mapmaker\q3ut4\GTKradiant\bspc.exe" -bsp2aas "E:\mapmaker\q3ut4\maps\ut4_gloom_bot.bsp" -forcesidesvisible

E:
cd E:\mapmaker\q3ut4\maps
ren ut4_gloom_bot.aas ut4_gloom_b2.aas

"E:\mapmaker\q3ut4\GTKradiant\q3map2.exe" -fs_basepath "E:\mapmaker" -fs_game "q3ut4" -fixaas "E:\mapmaker\q3ut4\maps\ut4_gloom_b2.bsp"

echo Open .aas file in a hex editor and change the first 4 byte to 45 41 41 53, namely "EAAS", overwrite the file.
pause

"E:\mapmaker\q3ut4\GTKradiant\bspc.exe" -optimize -reach "E:\mapmaker\q3ut4\maps\ut4_gloom_b2.map"
[/quote]

__________________________________________________________________________________

[quote=DagF]Just made a easy batch script that allowes you to do a compile, a compile with devmap and devmap.

It should work on windows computers. There might be errors, i have only tested it on my computer but i can not think of anything worng happening. Your urt have to be put to sv_pure 0 i think? it's normaly set to one for urt hd i think?

Code: Select all

@echo off
color 8a
title Compile v0.1 -DagF
rem variables

rem Path to radbump
set q3mappath=C:\urthdmapping\FS_q3map_Radbump_4.exe

rem path to mapping folder
set basepath=C:\urthdmapping\

rem fa_game
set game=urthdalpha1

rem ***********You do not need to change enything under this line(well noting more then the compile settings). so if you can avoid it i think you should ;P***********

cd %basepath%

:menu
cls
echo 1 Compile
echo 2 Compile then run devmap
echo 3 devmap
echo 4 Change paths
echo 5 Exit
set /p INPUT=Enter choice...
for %%j in (1 2 3 4 5) do if "%%j"=="%INPUT%" goto :%INPUT%

:5
exit

:1
rem compiling.
cls
start /low /B /wait %q3mappath% -meta -v -fs_basepath %basepath% -fs_game %game% "%~d1%~p1%~n1.map"
start /low /B /wait %q3mappath% -vis -fast -v -fs_basepath %basepath% -fs_game %game% "%~d1%~p1%~n1.bsp"
start /low /B /wait %q3mappath% -light -fast -radbump -fs_basepath %basepath% -fs_game %game% "%~d1%~p1%~n1.bsp"
echo "Done Compiling. Press any key to continue"
pause
goto :menu


:2
rem compile then run devmap.
cls
start /low /B /wait %q3mappath% -meta -v -fs_basepath %basepath% -fs_game %game% "%~d1%~p1%~n1.map"
start /low /B /wait %q3mappath% -vis -fast -v -fs_basepath %basepath% -fs_game %game% "%~d1%~p1%~n1.bsp"
start /low /B /wait %q3mappath% -light -fast -radbump -fs_basepath %basepath% -fs_game %game% "%~d1%~p1%~n1.bsp"
echo "Done Compiling. Press any key to run devmap"
pause
"%basepath%UrbanTerrorHD_release.exe" devmap %~n1
goto :menu

:3
rem run devmap
cls
"%basepath%UrbanTerrorHD_release.exe" devmap %~n1
goto :menu

:4
notepad.exe "compile_v.0.1.bat"
exit


It will work if you place it in the same folder as your FS_q3map_Radbump_4's


Instructions:

You will have to have the bat file in the folder with the FS_q3map_Radbump_4's. then open the folder maps folder and drag the map you want to convert on to the bat file.
The files does just need the name of the file you are compiling. So if you want to do a recompile or just a devmap is it possible to use the .map, the .bsd, the .srf or tga.

Please do correct me if anything i post is wrong or could be done better.
Works well for me so hope others can use it aswell :)[/quote]

__________________________________________________________________________________

[quote=DagF]I am doing this scripting as i like to make script and as i make a new samve of the map every 20 min or so(I don not want to get a corrupt file and stand on bar ground ever again). So changin the script to fit the map is not working well.

Therefore do i make this scripts who lets me compile whatever file i drag on it.
As for today i looked on the scripts i have made and started thinking why am i making this scripts? -To make compiling easier. The last verson of the script does is not as easy as possible and therefore not much good.

I made a script for now including compile, surface sound, devmap and l8ter on converting to ase. These are the normal settings you will need to do a compile of your map while testing. I think i will add other things like bots compiling as an obtion of it's own.

If there is more i should add plis do tell me.

I am making this script for myselfe and whoever would like to use them. I do this for fun(I guess it just tells what kind of person i am, liking making batch script used by max 10 ppl world wide(it can possible be counted as a binary number...))

So here is the new verson of my script. Plis do guide me if you got some ides for it ;)

Code: Select all

@echo off
color 70
title Compile v0.3 -DagF

rem variables

rem **General settings**

rem Path to mapping folder
set basepath=C:\urtmapping\

rem fs_game
set fsgame=q3ut4


rem **Compiler and running settings**

rem Path to compiler
set compilerpath=C:\urthdmapping\FS_q3map_Radbump_4.exe

rem name of urt exe file
set urtexe=iourbanterror.exe


rem **Surfacesound settings**

rem path to surface_sound folder
set pathtobsp=C:\urtmapping\q3ut4\surface_sound\

rem ***********Mind what your are changin***********

cd %basepath%

:menu
cls
echo 1 Compile
echo 2 Surface sound
echo 3 Run devmap
echo 4 Convert to ase
echo 5 Change paths or settigs
echo 6 Exit
set /p INPUT=Enter choice...
for %%j in (1 2 3 4 5 6) do if "%%j"=="%INPUT%" goto :%INPUT%
goto :menu

:1
cls
start /low /B /wait %compilerpath% -meta -v -fs_basepath %basepath% -fs_game %fsgame% "%~d1%~p1%~n1.map"
start /low /B /wait %compilerpath% -vis -fast -v -fs_basepath %basepath% -fs_game %fsgame% "%~d1%~p1%~n1.bsp"
start /low /B /wait %compilerpath% -light -fast -fs_basepath %basepath% -fs_game %fsgame% "%~d1%~p1%~n1.bsp"
echo "Done Compiling. Press any key to continue"
goto :menu

:2
cls
start "Making .surface file" /low /B /wait "%pathtobsp%bsp.exe" -se "%~d1%~p1%~n1.bsp" %~d1%~p1%~n1.surface
start "Opening .surface sounds" /low /B wordpad.exe "%pathtobsp%surfacesounds.surface"
Start "Editing . surface file" /low /B /wait wordpad.exe "%~d1%~p1%~n1.surface"
start "Applying .surface file to .bsp" /low /B /wait "%pathtobsp%bsp.exe" -si "%~d1%~p1%~n1.bsp" %~d1%~p1%~n1.surface
goto :menu

:3
cls
start /low /B %basepath%%urtexe% +sv_pure 0 +r_gamma 1 +devmap %~n1
goto :menu

:4
cls
echo "Not yet added"
pause
goto :menu

:5
cls
notepad.exe "compile_v.0.3.bat"
exit

:6
exit


PS.If you find my posts anoying, dont read them ;)[/quote]
[12:25] <JohnnyEnglish> morning Nounou
[12:25] <JohnnyEnglish> wotcha doing?
[12:25] <Nounou> hello
[12:26] <Nounou> nothing much, i've nothing to do at work so
[12:26] <Nounou> modeling woman
[12:26] <JohnnyEnglish> woo
[12:26] <JohnnyEnglish> real women?
[12:26] <Nounou> realistic yes, on maya

Image

User avatar
DagF
Posts: 277
Joined: Thu Aug 18, 2011 8:40 am
Location: Norway
Contact:

Re: Batches [Compiling]

Post by DagF »

Just toguth i would keep you updated.

I have changed the batch file some.
I have added converting and surface sound.
I will still have to add a few thing before i do any real release of it.

Code: Select all

@echo off
title BC v1.1 - Working with : %~n1
color 70

:Start
cls

rem Get paths
rem complie lines
set __BSP=-v -meta
set __VIS=-vis
set __LIGHT=-light

rem bot compile
set __ASS=-meta

rem paths
set __BasePath=C:\urtmapping\

set __FSGame=q3ut4
set __GameEXE=iourbanterror.exe
set __CompilerPath=compile\q3map2\q3map2.exe
set __BPSPath=compile\sfs\bsp.exe

cd %__BasePath%


:MainMenu
cls

echo 0. Refresh
echo 1. Test Compile
echo 2. Devmap
echo 3. Compile
echo 4. Surface Sound
echo 5. bots
echo 6. Autoscript
echo 7. Convert
echo 8. Settings
echo 9. Exit


CHOICE /C 0123456789 /N /M "Choose a option."


if errorlevel 10 goto :Exit
if errorlevel 9 goto :Settings
if errorlevel 8 goto :Convert
if errorlevel 7 goto :AS
if errorlevel 6 goto :BOT
if errorlevel 5 goto :SFS
if errorlevel 4 goto :Compile
if errorlevel 3 goto :Devmap
if errorlevel 2 goto :TestCompile
if errorlevel 1 goto :Start

goto :MainMenu



:TestCompile
cls

time /T
echo STARTING BSP:
start /low /B /wait %__BasePath%%__CompilerPath% -v -meta -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.map"

time /T
echo STARTING VIS:
start /low /B /wait %__BasePath%%__CompilerPath% -v -vis -fast -fs_basepath %__basePath% -fs_game %__FSGame% "%~d1%~p1%~n1.bsp"

time /T
echo STARTING RAD:
start /low /B /wait %__BasePath%%__CompilerPath% -v -light -fast -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.bsp"

goto :MainMenu



:Devmap
start %__basepath%%__GameEXE% +sv_pure 0 +r_gamma 1 +devmap %~n1
goto :MainMenu



:Compile

time /T
echo STARTING BSP:
start /low /B /wait %__BasePath%%__CompilerPath% %__BSP% -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.map"

time /T
echo STARTING VIS:
start /low /B /wait %__BasePath%%__CompilerPath% %__VIS% -fs_basepath %__basePath% -fs_game %__FSGame% "%~d1%~p1%~n1.bsp"

time /T
echo STARTING RAD:
start /low /B /wait %__BasePath%%__CompilerPath% %__LIGHT% -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.bsp"

goto :MainMenu



:SFS
   
start "Making .surface file" /B /wait %__BasePath%%__BPSPath% -se %~d1%~p1%~n1.bsp %~d1%~p1%~n1.surface
start "Opening surface sounds" /B compile/sfs/surfacesounds.surface "C:\Program Files (x86)\Windows NT\Accessories\wordpad.exe"                                       rem C:\Program Files (x86)\Windows NT\Accessories\
Start "Editing . surface file" /B /wait %~d1%~p1%~n1.surface "C:\Program Files (x86)\Windows NT\Accessories\wordpad.exe"                                  rem C:\Program Files (x86)\Windows NT\Accessories\
start "Applying .surface file to .bsp" /B /wait %__BasePath%%__BPSPath% -si %~d1%~p1%~n1.bsp %~d1%~p1%~n1.surface

pause
goto :MainMenu



:BOT
echo not done yet
pause
goto :MainMenu



:AS
echo not done yet
pause
goto :MainMenu



:Convert
cls

echo 0. map to ase
echo 1. bsp to ase
echo 2. bsp to map
echo 3. Main Menu


CHOICE /C 0123 /N /M "Choose a option."

if errorlevel 4 goto :MainMenu
if errorlevel 3 goto :Convert_bsp_map
if errorlevel 2 goto :Convert_bsp_ase
if errorlevel 1 goto :Convert_map_ase

goto :MainMenu



:Convert_map_ase
start /low /B /wait %__BasePath%%__CompilerPath% -v -meta -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.map"
start /low /B /wait %__BasePath%%__CompilerPath% -convert -format ase -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.bsp"

goto :MainMenu



:Convert_bsp_ase
start /low /B /wait %__BasePath%%__CompilerPath% -convert -format ase -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.bsp"

goto :MainMenu

:Convert_bsp_map
start /low /B /wait %__BasePath%%__CompilerPath% -convert -format map -fs_basepath %__BasePath% -fs_game %__FSGame% "%~d1%~p1%~n1.bsp"

goto :MainMenu



:Settings
notepad.exe "compile_v.1.1.bat"
goto :MainMenu



:Exit
exit


Comments and guiding bugreports are welcome.
This is a project im doing mostly for fun and for my own use.
Image

Post Reply