
In this tutorial I’m going to cover some basic things regarding coding for UT3. Specifically I’m running through where to put the code, compiling it, cooking it and using it.
Any time I refer to the My Documents UT3 folder I mean “My Documents\My Games\Unreal Tournament 3\” or “C:\Documents and Settings\YOURUSERNAME\My Documents\My Games\Unreal Tournament 3\” with YOURUSERNAME being the username for an account on your PC. These two are the same location and it’s shorter to refer to the My Documents version, but the longer Documents and Settings version will appear in the address bar of Windows Explorer.
My install folder is “C:\UT3\”, yours is probably “C:\Program Files\Unreal Tournament 3\” (or “C:\Program Files\Steam\steamapps\common\unreal tournament 3″ if you have the Steam version) so go to your install folder if I reference “C:\UT3\”.
Don’t confuse these two sets of folders. You don’t put anything in your install folder, everything happens in the My Documents folder except for running the programs that live in the install folder (UT3.exe and UnrealFrontend.exe).
If I refer to a folder that doesn’t exist in your My Documents UT3 folder then create it, I’m not certain about which folders the game creates when it installs as I did it so long ago and I might assume the wrong way.
If you have the Steam version of the game you should start it running now, if you don’t it will have to launch before the compile process will run and Unreal Frontend will crash when you try to cook.
Any code you want to compile will have to be in a folder under “My Documents\My Games\Unreal Tournament 3\UTGame\Src\” so browse to that location now. In this folder create a new folder called Mod_CompileTest and then within that folder create another folder called Classes.
You’ll need some code to actually compile so open Notepad and copy paste this into the program (the // can be blank lines, I’ve just put them there so the whole block displays properly on this page):
Your browser does not support iframes.
This code creates a mutator which will replace the number one entry in the default inventory (which is the Enforcer, the Impact Hammer is zero) with the Rocket Launcher.
The first line names our class and sets what it is extended from (this means that our class adds to anything that’s already in UTMutator.uc that we don’t override), the second line is a function which happens when this mutator is present in the mutators list for a match, the first line in the brackets (the first part of the function) sets DefaultInventory[1] to the Rocket Launcher and the second line in the brackets is a Super which tells the function to look up the extend chain (ie up to UTMutator, then up to whatever UTMutator is extended from and so on) for the InitMutator function and then do whatever is coded to happen there. This is necessary as if it was omitted only the InitMutator code from our class would run and we want to add to the function rather than replace it.
The last part is the defaultproperties section which is where any variables are normally defined, in this case we have a GroupName which means our mutator won’t be placeable in a list with another mutator that has the GroupName WEAPONRESPAWN so we avoid code clashes.
Now go to File, Save As. Change the Encoding drop down to Unicode (if you don’t do this you’ll get the ï error when you try to compile). In the File name box type Mut_CompileTesting.uc (make sure you get rid of the *.txt that’s already in the box). Now save the file in “My Documents\My Games\Unreal Tournament 3\UTGame\Src\ Mod_CompileTest\Classes” and close Notepad. At this stage you might want to associate Notepad (or another text editor) with .uc files for ease of use in the future.
Next you need to browse to “My Documents\My Games\Unreal Tournament 3\UTGame\Config” and use Notepad to open UTEditor.ini, again you might want to associate Notepad with .ini files. With the file open hold CTRL and press F to open the Find tool, type [Mo into the Find what box and click Find Next and you should be taken to the [ModPackages] section which will look like this:
Your browser does not support iframes.
You need to add a line to this section to tell Unreal Editor to check if your code needs compiling, so on a new line type ModPackages=Mod_ CompileTest (ie the name of the folder with our Classes folder in it) so the section now looks like this:
Your browser does not support iframes.
Now save and close Notepad. Be aware that any new mods you make will have to be added to this list and the compiler will recompile the list starting from the first changed entry, so if you have five entries in the list and you change something about the first one it’ll recompile all five.
If you don’t already have a shortcut to Unreal Editor you’ll need to create one so copy your normal UT3 game shortcut, then right click on the copy and select Properties. On the Shortcut tab click at the end of the Target box and type a space followed by editor, in my case the Target box would now read “C:\UT3\Binaries\UT3.exe editor”, and then click OK at the bottom of the Properties window. You’ll probably want to rename this shortcut to something like UT3 Editor. Your UT3 game shortcut might have “ at each end in which case you’d put the space followed by editor after the last “ which in my case would leave me with “C:\UT3\Binaries\UT3.exe” editor in the Target box.
Run your Unreal Editor shortcut and, possibly after a delay, a Message box will pop up and ask if you want to rebuild your scripts so click Yes. There’ll be another delay and a black window with white text called UT3 Editor will appear. It’ll run through the new code it’s found and compile it then say Success – 0 error(s), 0 warning(s) in green text when it has finished. You can then click the close button in the top right corner to close the window.
Browse to “My Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\Script” and you’ll see Mod_CompileTest.u, this is your compiled code in a package. You’ll only ever get one file per Src folder regardless of how many classes (.uc files) you have.
The game won’t normally read anything under the Unpublished folder tree so our .u file needs to go in the Published folder tree. The proper way to do this is by cooking the package, with a package so small and just for testing you could copy and paste to “My Documents\My Games\Unreal Tournament 3\UTGame\Published\CookedPC\Script” and then cook when you intend to release a file.
To cook a package that isn’t tied to a map you can use Unreal Frontend which is “C:\UT3\Binaries\UnrealFrontend.exe” for my install, you might want to create a shortcut to that and put it with your UT3 and Unreal Editor shortcuts. Run Unreal Frontend and check the Platform box is set to PC and the Game box is set to UTGame. Select the Cooking tab and enter Mod_CompileTest in the mislabelled Maps box, uncheck everything other than Packages have changed. If you’ve downloaded the PS3 cooking tools (from this page of the UDN) you’ll have a drop-down box called Mod Type which you should set to Mutator.
Your browser does not support iframes.
FriendlyName= is the text that will appear in the mutator list as the name of the mutator, so change that to something nicer like Compile Test Mutator. Description= is the text that will appear along the bottom of the screen when you highlight the mutator, so set that to something like This is a test mutator created as part of a tutorial.. Save and close Notepad.
Now start UT3 and select Instant Action, Deathmatch (you can use any game type as long as it doesn’t affect initial weapons like Betrayal for example), any map and then on the next screen select Mutators. Find whatever you set FriendlyName= to in the list and double click it to move it to the active mutators pane.
Great tut. Now to cook some food..
Arrrrrrrrr, have to read this one, ut is so different from all other games, and finding any good tutorials is a real pain, thanks dude, will infuse this one with the next coffe