KF2 Code Modding How-to
Or: How to create, compile, brew, and run a custom GameInfo or Mutator mod
1. Create new .uc file(s)
- If creating a new game mode, create a new GameInfo class that extends KFGameInfo (or one of its derivatives)
- If creating a mutator, create a new Mutator class that extends KFMutator
2. Save your file(s) to your "My Games" folder
a. Make a new directory called "Src" in <drive:>\Users\<user>\Documents\My Games\KillingFloor2\KFGame. This is specified in KFEditor.ini, [ModPackages], ModPackagesInPath
b. Make a new directory for your mod in Src directory (e.g. KFGame\Src\MyMod)
c. Make a "Classes" directory in your new mod directory (e.g. KFGame\Src\MyMod\Classes)
d. Put your mod source files in Classes directory (e.g. KFGame\Src\MyMod\Classes\MyMod.uc)
3. Add a ModPackage entry for each package that your mod uses
In KFEditor.ini:
[ModPackages]
....
ModPackages=MyMod1
ModPackages=MyMod2
4. Compile your file(s)
a. Open the command prompt and navigate to your Steam Killing Floor 2 binaries directory (<drive:>\Steam\SteamApps\common\killingfloor2\Binaries\Win64)
- or, navigate to that directory in Windows Explorer, shift+right-click and select "open command window here"
b. Type "kfeditor make" and hit enter. The compiled .u file (e.g. MyMod.u) can then be found in your My Games directory (My Games\KillingFloor2\KFGame\Unpublished\BrewedPC\Script)
How to run a mod
- If running with a GameInfo mod, add "?game=<packagename.scriptname>" to the command line (e.g. kf-burningparis?game=mymod.mygameinfo)
- If running with a Mutator mod, add "?mutator=<packagename.scriptname>" to the command line (e.g. kf-burningparis?mutator=mymod.mymutator). You can run with multiple mutators by separating them with commas (e.g. kf-burningparis?mutator=mymod.mymutator1,mymod.mymutator2)
5. Test your mod (by running as "unpublished")
Run your mod with an additional command-line parameter, "-useunpublished", to test it before brewing. Brewing will "publish" your content and put it in a Published directory, which the game needs when not using -useunpublished.
5. Brew your file(s)
On the command prompt, type "kfeditor brewcontent -platform=PC <compiled mod package>" (e.g. kfeditor brewcontent -platform=PC MyMod) and hit enter. You can brew more than one compiled file by separating each one with a space (e.g. MyMod1 MyMod2). Brewing will create a "Published" directory in My Games\KillingFloor2\KFGame, in which the brewed mod files need to live to be run.
6. Run your mod (as "published")
Now that your mod has been created, compiled, tested, and brewed, it can be run without the "-useunpublished" command-line parameter.
Troubleshooting
- If you crash while running "make" or "brewcontent", try running again with the "-useunpublished" command-line parameter.
Related articles