My program doesn't have bugs. It just develops random features.
User:Eliot/Modify Players
This tutorial will explain how to make a simple Mutator(RTNP, U1, UT, U2, U2XMP, UE2Runtime, UT2003, UT2004, UDK, UT3) that can modify a player when the player spawns.
Note: You need to understand how to make a project and how to compile a project to succeed this tutorial.
First you will make a new .uc file named FastPacedMutator.uc, open it and write down the following code class FastPacedMutator extends Mutator;
, now you need to override a function from the parent class mutator named ModifyPlayer this function is called by the GameInfo.uc
class whenever a player is about to posses a new Pawn(RTNP, U1, UT, U2, U2XMP, UE2Runtime, UT2003, UT2004, UDK, UT3).
Write this code function ModifyPlayer( Pawn Other )
, Pawn is the object class this function accepts, you cannot change it because you have to accept the same class as the parent class mutator, Other is the name you will use as reference to the passed pawn instance, you can change this reference name to whatever you like.
now that's done you can start writing code, add {
next to the end of ModifyPlayer on a new line(optional), now lets use the Other reference to access a member of the class Pawn by doing Other.
followed by GroundSpeed
(you can always use something else too, just take a look at Pawn.uc
), now add +=
this is an operator that will increment the value of GroundSpeed by the specified value, you do this by writing 100
after the +=
, that's done now this means whenever this function is called, the passed Pawn instance will have it's GroundSpeed incremented by 100.
We got nothing else to add so you can finish this line by adding a ;
next to the value. Because this is the only thing you want this function to do you can tell the compiler where the end is of this function by writing }
on a new line.
That's how easy it is to do folks! now you've got a mutator that will increment the speed of all spawning players by 100!.
Additional functionality
To make this mutator cooler you could add a variable, see Variables e.g. var float GroundSpeedIncremention;
.
Add GroundSpeedIncremention += 0.1;
inside the ModifyPlayer function after the Other.GroundSpeed += 100;
line.
Change the Other.GroundSpeed += 100;
line to Other.GroundSpeed += 5 * GroundSpeedIncremention;
.
Now compile the mutator and test!. As you might have noticed this mutator will now increment the spawned player's GroundSpeed by 5 multiplied by GroundSpeedIncrementation, then GroundSpeedIncrementation is incremented by 0.1 so that the next time a player spawns he will be even faster than the first time a player spawned, and so on.
Example