Wednesday, 18 May 2011

UDK Mutator Tutorial - For us UCS first years who can't use Chris' tutorial

Hey guys, it's me again with a random blog post, this time this is purely for my classmates at Uni to use to help them create UDK Mutators. Hope this helps guys ;)
----------------------------------------------------------------------------------
Adam’s Mutator Tutorial that is miles better than Chris’

Step 1: Finding the Development folder
The first thing that you have to do is go to ‘My Computer’ and then ‘Local Disc (C:)’ in this there should be a folder called ‘UDK’. In this folder go into ‘UDK <Latest date>’ (Note: It won’t say latest date, it will most likely be 2011-01-03) and finally in this folder there is one called Development – this is the first folder we need to be in.

Step 2: Create your folders
Easy enough, in this Development folder make a new folder and name it after yourself (for example, I would make a folder called ‘Adam’). Once you have made this folder, open it and then make a  folder inside it called ‘Classes’ – it is in this folder that we will make our Mutator files later on.

Step 3: Changing existing file number 1
Now that the folders are set up, go back to the folder that is called ‘UDK<latest date>’ and in this folder go into the folder called ‘UDKGame’ and then finally in this folder go into the one called ‘Config’. In this folder open the file that is called ‘DefaultEditorUDK.ini’ – it should open in notepad. A few lines down the text pad you should see a block of text with the following 3 lines of text:-
[ModPackages]
ModPackagesInPath=..\..\UDKGame\Src
ModOutputDir=..\..\UDKGame\Unpublished\CookedPC\Script

Chance the second line of text so that it says ‘ModPackagesInPath=..\..\Development\Src’ and then, under the whole block of text add a line of text which says ‘ModPackages=<YourName>’ and then change the <YourName> part so that it is the same as the folder you made with your name (for example, in my case it would be ModPackages=Adam). You should now have a block of text that looks like so:-
[ModPackages]
ModPackagesInPath=..\..\Development\Src
ModOutputDir=..\..\UDKGame\Unpublished\CookedPC\Script
ModPackages=<YourName>

After this save and close the file.

Step 4: Changing existing file number 2
In the same folder we are already in, find a file called ‘DefaultEngine.ini’ and open that as you did the previous file. Find a block of text a few lines down that looks as follows:-
            [UnrealEd.EditorEngine]
            Other lines that start with ‘+EditPackages’

No lines of this need to be changed but you need to add a line to the bottom of this block of text which says ‘ModEditPackages=<YourName>’, changing the <YourName> part to the folder you created with your name (in my case it would be ‘ModEditPackages=Adam’). You should now have a block of text that looks like so:-
[UnrealEd.EditorEngine]
            Other lines that start with ‘+EditPackages’
            ModEditPackages=<YourName>

After this, save and close this file.


Step 5: Adding your Mutator file and information
Right-click in the folder and go to New and create a new text document. Make the name of this file ‘UDK<YourName>.ini’ changing <YourName> to the folder you created with your name (so mine would be ‘UDKAdam.ini’). A message come up about changing the file extension, click on yes when this comes up. Open this file and type in the following line of text, replacing where it says your name with… you get the idea by now:-
[UTMutator_SuperRegen UTUIDataProvider_Mutator]
ClassName=<YourName>.UTMutator_SuperRegen
FriendlyName=Health Mutator
Description=This is my Health Mutator (<YourName>)

After this save and close the file.

Step 6: Writing the Script for the Pawn (player)
In this step I will literally copy and paste the script to make the Mutator, if you want an explanation of what each line does just look at Chris’ tutorial as the explanations are correct. Anyways, go back to the folder you made with your name and go to the classes folder inside it (this should be back 2 folders and then in Development, then Src). Inside the classes folder, right-click and make a new Text Document and call it ‘UTPawn_SuperRegen.uc’ selecting yes when the file extension message pops up.

Open this new file; you will most likely have to choose to open it with notepad when doing this for the first time. Then copy the following lines of script in the EXACT format it appears below:-

class UTPawn_SuperRegen extends UTPawn;

var int RegenPerSecond;

simulated function PostBeginPlay()
{
// call the parents version of this function
Super.PostBeginPlay();

SetTimer(1.0, true);
}

function Timer()
{
if ( Controller.IsA(‘PlayerController’) && !IsInPain() && Health < SuperHealthMax)
{
Health = Min(Health+RegenPerSecond, SuperHealthMax);
}
}

defaultproperties
{
RegenPerSecond = 10
}

After this save and close the file.

Note: If you are copying and pasting this code, delete and re-type the apostrophes (‘) around PlayerController as UDK is fussy about them.



Step 7: Writing the Script that implements your Mutator into the game itself
Same as before, if you want to understand the code look at Chris’ tutorial. Make another text document, this time call it ‘UTMutator_SuperRegen.uc’. Open it and type the following lines of text:-

class UTMutator_SuperRegen extends UTMutator;

simulated function PostBeginPlay()
{
// call the parents version of this function
Super.PostBeginPlay();

WorldInfo.Game.DefaultPawnClass = class’<YourName>.UTPawn_SuperRegen’;
}

defaultproperties
{
GroupNames[0] = “PLAYERMOD”
}

As usual, replace <YourName> with the name of the folder you made with your name, after this save and close the file.

Note: If you are copying and pasting this code, delete and re-type the apostrophes (‘) around <YourName>.UTPawn_SuperRegen as UDK is fussy about them as well as deleteing and re-typing the speech marks (“) around PLAYERMOD.

Step 8: Compiling the Script
Close all your folders. Click on Start, and then go to ‘All Programs’, ‘Unreal Development Kit’, <Most recent date folder> (probably 2011-01-03), ‘Tools’ and then load ‘Unreal Frontend’. When this is open, make sure that you have clicked on UDK DM-Deck on the 3 choice below where the start button is (it’s the only one that doesn’t have MobileGame in its description) and then click on the drop-down arrow under Start in the top-right hand corner and click on ‘Start:Rebuild Script’.

After this you should (fingers crossed) have no errors and your script will be rebuilt with your Mutator added. This is the most temperamental part of the whole process so if you get errors make sure everything is as setup as detailed above and failing that, summon Chris to check it all…

After this UDK should automatically load up.

Step 9: Checking the Mutator works
Once UDK has loaded up, choose ‘Instant Action’ and then under ‘Mutators’ you should see your Mutator called ‘Health Mutator’. Enable it and then start a game. If its worked you should be getting +10 Health every second and you are done… unless you wish to make your own personal Mutator or whatever. If it hasn’t worked then check the 2 files of code are both EXACTLY correct and then failing that call Chris again…

You are now done but carry on reading if you want to know little changes you can make, such as changing the name and description of your Mutator and a link to a page with some variable you may wish to add to your Mutator to change them.



Step 10: Little Extras
  1. To change the name and description of your Mutator open up the UDK<YourName>.ini file you made in ‘UDKGame’ and then ‘Config’. The ‘FriendlyName’ line is the one that determines the name of your Mutator and the ‘Description’ one changes the description.
  2. Visit http://wiki.beyondunreal.com/UE3:Pawn_internal_variables_%28UDK%29 for a list of variable that you can put into your script and change if you wish. The file you need to put them in is the ‘UTPawn_SuperRegen.uc’ file that is located in the folder with your name. This is mostly trial and error work getting it to work so its down to you.
Step 11: Submiting the work
When handing in the work all you need to put onto a USB or CD to submit it are the following 4 files:-
  1. The file called UTMutator_SuperRegen.uc located in the folder with your name.
  2. The file called UTPawn_SuperRegen.uc located in the folder with your name.
  3. The file called UDK<YourName>.ini located in the UDKGame Config folder.
  4. The file called <YourName>.u located in the following folder Local Disc (C:) -> UDK -> UDK<LatestDate> -> UDKGame -> Script.
And that is everything – it’s in your hands now. Any help needed ask me if I’m about or over Facebook or whatever if I'm online or ask Chris if he’s there.

BigAd
----------------------------------------------------------------------------------
So yea, 'til next time - that's all folks!

1 comment:

  1. i have mutator to show up but none of my changes seem to take effect. I even try calling clientmessage to print.

    ReplyDelete