Compiling Killing Floor Packages with ucc make
ucc make is the UnrealScript compiler that comes with Unreal Engine 2 games. Killing Floor 1 has it in the System folder next to KillingFloor.exe. This guide adapts the classic Unreal Wiki page "Compiling With UCC" to KF's file names.
Folder layout
UCC looks for sources in a folder named after the package, in the game root, with a Classes subfolder:
KillingFloor/
├── System/
│ ├── ucc.exe
│ ├── KillingFloor.ini
│ └── MyMutator.u <- compiled result
└── MyMutator/
└── Classes/
├── MyMutator.uc
└── MyHelper.uc
The package name is the folder name, and each class file must be named after the class it declares.
Register the package
Open System/KillingFloor.ini, find the EditPackages= lines in [Editor.EditorEngine] and add yours at the bottom:
EditPackages=Core
EditPackages=Engine
; ...the rest of the stock list, including KFMod...
EditPackages=MyMutator
Order matters. Packages are compiled top to bottom, and a package can only use classes from packages listed above it. If your mutator depends on, say, ServerPerks, its EditPackages line must come before yours.
Compile
cd "C:\Program Files (x86)\Steam\steamapps\common\KillingFloor\System"
ucc make
ucc make goes through every EditPackages entry and compiles only the packages that have no .u file yet. If you change the code and run it again, nothing happens, because MyMutator.u already exists. Delete the old .u first:
del MyMutator.u
ucc make
The full output is also written to System/ucc.log.
A faster per-project ini
With the stock ini, UCC loads every package listed there on each run. Make a copy of KillingFloor.ini, for example MyProject.ini, keep in it only the EditPackages your code needs plus your own package, and compile with it:
ucc make -ini=MyProject.ini
Batch files
Back up, delete, rebuild and wait for a key press:
@echo off
cd /d "%~dp0"
copy MyMutator.u MyMutator.u_backup >nul 2>&1
del MyMutator.u >nul 2>&1
ucc make -ini=MyProject.ini
pause
A loop that shows the result in the window title and rebuilds on any key:
@echo off
:start
title COMPILING :: MyMutator
cls
copy UCC_MyMutator.log UCC_MyMutator_OLD.log >nul 2>&1
del MyMutator.u >nul 2>&1
ucc make -ini=MyProject.ini -log=UCC_MyMutator.log
if errorlevel 1 goto error
title OK :: MyMutator
goto done
:error
title ERROR :: MyMutator
:done
findstr /c:"Log file closed" UCC_MyMutator.log
echo.
pause
goto start
Put either file in System. Keeping the previous log (_OLD.log) makes it easy to compare two builds.
So you do not have to decompile the stock packages by hand after every update, Dr_Killjoy posted a batch file in the "Декомпиляция стандартного кода" (Decompiling the stock code) thread on the killingfloor.ru forum. Dir holds the path of the server folder you compile in, and three lines are repeated for each package:
set Dir=C:\...
set Package=Core
del %Dir%%Package% /q
UCC.exe BatchExport %Package% class uc %Dir%%Package%\Classes
set Package=KFMod
del %Dir%%Package% /q
UCC.exe BatchExport %Package% class uc %Dir%%Package%\Classes
pause
His version exports Core, engine, goodkarma, ipdrv, Fire, GamePlay, editor, GUI2K4, unrealed, unrealgame, utv2004c, utv2004s, uweb, xadmin, xgame, xinterface, xvoting, xwebadmin, ROEngine, ROEffects, ROInterface, Old2k4, KFGui, KFMod, KFChar and KFMutators this way.
Flame recommended finding code exactly like this: decompile all the stock packages and search the files for the string you need. For example, exec function ReloadMeNow() (reloading) and ToggleIronSight are in KFMod.KFWeapon; the latter calls PerformZoom from ROEngine.ROProjectileWeapon. Your own exec functions are usually declared in the controller ("Контроль игрока" (Player control) thread).
Common problems
| Message or symptom | Cause |
|---|---|
| Nothing is compiled, no errors | The .u already exists. Delete it |
Can't find files matching ...\Classes\*.uc | Wrong folder: sources must be in <KF root>\<Package>\Classes |
Unrecognized type / Bad class definition for a class from another package | That package is missing from EditPackages or listed below yours |
Superclass ... not found after editing the ini | You edited a copy of the ini but compiled without -ini= (or the other way round) |
| The server rejects clients after a rebuild | A changed .u with the same name causes Package version mismatch for anyone with the old copy in Cache. Rename the package (MyMutatorV2) for each public release |
The file '..\NZPR\Inc\NZPRClasses.h' needs to be updated. Do you want to overwrite the existing version? (Y/N) | Answer N: compilation finishes normally, while Y gives a couldn't open file error. In forum experience the prompt is caused by an extra orphan class in the package (an emitter, an unused class); removing it makes the prompt go away (killingfloor.ru forum, "Сообщение ...Classes.h' needs to be updated..." thread) |
A downloaded weapon with sources fails to compile after edits: a resource package is not found (for example SVDLLI_A) | Resources the code refers to are missing: put .ukx into Animations and .utx into Textures. Search System\ucc.log for error for details (killingfloor.ru forum, "Изменение оружия" thread) |
Superclass KFPlayerController_Story of class KFPCServ not found when building ServerPerks 7 | EditPackages=KFStoryGame and EditPackages=KFStoryUI are missing above the ServerPerks packages (or the server is too old) (killingfloor.ru forum, "Ошибка, при компиляции SP 7" thread) |
Error: ... Unknown property in defaults: showMesh=SkeletalMesh'...' in weapon Pickup classes (after patch 1058) | The showMesh variable was removed from the Pickup class. Delete or comment out the line; according to Flame it does not affect how the packages work. If the third-person weapon model then loses its textures, move the line into the weapon's attachment class without "show": Mesh=SkeletalMesh'XMV850_A.XMV850-3rd' (killingfloor.ru forum, "Патч 1058 - Проблемы и их решения" thread) |
UCC will not compile or decompile in any folder: General Protection Fault! and History: appInit | For Dr_Killjoy the cause was Steam running; a simple PC reboot also helped (killingfloor.ru forum, "Полетел ucc" (ucc broke) thread) |
| ScrnBalance does not build after editing perk bonuses | ScrnBalance is an add-on over ServerPerks and requests its classes when compiling: add the ServerPerks sources to the build (Dr_Killjoy, killingfloor.ru forum, "ScrnBalance" thread) |
#exec OBJ LOAD FILE=... lines in your .uc files tell UCC which .utx/.uax/.ukx files to load while compiling. They are not stored in the .u and do not make a server send those files to clients.
ServerPerks as a single package
To build ServerPerks V7 as one package (killingfloor.ru forum, "Compiling SP V7" thread, answer by kok-s): move all classes into the ServerPerks package, then find references to ServerPerksP and ServerPerksMut in them and replace them with ServerPerks.