| Home Page | Recent Changes | Preferences

Regen Mutator

This page is one of a series of UnrealScript Lessons.

Previous tutorials:

Now we're going to make a mutator that actually does something.

1  Make Your Own Package

While some editors don't require you to do this by hand, it's so easy it seems silly not to. To create your own package that the compiler will recognize, just create a new directory within the Base Directory, named the same as your package e.g. "MyPackage". In it, make a subdirectory called "Classes":

 +– {Base Directory}
        +- MyPackage
           +- Classes

Finally, open your UT2003.ini and find the list of "EditPackages". Add "EditPackages=MyPackage" to the list. The compiler will now attempt to compile your package with the rest.

Quicknote about the order of EditPackages - if you have one package dependant on the other, the dependant package must come after the other one. Notice how the first package in the list is "Core"

Now go to your command prompt, CD down to your {Base Directory}/System directory and type

 ucc make

Voila! You get ... an error! That's because your package is completely empty. Let's quickly fix that.

2  Subclassing

Go into the directory XGame/Classes and open the file "MutRegen.uc" with your editor of choice. Resave this file into your own package's class directory as "MutRegenPlus.uc." Take care not to directly edit any of the classes that came with the game. If you do, the package size will become invalid and you won't be able to play online and you might possibly break the game itself.

Your first step to making MutRegen your own is changing the classname to match what you saved the file as. So change:

//=============================================================================
// MutRegen - regenerates players
//=============================================================================
class MutRegen extends Mutator;

to:

//=============================================================================
// MutRegenPlus - regenerates players plus!
//=============================================================================
class MutRegenPlus extends Mutator;

3  Writing the script

You should also go ahead and change the default properties from:

GroupName="Regen"
FriendlyName="Regeneration"
Description="All players regenerate health."

to:

GroupName="Regen"
Friendlyname="Regeneration Plus"
Description="All players regenerate health to superhealth limits."

Now what fun is modding if you don't modify anything? Take the line down below that says:

    if (C.Pawn != None && C.Pawn.Health < C.Pawn.HealthMax )
        {
            C.Pawn.Health = Min( C.Pawn.Health+RegenPerSecond, C.Pawn.HealthMax );
        }

And change it to:

        if (C.Pawn != None && C.Pawn.Health < C.Pawn.HealthMax*2 )
        {
            C.Pawn.Health = Min( C.Pawn.Health+RegenPerSecond, C.Pawn.HealthMax*2 );
        }

You just altered the second variable of the Min function, which is essentially the cap that can be returned.

Save your file and prepare for compiling.

4  Compiling Your Script

Before you can compile you will need to make some changes to your UT2003.ini file that's in your UT2003/System directory. Open the UT2003.ini file and locate the list of of "EditPackages" under [Editor.EditorEngine]. Add your package to the end of that list (e.g. "EditPackages=MyPackage").

Quicknote about the order of EditPackages - if you have one package dependant on the other, the dependant package must come after the other one. Notice how the first package in the list is "Core."

Open up a command prompt, CD to your UT2003/System directory, and type "ucc make" (see Compiling With UCC). You should get something that looks like this:

-------------------------MyPackage - Release--------------------------
Analyzing...
Parsing MutRegenPlus
Compiling MutRegenPlus
Importing Defaults for MutRegenPlus
Success - 0 error(s), 0 warning(s)

D:\UT2003\System>

Quick note on compiling - if you don't see the above, make sure the UT2003.ini file hasn't been rewritten again without your EditPackages line it from a previous attempt at compiling. If it has, make sure to close out of any programs which might have opened it after putting it back in and recompiling. (This can happen if you have UnrealED or UT2003 open while you edit the .ini file. As soon as you quit either, they will overwrite your .ini with whatever was current when they were launched.)

There should now be a .u file with your package name on it in the UT2003/System directory. But, before you can see your new codework in the game, there is another step you need to do. The code is there, but you have to tell the game to see it. To do this, you'll need to make an INT file named after your package in the System directory. This is a file which will describe to the engine the most basic parts of your package. For now, just copy:

[Public]
Object=(Class=Class,MetaClass=Engine.Mutator,Name=MyPackage.MutRegenPlus,Description="Regeneration Plus")

And save it into your package's .int file (e.g. MyPackage.int). If you make any other changes to your .uc script file, recompile your code.

5  Fire it Up

Go ahead and start up UT2003. Go into Instant Action. Select "Regeneration Plus" into your mutator list, and watch as you regenerate to 200 health.

This tutorial was originally part of RegularX's UTutes series.

Related Topics

Comments

CH3Z:This tutorial is too game-specific. I want to mod for UT and don't have UT2003. We need a more compatible example here.

RegularX: I think it's hazardous to assume that a cross-app example is really productive, UT and UT2003 mutators are similar in theory, but really pretty different in practice. For example, most mutes in UT2003 will eventually talk to the Controller class in some way, which doesn't even exist in UT. There might be a need for a lower level "Intro to Mutators" page that doesn't really go into app specific code, but when it comes down to the "this is how you write it" level, it's gonna have to be one game or another.

CH3Z: how bout both then?

RegularX: Both would make sense, and maybe we should adopt specific ways of telling between them, like some sites do to detail scripts which only work with certain browsers.

RDGDanClark: Both is the way to go, but how about simply putting either (UT) or (UT2003) in the page titles like we do with some other pages?

Foxpaw: A lot of Unrealscript is compatible between the two. How about instead of using the controller and referencing it's pawn, we just walk the pawnlist every tick/every second/whatever you like? That should work in both UT and UT2003.

A UT Example

Yeah, the images are already made and with the next edit of the wiki code, I believe Mychaeel will be implementing syntax to add logos like the one above just like the smileys. This should work great for the indicators. see Wiki Development for other logos and the plan for implementation (Note also that the image shows up in Quick Navigation).


Category Tutorial

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In