How to Setup Unrealscript Environment

Obtain IDE (Sublime Text 3)

  • Sublime Text 3
    • Install UnrealScript IDE plugin
      1. Open Sublime Text 3
      2. Press Ctrl + Shift + P
      3. Type "install" (this should select "Package Controll: Install Package"), hit enter
      4. Search for "UnrealScriptIDE", hit enter.
  • Other choices


Install Killing Floor 2 SDK

  1. Open Steam 
  2. Click Library 
  3. Click Tools - See Figure 2.1
  4. Install the Killing Floor 2 - SDK
    • Keep in mind where this is installed to, we will be including the Scripts from this install

Figure 2.1 

Creating New Sublime Project

  1.  Click Project>Add Folder to Project
    • See Figure 3.1
  2. Add Killing Floor 2 source Scripts
    • Located in <Steam Install Location from previous step>\steamapps\common\killingfloor2\Development\Src
  3. Create a folder for your Mod
    1. Make a new directory called "Src" in <drive:>\Users\<user>\Documents\My Games\KillingFloor2\KFGame. This is specified in KFEditor.ini, [ModPackages], ModPackagesInPath
    2.  Make a new directory for your mod in Src directory (e.g. KFGame\Src\MyMod)
    3. Make a "Classes" directory in your new mod directory (e.g. KFGame\Src\MyMod\Classes)
    4. Put your mod source files in Classes directory (e.g. KFGame\Src\MyMod\Classes\MyMod.uc)
  4. Add Folder To your project
    1. Once this step is done, your folder structure should look something like this:

    • See Figure 3.2

  5. Save your Project - Do not forget this step other wise you will have to start over 
    1. Tip - Save all of your Sublime projects together in a SublimeProjects folder in My Documents

Figure 3.1


Figure 3.2


Include Your Package In KFEditor.ini

This step is very important, especially, if you are going to be using custom UDK files and/or other content.


KFEditor.ini is located at <Drive>:\Users\<User>\Documents\My Games\KillingFloor2\KFGame\Config


In KFEditor.ini:


[ModPackages]
ModPackagesInPath=..\..\KFGame\Src
ModOutputDir=..\..\KFGame\Unpublished\BrewedPC\Script
ModPackages=MyMod


NOTE: User must have at least ran and closed the Editor to generate the KFEditor.ini file.

Creating an Example Mutator

This file will be for testing your compiler.

  1. Start a new script in Sublime with Ctrl-N
  2. Insert the Script from the Example 
  3. Save the Script as KFMutator_Example.uc in  - <Drive>:\Users\<User>\Documents\My Games\KillingFloor2\KFGame\Src\MyMod\Classes

NOTE: The Name of the file must match the name of the class.

KFMuatator_Example.uc
//=============================================================================
// KFMutator
//=============================================================================
// Example mutator class for KF2
//=============================================================================
class KFMutator_Example extends KFMutator;
/**
* This function can be used to parse the command line parameters when a server
* starts up
*/
function InitMutator(string Options, out string ErrorMessage)
{
super.InitMutator( Options, ErrorMessage );
`log("This is my Example Mutator");
}

Compiling via Command Console

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)



Figure 6.1

Compile via Workshop Upload Tool

  1. Launch the Workshop Upload tool by double clicking the Killing Floor 2 - SDK in Steam.  See Figure 7.1
  2. Click on the Maps/Mods tab
  3. Create new workshop item if you do not have an existing one for your current project
  4. Give the Item a name then click OK. See Figure 7.2
  5. Make sure that your item is selected in the left pane.
  6. Add your Script Source to compile See Figure 7.3
  7. If your mod is using custom packages Add them in the Packages to brew (in our case it is ExampleMeleeWeapon)
  8. Click the drop down on the Script button and click Compile scripts.  See Figure 7.4
  9. The compiler will run and output the results the in console at the bottom of the window.
  10. This will create an "Unpublished" version of your mutator. 
    • This can be used for testing the mutator with the launch command line arguement -useunpublished.  This will come later on in the tutorial
  11. Click the drop down on Brew and select Brew Packages to create a published version of the mutator.  See Figure 7.5
    • No addition command line arguments are need to run this other than running the mutator.

How to Run a mod / mutator

  • 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)


Figure 7.1

Figure 7.2

Figure 7.3

Figure 7.4


Figure 7.5

Test To Verify The Mutator is Working

  1. Open the command prompt and navigate to your Steam Killing Floor 2 binaries directory (<drive:>\Steam\SteamApps\common\killingfloor2\Binaries\Win64)
  2. run the following command KFGame.exe KF-BioticsLab?mutator=MyMod.KFMutator_Example -log
    • If your have not brewed your mod, remember to add the command  -useunpublished 
    • This command can also be run through the console in game by pressing F3 or ` to open the console 
  3. When the game launches, a window will appear containing your log. 
    • (An output of this log can be found in the folder: <drive:>\Users\<User>Documents\My Games\KillingFloor2\KFGame\Logs)
  4. In the log we should see the line This is my Example Mutator and Mutators MyMod.KFMutator_Example See Figure 8.1


Figure 8.1