Cogito, ergo sum

Legacy:MutTutorial Code/Source Code

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Unchanged Source Code block from MutTutorial.[edit]

Class MutTutorial extends mutator;
//creates a new class for your mutator and makes it an extension of the mutator class.
//This makes it so it follows all the rules a mutator does.
Var() int XMultiJump, XBoost, XHealth;
// The var keyword prefixes a variable declaration.
// A variable declaration tells the engine what information this
// object needs to store and what kind of information it is.
// The type of information in this declaration is int, short
// for integer. An integer is a whole number, either positive
// or negative.
// The () puts these variables in a group and makes them
// visible in UnrealEds property browser. Since this is a
// mutator and likely won't be placed in a map, the () is
// probrably unnecessary.
Function Modifyplayer(pawn other)
//A function (set of actions, in the case of Uscript often predefined) that will modify the avatars/bots (pawns).
// Other is a variable that stores a reference to the player
// that we are modifying. The function uses this information
// to find the player amidst all the other things in the game
// world.
//I am using modify player because I want to change the properties of a player, in this case the MultiJumping power.
   // Local is just like the Var keyword - it tells the engine
   // that we need to store some information, and what type of
   // information to store. However, Local declarations go away
   // at the end of the function, while Var ones stay around
   // until this object is destroyed. (Since it's a mutator,
   // it will be destroyed when the level changes.)
   Local Xpawn x; //Xpawn = changeable guy
   // This stores the information we had in Other, in X as well.
   // We cast Other to an xPawn (which is what X is) because an
   // xPawn is a type of Pawn. (which is what Other is) Since
   // every xPawn is a Pawn, but not all Pawns are xPawns, we
   // have to tell the engine that the Pawn in Other is actually
   // an xPawn.
   X = xPawn(other);
   // Now we check to see if X holds valid information or not.
   // If it was a reference to a player that didn't actually
   // exist, or if the statement before this one (where we told
   // the engine that our Pawn (Other) was an xPawn turned out
   // to be untrue, then X might not hold valid information.
   // Most of the time it will hold valid information, but this
   // line checks just to be sure.
   if (X != None)
      // Make X's MaxMultiJump equal to XMultiJump etc.
      X.MaxMultiJump = XMultiJump;
      X.MultiJumpBoost = XBoost;
      X.Health = XHealth;
   FriendlyName="Mutation Tutorial" //Important, this is what will display in the game when you are selecting Mutators.
   Description="Changes your health and MultiJumping ability"