If you want to help us maintaining this wiki, check out our discord server: https://discord.gg/3u69jMa 

Difference between revisions of "Create a new Mutator"

From SWRC Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 11: Line 11:
By the way, UnrealScript is case-insensitive!
By the way, UnrealScript is case-insensitive!


<source lang="cpp" line">
<syntaxhighlight lang="C++" line>
class TestMutator extends Mutator;
class TestMutator extends Mutator;
</source>
</syntaxhighlight>


That's the way every class starts. '''class <subclass> extends <parentclass>;'''
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.
<syntaxhighlight lang="C++" line>
function PostBeginPlay()
{
    //Code here...
}
</syntaxhighlight>
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:
<syntaxhighlight lang="C++" line>
    Class'MPClone'.Default.JumpZ = 800;  //Default is 475
    Class'MPTrandoshan'.Default.JumpZ = 800;  //Default is 475
</syntaxhighlight>
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:
<syntaxhighlight lang="C++" line>
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
}
</syntaxhighlight>
That's an easy starter mutator, where new stuff can easily be added anytime.
For a more detailed view on UnrealScript, look [https://docs.unrealengine.com/udk/Three/UnrealScriptFunctions.html here]

Latest revision as of 18:16, 8 July 2021

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.

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!

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