All pastes #2120036 Raw Edit

Someone

public text v1 · immutable
#2120036 ·published 2012-02-19 20:34 UTC
rendered paste body
@echo off
rem regen.bat does not support DCSS versions lower than .8.
rem -----------------------------------------
rem If modifications are made, take care to specify 
rem correct pathnames, as the savedir, backup1,
rem and backup2 directories are subject to irretrievable
rem deletion during the normal course of this batch.
rem -----------------------------------------
rem remember the current directory
rem -----------------------------------------
set home=%CD%
rem -----------------------------------------
rem The following lines reflect where
rem Crawl and the saves dir are stored on your PC
rem -----------------------------------------
set drv=c:
%drv%
set crawldir=\games\crawl
set crawlexe=crawl.exe
set savedir=%crawldir%\saves
rem -----------------------------------------
rem Specifies location of primary backup directory
rem Important: this directory is deleted.
rem -----------------------------------------
set backup1=%crawldir%\backup_saves
set backup2=%crawldir%\backup_saves_2
rem -----------------------------------------
rem Specifies where the optional Choose32.exe utility
rem is located (if present)
rem -----------------------------------------
set choosedir=\games\Choose32.exe
rem -----------------------------------------
rem This file should always be present in any saved game.
rem It is used to test for the existence of a save.
rem The variable may be helpful to those modifying the batch for
rem use with a different version of Crawl, newer or older.
rem -----------------------------------------
set save_file=*.cs
rem -----------------------------------------
rem Check the pathname assumptions and make
rem a few adjustments if necessary.
rem -----------------------------------------
if exist "%crawldir%\%crawlexe%" goto skipverify
set crawlexe=crawl-tiles.exe
if exist "%crawldir%\%crawlexe%" goto skipverify
rem -----------------------------------------
rem Check whether the Installer was used for all users.
rem (The Installer can install for all users or only for one.)
rem Note: The ProgramFiles variable is set by the OS.
rem -----------------------------------------
set crawldir=%ProgramFiles%\Crawl
if exist "%crawldir%\%crawlexe%" goto installer
rem -----------------------------------------
rem Installer may have selected just one user.
rem Note: The USERPROFILE variable is set by the OS.
rem -----------------------------------------
set crawldir=%USERPROFILE%\Local Settings\Application Data\Crawl
if exist "%crawldir%\%crawlexe%" goto installer
rem -----------------------------------------
rem Attempt to conform to Windows 7 based on suggestions by 'Anonymous'
rem -----------------------------------------
set crawldir=%ProgramFiles(x86)%\crawl
rem -----------------------------------------
:installer
rem -----------------------------------------
rem Assume that the Installer was used.
rem Note: The APPDATA variable is set by the OS.
rem -----------------------------------------
set installersave=%APPDATA%\Crawl
rem -----------------------------------------
rem Attempt to conform to Windows 7 based on suggestions by 'Anonymous'
rem -----------------------------------------
if not exist %installersave% set installersave=%APPDATA%\roaming\crawl
rem -----------------------------------------
set backup1=%installersave%\backup_saves
set backup2=%installersave%\backup_saves_2
set savedir=%installersave%\saves

:skipverify
cd "%crawldir%"
set backedup=FALSE

if exist "%crawlexe%" goto checkinit

echo.
echo. Error: unknown filename. Expecting %crawlexe%.
echo. Suggestion: modify the batch as needed.
echo.
pause
goto edit

:checkinit
rem --------------------------------------------------------
rem Mod init.txt if necessary to prevent version .8 cycling 
rem back to race selection menu upon character death
rem --------------------------------------------------------
find /C "restart_after_game = false" settings\init.txt
if errorlevel 1 echo restart_after_game = false >> settings\init.txt
:decision_time
cls
cd "%crawldir%"
echo Regen.bat for Dungeon Crawl Stone Soup, updated July 4th, 2011
echo by igor at http://techlorebyigor.blogspot.com
echo.
set bmsg=
set ba=backup available.
if exist "%backup1%\%save_file%" set bmsg=Crawl %ba%
if exist "%backup1%\sprint\%save_file%" set bmsg=%bmsg% Sprint %ba% 
if exist "%backup1%\zotdef\%save_file%" set bmsg=%bmsg% Zot Defense %ba%
if /I "%message%" NEQ "" echo %message%
if /I "%message2%" NEQ "" echo %message2%
if /I "%message3%" NEQ "" echo %message3%
echo.
if /I "%bmsg%" NEQ "" echo %bmsg%
echo.
set choose_label=[r]estart, [!] delete saves, [m]od settings, or [q]uit
echo. To restart Crawl, press 'r'
echo. To delete all previous saves and start afresh, press '!'
echo. To apply mods to the game settings, press 'm'
echo. To edit the batch file and quit, press +
echo. If you're satisfied with a heroic death, press 'q' to quit.
echo.
rem --------------------------------------------------------
rem Somewhat better functionality is possible with Choose32.exe from
rem http://www.westmesatech.com/editv.html
rem The location of this utility is controlled by the %choosedir% variable.
rem --------------------------------------------------------
if not exist "%choosedir%" goto simplequery
"%choosedir%" -c r!m+q -p "%choose_label%" -d r
rem errorlevel 1 will be the first option in choosdir sequence, above
if errorlevel 5 exit
if errorlevel 4 goto edit
if errorlevel 3 goto mods
if errorlevel 2 goto deletegames
if errorlevel 1 goto begin
echo. ERROR: Unexpected response
pause
exit

:begin
rem --------------------------------------------------------
rem If player recently backed up saved game, no need to copy
rem --------------------------------------------------------
if %backedup%==TRUE goto housekeeping
rem --------------------------------------------------------
rem Prepare to restore the preserved save files from backup_saves.
rem --------------------------------------------------------
if exist "%backup1%" del "%savedir%\*.*" /Q
if exist "%backup1%\sprint" del "%savedir%\sprint" /Q
if exist "%backup1%\zotdef" del "%savedir%\zotdef" /Q
rem --------------------------------------------------------
rem Restore backup directory to the saves directory.
rem It is necessary to copy the sprint subdirectory.
rem --------------------------------------------------------
if exist "%backup1%" copy "%backup1%\*.*" "%savedir%" /Y
if exist "%backup1%\sprint" copy "%backup1%\sprint" "%savedir%\sprint" /Y
if exist "%backup1%\zotdef" copy "%backup1%\zotdef" "%savedir%\zotdef" /Y
:housekeeping
set backedup=FALSE
if exist "%savedir%\logfile". del "%savedir%\logfile".
if exist "%savedir%\logfile-sprint". del "%savedir%\logfile-sprint".
if exist "%savedir%\logfile-zotdef". del "%savedir%\logfile-zotdef".
if exist "%savedir%\scores-zotdef". del "%savedir%\scores-zotdef".
if exist "%crawldir%\arena.result". del "%crawldir%\arena.result".

echo.You are currently playing the game...
%crawlexe%
rem --------------------------------------------------------
rem Set default messages
rem --------------------------------------------------------
set message=You have quit the game...
set message2=
set message3=
echo. %message%
rem --------------------------------------------------------
rem Existing arena.result indicates Arena was played
rem --------------------------------------------------------
if not exist "%crawldir%\arena.result" goto other_tests
cls
type "%crawldir%\arena.result"
echo.
pause
goto housekeeping

:other_tests
rem --------------------------------------------------------
rem Test for an exit from generic Crawl.
rem --------------------------------------------------------
set logfile=%savedir%\logfile
rem --------------------------------------------------------
rem Missing logfile indicates the current character survived
rem --------------------------------------------------------
if exist "%logfile%" goto testlogfile
rem --------------------------------------------------------
rem Test for an exit from Sprint. 
rem --------------------------------------------------------
set logfile=%savedir%\logfile-sprint
if exist "%logfile%" goto testlogfile
rem --------------------------------------------------------
rem Test for an exit from Zot Defense. 
rem --------------------------------------------------------
set logfile=%savedir%\logfile-zotdef
if exist "%logfile%" goto testlogfile
rem --------------------------------------------------------
rem Log file does not exist. 
rem At any rate, character survived.
rem --------------------------------------------------------
goto normalsave

:testlogfile
set message2=Liberalism has science on its side!
set message3=We have the technology to bring you back to life!
rem --------------------------------------------------------
rem If there was a killer, then the current character is dead.
rem This is the most likely scenario.
rem --------------------------------------------------------
find /C "killer=" "%logfile%"
rem --------------------------------------------------------
rem An errorlevel of 1 indicates the search text was not found
rem --------------------------------------------------------
if errorlevel 1 goto quittest
set message=You were defeated by the reactionaries!
goto decision_time
:quittest
rem --------------------------------------------------------
rem Check whether player quit game
rem --------------------------------------------------------
find /C "ktyp=quit" "%logfile%"
if errorlevel 1 goto checkforwin
set message=You quit the game. 
goto decision_time
:checkforwin
rem --------------------------------------------------------
rem If character won, quit.
rem --------------------------------------------------------
find /C "ktyp=win" "%logfile%"
if errorlevel 1 goto test_for_death
cls
echo.
echo. Congratulations on your victory!
echo.
pause
exit
:test_for_death
rem --------------------------------------------------------
rem Ktyp with unknown text indicates character was slain
rem --------------------------------------------------------
find /C "ktyp=" "%logfile%"
if errorlevel 1 goto decision_time
set message=You were defeated by the reactionaries!
goto decision_time

:edit
cls
echo. Environmental variables:
echo.
echo. Drive name is %drv%. Game directory is %crawldir%. Crawl .exe is %crawlexe%
echo. Saves directory is %savedir%
echo. Saves are backed up to %backup1% 
echo. and %backup2%
echo. Save file indicator is %save_file%
echo.
set bmsg=The optional Choose32.exe utility was
if not exist "%choosedir%" set bmsg=%bmsg% not
echo. %bmsg% found at %choosedir%.
echo.
echo Loading text editor...
rem --------------------------------------------------------
rem Vastly improved functionality is possible with Notepad++
rem --------------------------------------------------------
set notepad=\Program Files\Notepad++\notepad++.exe
if exist "%notepad%" call "%notepad%" %home%\regen.bat
if not exist "%notepad%" call notepad %home%\regen.bat
pause
exit

:simplequery
set /P userinput=Input your command and press Enter.
if "%userinput%"=="" goto decision_time
if /I %userinput%==+ goto edit
if /I %userinput%==q exit
if /I %userinput%==m goto mods
if /I %userinput%==r goto begin
if %userinput%==! goto deletegames
goto decision_time

:deletegames
rem --------------------------------------------------------
rem Delete all saved games and start afresh
rem --------------------------------------------------------
if exist "%backup1%" rd "%backup1%" /S /Q
if exist "%backup2%" rd "%backup2%" /S /Q
rem --------------------------------------------------------
rem Spare the subdirectories db and des.
rem --------------------------------------------------------
del "%savedir%\*.*" /Q
if exist "%savedir%\sprint" rd "%savedir%\sprint" /S /Q
if exist "%savedir%\zotdef" rd "%savedir%\zotdef" /S /Q
goto housekeeping

:mods
cd "%crawldir%\settings"
set speed=ACTIVE
set macro=ACTIVE
set perm=ACTIVE
find /C "tile_update_rate = 2500" tiles_options.txt
if errorlevel 1 set speed=INACTIVE
find /C "A:Zap" macro.txt
if errorlevel 1 set macro=INACTIVE
find /C "remember_name = true" init.txt
if errorlevel 1 set perm=INACTIVE
cls
echo. Igor's Mods Menu
echo. ----------------
echo.
echo. Speed mod: %speed%
echo. Macro mod: %macro%
echo. Name permanence mod: %perm% 
echo. (Note: Name permanence disables access to Sprint, etc.)
echo.
set choose_label=[s]peed, [m]acro, [p]erm, or [q]uit to main menu
echo. To toggle speed enhancement, press 's'
echo. To toggle macros, press 'm'
echo. To toggle name permanence, press 'p'
echo. To quit to the main menu, press 'q'
echo.
rem --------------------------------------------------------
rem Somewhat better functionality is possible with Choose32.exe from
rem http://www.westmesatech.com/editv.html
rem The location of this utility is controlled by the %choosedir% variable.
rem --------------------------------------------------------
if not exist "%choosedir%" goto simplequery2
"%choosedir%" -c smpq -p "%choose_label%" -d q
if errorlevel 4 goto decision_time
if errorlevel 3 goto name
if errorlevel 2 goto macro
if errorlevel 1 goto speed
echo. ERROR: Unexpected response
pause
exit

:simplequery2
set /P userinput=Input your command and press Enter.
if "%userinput%"=="" goto mods
if /I %userinput%==q goto decision_time
if /I %userinput%==s goto speed
if /I %userinput%==m goto macro
if /I %userinput%==p goto name
goto mods


:speed
set fi=tiles_options
if %speed%==ACTIVE copy "%fi%.bak" "%fi%.txt" /Y
if %speed%==ACTIVE goto mods
rem --------------------------------------------------------
rem speed up certain behaviors
rem --------------------------------------------------------
if not exist %fi%.bak copy "%fi%.txt" "%fi%.bak"
if %speed%==INACTIVE echo tile_update_rate = 2500   >> "%fi%.txt"
if %speed%==INACTIVE echo tile_runrest_rate = 300   >> "%fi%.txt"
goto mods

:name
set fi=init
if %perm%==ACTIVE copy "%fi%.bak" "%fi%.txt" /Y
if %perm%==ACTIVE goto mods
rem --------------------------------------------------------
rem avoid being queried about name
rem replace with your own preferred name
rem --------------------------------------------------------
if not exist %fi%.bak copy "%fi%.txt" "%fi%.bak"
if %perm%==INACTIVE echo name = glorious igor >> "%fi%.txt"
if %perm%==INACTIVE echo remember_name = true >> "%fi%.txt"
goto mods

:macro
set fi=macro
rem --------------------------------------------------------
rem macro.txt does not necessarily exist in a fresh install
rem --------------------------------------------------------
if not exist %fi%.txt echo. > %fi%.txt
if %macro%==ACTIVE copy "%fi%.bak" "%fi%.txt" /Y
if %macro%==ACTIVE goto mods
rem --------------------------------------------------------
rem The Function keys (F1 - F12) appear to be coded thus:
rem F1 is \{-282}
rem F2 is \{-283}
rem ...and so on?
rem --------------------------------------------------------
rem a helpful macro for spellcasters
rem press F1 for Z a p
rem --------------------------------------------------------
if not exist %fi%.bak copy "%fi%.txt" "%fi%.bak"
if %macro%==INACTIVE echo M:\{-282} >> "%fi%.txt"
if %macro%==INACTIVE echo A:Zap >> "%fi%.txt"
rem --------------------------------------------------------
rem a helpful macro for artificers & others would be
rem press F2 for V a p
rem --------------------------------------------------------
if %macro%==INACTIVE echo M:\{-283} >> "%fi%.txt"
if %macro%==INACTIVE echo A:Vap >> "%fi%.txt"
goto mods

:normalsave
if exist "%savedir%\%save_file%" goto save_game
if exist "%savedir%\sprint\%save_file%" goto save_game
if exist "%savedir%\zotdef\%save_file%" goto save_game
rem --------------------------------------------------------
rem if no save file, do not bother backing up
rem --------------------------------------------------------
goto decision_time

:save_game
cls
echo. If you wish to backup your game, press any key to continue.
echo. Otherwise, press Ctrl-C to quit.
pause

if exist "%backup2%" rd /S /Q "%backup2%"
md "%backup2%"
copy "%backup1%\*.*" "%backup2%" /Y
set s=%backup1%\sprint\%save_file%
set z=%backup1%\zotdef\%save_file%
if exist "%s%" md "%backup2%\sprint"
if exist "%s%" copy "%backup1%\sprint" "%backup2%\sprint" /Y
if exist "%z%" md "%backup2%\zotdef"
if exist "%z%" copy "%backup1%\zotdef" "%backup2%\zotdef" /Y

if exist "%backup1%" rd /S /Q "%backup1%"
md "%backup1%"
copy "%savedir%\*.*" "%backup1%" /Y
set s=%savedir%\sprint\%save_file%
set z=%savedir%\zotdef\%save_file%
if exist "%s%" md "%backup1%\sprint"
if exist "%s%" copy "%savedir%\sprint\*.*" "%backup1%\sprint" /Y
if exist "%z%" md "%backup1%\zotdef"
if exist "%z%" copy "%savedir%\zotdef\*.*" "%backup1%\zotdef" /Y

set message=You have backed up your saved game.
set message2=
set message3=
set backedup=TRUE

goto decision_time