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
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..."
 
No edit summary
Line 1: Line 1:
Let's take the knowledge from [[Create a new sciptable Class]] and let's make a new Mutator for SWRC.
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.
In this case I already created a new subclass in Mutator called TestMutator.


[[File:Mut1.PNG]]
[[File:Mut1.PNG]]


So open up the script in UnrealED or outside in notepad.
So open up the script in UnrealED or outside in notepad.
Line 17: Line 18:
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.
Next we will use one of the most common default function in Unrealscript: 'PostBeginPlay' This one gets called after the level has been loaded.


<syntaxhighlight lang="C++" line>
<syntaxhighlight lang="C++" line>
Line 26: Line 27:
</syntaxhighlight>
</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:
 
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>
<syntaxhighlight lang="C++" line>
Line 33: Line 35:
</syntaxhighlight>
</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).
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.
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>
<syntaxhighlight lang="C++" line>
Line 50: Line 51:
}
}
</syntaxhighlight>
</syntaxhighlight>


That's an easy starter mutator, where new stuff can easily be added anytime.
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]
For a more detailed view on UnrealScript, look [https://docs.unrealengine.com/udk/Three/UnrealScriptFunctions.html here]

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