Skip to content

Instantly share code, notes, and snippets.

@khasky
Last active Apr 13, 2022
Embed
What would you like to do?
Backup, compile and compress Killing Floor mutator using UCC (UnrealScript)
rem # Created by poosh (https://github.com/poosh) and edited by Khasky (https://github.com/khasky)
rem # PLEASE NOTE: For compile mutator using this batch you should append your package to EditPackages of /System/KillingFloor.ini
@echo off
color 07
setlocal
set MUT=ServerPerksMut
set KFDIR=C:\kfdev
set SYSTEMDIR=%KFDIR%\System
set BACKUPDIR=%KFDIR%\_BACKUP
set COMPRESSDIR=%KFDIR%\_COMPRESS
set OUTDIR=%KFDIR%\_OUTPUT
if not exist "%BACKUPDIR%" mkdir "%BACKUPDIR%"
if not exist "%COMPRESSDIR%" mkdir "%COMPRESSDIR%"
if not exist "%OUTDIR%" mkdir "%OUTDIR%"
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "DATETIME=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
rem # Save current directory
set CURDIR=%~dp0
rem #######################################
cd /D %SYSTEMDIR%
set T=Moving old mutator to backup
title %T%
echo %T%
ren %MUT%.u %MUT%_%DATETIME%.u
move "%SYSTEMDIR%\%MUT%_%DATETIME%.u" "%BACKUPDIR%"
ren %MUT%.ucl %MUT%_%DATETIME%.ucl
move "%SYSTEMDIR%\%MUT%_%DATETIME%.ucl" "%BACKUPDIR%"
cd /D %COMPRESSDIR%
del %MUT%.u.uz2
del %MUT%.ucl.uz2
cd /D %OUTDIR%
del %MUT%.u
del %MUT%.ucl
rem #######################################
cd /D %SYSTEMDIR%
set T=Running UCC complier
title %T%
echo %T%
ucc make
set ERR=%ERRORLEVEL%
if %ERR% NEQ 0 goto error
color 0A
rem #######################################
set T=Removing source code
title %T%
echo %T%
ucc Editor.StripSourceCommandlet %MUT%.u
rem #######################################
set T=Compressing files (%COMPRESSDIR%)
title %T%
echo %T%
ucc compress %MUT%.u
move "%SYSTEMDIR%\%MUT%.u.uz2" "%COMPRESSDIR%"
ucc compress %MUT%.ucl
move "%SYSTEMDIR%\%MUT%.ucl.uz2" "%COMPRESSDIR%"
rem #######################################
set T=Moving output
title %T%
echo %T%
xcopy "%SYSTEMDIR%\%MUT%.u" "%OUTDIR%"
xcopy "%SYSTEMDIR%\%MUT%.ucl" "%OUTDIR%"
rem # Return to previous directory
cd /D %CURDIR%
endlocal
echo --------------------------------
echo Compile successful.
echo --------------------------------
goto end
:error
rem # Restore backups on error
move "%BACKUPDIR%\%MUT%_%DATETIME%.u" "%SYSTEMDIR%
move "%BACKUPDIR%\%MUT%_%DATETIME%.ucl" "%SYSTEMDIR%"
ren %MUT%_%DATETIME%.u %MUT%.u
ren %MUT%_%DATETIME%.ucl %MUT%.ucl
color 0C
echo ################################
echo Compile ERROR! Code = %ERR%.
echo ################################
:end
pause
set ERRORLEVEL=%ERR%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment