Setting Up UnrealScript
This page is one of a series of UnrealScript Lessons.
To create a mutator or mod for Unreal Tournament 2004, all you need is a copy of the game and the tools it comes with. Of course, it doesn't all come pre-assembled. You will have to do this. You also might want to make sure you have the latest patches to the game before setting up here.
1 Get the Source Code
Out of the box, UnrealScript classes are compiled in .u files. These contain the source as well as the compiled bytecode. You can see the source within UnrealEd, but we want to get it into standalone plaintext UC files. You have two choices here:
- [recommended] You can go to UnrealScript Source and download the original sources from there. Extract this into your UT2004 folder and voila – you have the source code.
- Or, you can go into UnrealEd 3, bring up the Script Editor and export the scripts from there. To do this, do UnrealEd Main Menu → View → Show Script Editor and then in the editor do File → Export all scripts. Note that we don't recommend this method: nine times out of ten, UnrealEd will then crash (unless that bug has been fixed), and UnrealED still does not export all of the default properties properly. This is most notable in the GUI2K4 package, within the styles subclassed classes.
If you look at your UT2004 directory now, there should be a whole heap of new folders. Inside each of these folders will be a subfolder "Classes", containing a bunch of UC files. .uc is the file extension of uncompiled UnrealScript sources while .u is the extension of compiled code.
The folders all represent packages. A package in object-oriented design is pretty much just the grouping of specific types of files. UT2004 has a lot more organization to it than UT did, more fully separating out weapon classes from effect classes and so on.
2 Choose a scripting environment
Even though there is only one compiler for UnrealScript, Ucc, there are many different ways in which to write your code and compile it. Some are downright bats, but in most cases it's horses for courses.
You may notice that further tutorials assume different methods of scripting and compiling. This is basically due to the tutorial writer's personal preference. If you can rewrite it to be a little bit more general, please do!
UnrealEd
First of all you could use UnrealEd for coding. But you probably don't want to. It's great for making levels, but really inferior for coding. It's fine for coding a one-off class like a Trigger to embed in a map, but for modding, there are far better ways.
Using UEd to code is like using a fork to eat soup: It's somehow possible, but not really worth the trouble.
Text editor + UCC + UnCodeX
The original way was to write your code in a normal text editor, and compile with the external compiler. Compiling With UCC elaborates on that. See below for a more convenient way.
Short list of text editors:
- Notepad – yuck, although the XP version of Notepad is bearable – Ctrl-G (goto line number) and Ctrl-F (text search) are your friends.
- TextPad – nice, supports UnrealScript syntax highlighting
- ConTEXT – another nice text editor with syntax highlighting
- UltraEdit – even better, as it has a function browser window (good for large classes)
- jEdit – powerful Java-based code editor; heaps of plugins, built-in UnrealScript syntax highlighting (4.2+)
- [Notepad++] – simple Windows notepad replacement using the Scintilla engine. Get the UnrealScript syntax highlighting file from the [downloads page] in the "User Defined Language files" section.
In any case you will want to use UnCodeX to browse the source files.
Text editor + UMake + UnCodeX
A simple stand-alone way to compile UnrealScript projects is UMake. It provides similar features as integrated development environments, but assumes that you use your own (favorite) text editor to create and edit your sources.
Again, UnCodeX will help you find your way through the code jungle.
Integrated Development Environment
All good editors. All have nice graphical user interfaces for editing and compiling. More on IDE.
Related Topics
- UnrealScript Hello World – your recommended next step
- UnrealScript Lessons – all the UnrealScript tutorials
- UnrealScript – all the reference pages
- Mutator Topics – more on mutators
- Making Mods – more on the organizational and social aspects
- Application – list of useful software
- Compiling With UCC – How to use UCC
Comments
Some things that could have been mentioned in this tutorial:
- basic syntax features: functions, variables, conditional execution of code & loops, special keywords like None, Self, etc.
- lack of an "entry point". Simple classes like Mutator maybe?
- inheritance, link to Object Oriented Programming Overview
Tarquin: This page is meant to be the basics, so the mutator batch files stuff needs to be moved.
Solid Snake:You may now want to also dump INT files since automatic generations is nice. Using ucc dumpint MyPackage.U is the way to go. It appears that the v3236 of UT2004 automatically calls the exportcache command when you compile. Also you can compile using the mod hash if you have your own mod directory...
OlympusMons:Ive added a link to compiling with ucc.
King Mango Exporting all scripts via UED didn't crash for me, but it made a complete mess out of my UT2004 install. Unless I'm completely wrong, I just downloaded the source zip and extracted to a practice DIR in My Documents. Anything I want to test or compile I will then just create new folders individually. Tarq fix the text wrap on the edit panel!
El Muerte: Well, if you use WOTgreal you will need to have the script files in the engine's base dir, otherwise the cool features don't work and you might as well use a normal text editor. UnCodeX is a bit more relaxed on this, since you can define multiple directories to scan. Before using WotGreal I used the later approach.
DarthDevilous: Is there a way to upload and link to XML files? Just I made a style definition file for [Notepad++] and have no way of hosting it myself.
Tarquin: I can upload it. But won't the program's site host it? It would reach more people that way.
Tabu: Just wanted to add, that Crimson editor (http://www.crimsoneditor.com/) is a briliant texteditor, the best I have used to date. It has a unreal script syntax file, that needs to be downloaded from the page seperatly and added!