Creating A Basic Mutator

From Tripwire Interactive Wiki
Revision as of 11:11, 22 September 2012 by Benjamin (talk | contribs) (→‎See also)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a step-by-step guide on how to create a mutator for Killing Floor. It is taken from the tutorial of the same name, written for the official Tripwire Interactive forums by Benjamin.

Create directory hierarchy

Create a directory in .../steamapps/common/killingfloor with the same name you wish to give your mutator. Create a subdirectory inside this named Classes. You should now have a directory structure that looks like this:

.../steamapps/common/killingfloor/ExampleMutator/Classes

Create script file

Inside the Classes subdirectory create a file with a .uc extension with a name matching the mutator's main directory name, for example ExampleMutator.uc. The path of this file should look like this:

.../steamapps/common/killingfloor/ExampleMutator/Classes/ExampleMutator.uc

Add mutator to compilation

In order to have the compiler actually compile your mutator you must add an entry for it in the game's configuration file, named killingfloor.ini, located in the game's system directory. Open this file, search for the section with several lines beginning with EditPackages=PackageName. Add an entry at the bottom of this list to include the name of your mutator package, which should look like this:

EditPackages=ExampleMutator

Write mutator script

class ExampleMutator extends Mutator;

defaultproperties
{
    GroupName="KFExampleMutator"
    FriendlyName="Example Mutator"
    Description="Mutator description here"
}

This is the bare minimum for compiling a mutator that can be seen in Killing Floor (actually, FriendlyName and Description aren't strictly necessary). The GroupName property must start with the letters KF else it won't be seen by the game.

Compile

Compiling the mutator is as simple as calling ucc make, which can be found in the system directory (in fact the file is simply called ucc.exe and make is a command line argument). Note that if you have previously compiled the mutator you must remove its .u file from the system directory in order to recompile (otherwise the mutator will be ignored in the compilation process).

If you cannot find ucc.exe you may not have the Killing Floor SDK installed. Find it on Steam in the tools section.

Additionally you may want to remove certain files and have the console wait before closing, so that you can view the compilation output (and thus determine if it failed and why). You could do all this by opening command prompt and typing the commands manually, but it's far simpler to use a batch file. Create a batch file (anywhere - the desktop is good for easy access) with a name such as ExampleMutator.bat and copy the following lines in:

del "C:\Program Files\Steam\steamapps\common\killingfloor\System\ExampleMutator.u"
"C:\Program Files\Steam\steamapps\common\killingfloor\System\UCC.exe" make
del "C:\Program Files\Steam\steamapps\common\killingfloor\System\steam_appid.txt"
pause

You may need to alter the paths if you have the game installed to a different hard drive or have a different directory structure. The third line removes a file generated by UCC which while exists will prevent connecting to servers (may not apply to all).

Run the batch file and tada! If compilation was successful, you have just made your first mutator. If not, you have made a mistake and should re-read this article to try to find where you went wrong.

Example

Here is a functional, more interesting mutator to take a look at:

class ExampleMutator extends Mutator;

function PostBeginPlay()
{
	SetTimer(1, true);
}

function Timer()
{
	local KFHumanPawn Player;
	
	foreach DynamicActors(class 'KFHumanPawn', Player)
	{
		if (Player.Health + 2 <= Player.HealthMax) Player.Health += 2;
		else Player.Health = Player.HealthMax;
	}
}

defaultproperties
{
    GroupName="KFExampleMutator"
    FriendlyName="Example Mutator"
    Description="Mutator description here"
}

What it does: Increases the health of each player by 2 points every second.

Where do I go from here?

Now that you understand how to compile a mutator, I'd recommend first taking a look at the official UnrealScript Language Reference which covers all aspects of the language itself. If you plan to write mutators which work online it's vital that you understand how the networking is handled, and I'd suggest reading the Unreal Networking Architecture article on this. If you want to know more about the engine (and particularly which classes are available to use) you can either browse through the script files yourself, or check out the BeyondUnreal Wiki for more general information relating to Unreal Engine itself.

See also