Check out our discord at https://discord.gg/3u69jMa 

Create a new Mutator

From SWRC Wiki
Revision as of 22:51, 11 August 2024 by Plasma (talk | contribs) (Created page with "Let's take the knowledge from Create a new sciptable Class and let's make a new Mutator for SWRC. In this case I already created a new subclass in Mutator called TestMutator. File:Mut1.PNG So open up the script in UnrealED or outside in notepad. The first line is always the class definition and linking to parent class. By the way, UnrealScript is case-insensitive! <syntaxhighlight lang="C++" line> class TestMutator extends Mutator; </syntaxhighlight> That...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Let's take the knowledge from Create a new sciptable Class and let's make a new Mutator for SWRC.

In this case I already created a new subclass in Mutator called TestMutator.

So open up the script in UnrealED or outside in notepad.

The first line is always the class definition and linking to parent class.

By the way, UnrealScript is case-insensitive!

	class TestMutator extends Mutator;

That's the way every class starts. 'class <subclass> extends <parentclass>;'

Next we will use one of the most common default function in Unrealscript: 'PostBeginPlay' This one gets called when we load the script, like a starting point you could say.

function PostBeginPlay()
{
    //Code here...
}

So let's say I would like to change some default properties for the game. For example I want the clones and trandos be able to jump higher:

    Class'MPClone'.Default.JumpZ = 800;  //Default is 475
    Class'MPTrandoshan'.Default.JumpZ = 800;  //Default is 475

So let's explain what we are doing here. We take a class which properties we want to change, Clones and Trandos in multiplayer. MPClone and MPTrandoshan are self explaining. The "Default" keyword is being used to access/modify the default values of the class. JumpZ is a variable in Pawn Class for moving the pawn in Z axe (jumping).

Since those two MP classes extends Pawn class, we can use/modify the values. Last but not least, we assign a new value of 800 to the JumpZ variable.

So let's sum up the code:

class TestMutator extends Mutator;

function PostBeginPlay()
{
    Class'MPClone'.Default.JumpZ = 800;  //Default is 475
    Class'MPTrandoshan'.Default.JumpZ = 800;  //Default is 475

    Log("My new mutator got loaded successfuly.");  //Added this small log window output :3
}

That's an easy starter mutator, where new stuff can easily be added anytime.

For a more detailed view on UnrealScript, look here