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

Create a new Mutator: Difference between revisions

From SWRC Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 15: Line 15:
class TestMutator extends Mutator;
class TestMutator extends Mutator;
</syntaxhighlight>
</syntaxhighlight>


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

Latest revision as of 22:55, 11 August 2024

Let's take the knowledge from Create a new sciptable Class and 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 after the level has been loaded.

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


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

We take a class which properties we want to change, Clones and Trandos in multiplayer. MPClone and MPTrandoshan in this case. 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.


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