Creating Your First Mutator

From BiaSDK
Jump to: navigation, search

Mutators are special Unreal Actors that allow you to modify or override the behavior of other Actors in the game.

You need to understand how to code in UnrealScript before you begin creating mutators on your own. See the following references for general UnrealScript coding syntax...

See the following Unreal Wiki article about the chain of events when a level (map) is started...

Notice that Mutators are created as one of the LAST STEPS of starting a level (so Mutators get created AFTER all other game actors have been created. See GameInfo.InitGame() for details).

Since Mutators are just like any other Unreal Actor, they have the same initialization sequence as any other Actor. See the following Unreal Wiki article about the chain of events that happens when an Actor is created...

Notice that PreBeginPlay(), BeginPlay() and PostBeginPlay() are called in the Mutator class just as they would be for any other Actor, so you can use these functions to initialize variables or set up other properties when the Mutator is first created.

Also, read this Unreal Wiki page about Mutators to understand what they can (and can't) do...

Now, here's an example of a very simple Mutator that simply outputs a text message to the .log file.

Create a new .uc script file with the following code:

class HelloWorld extends Mutator;
function PostBeginPlay() { Super.PostBeginPlay(); ModLog("Hello World"); }
defaultproperties { GroupName="Hello World" FriendlyName="Hello World Mutator" Description="Log Hello World" }

Compile using UCCDEPEND.

Load up MIG and enter FirstMutator for Mutator Package, HelloWorld for the Mutator Class, and whatever you want for the rest.

Click Generate File, then Okay. Open that file in an editor and fix the Mutator line from:

Mutators=(Class=class,MetaClass=Engine.Mutator,Name=FirstMutator.Mutator Class,Description="This is a test.")


Mutator=(Class=class,MetaClass=Engine.Mutator,Name=FirstMutator.HelloWorld Class,Description="This is a test.")

Save and close. Play EIB, load up your testuser (you do have a testuser that has console access, right?) and then go to Story mode, Chapters, Mutators. Your mutator should be listed. Add it, then go to the chapter list and load up a map.

Open the console and type 'ShowLog'

Viola. You should see a 'ScriptLog: Hello World' as the last line in the log.

Back to Main Page