Project: Sample Unreal Tournament Mutator


Background

Unreal and Unreal Tournament are very extensible games. The core of this extensibility is the UnrealScript language. Following is what I needed to do to create a simple mutator "Boom".

UnrealScript source files have a .uc extension. They are simple text files that contain unreal script commands. UnrealScript looks alot like C++/Java. Good resources for script development can be found on Epic's Unreal Technology page. In particular look at:

Preparing for UnrealScript development

First you need to have Unreal Tournament and UnrealEd installed. Fire up UnrealED.


This will dump all of Unreal Tournament's classes into the directory where Unreal Tournament is installed. You only need to do this once*. I strongly encourage you to browse the scripts in these directories. They're very instructional.

*Actually it's a good idea to do this each time you patch Unreal Tournament to pick up the latest fixes.

Develop "Boom"

Boom is inspired by "Boom Death", a mutator that I found on the web but I could not get to install. Whenever a person or bot dies set of a redeemer round at their location. It seemed simple enough so I took a crack at writing it myself.

There are several steps to creating a mutator:

  • Prepare a directory
  • Create the script (.uc file)
  • Create the interface file (.int file)
  • Register the script with Unreal Tournament
  • Build the scripts
  • Test the script
  • Prepare a directory

    Off your Unreal Tournament directory create a directory "MyPackages" and "MyPackages\Classes".

    Create the script (.uc file)

    In MyPackages\Classes create a file named Boom.uc. In it put the following:

    class Boom expands Mutator;
    
    var bool Initialized;
    
    function PostBeginPlay()
    {
      //
      //  Install only once
      // 
      if (Initialized)
        return;
      Initialized = True;
    
      Level.Game.RegisterDamageMutator( Self );
    }
    
    function MutatorTakeDamage(
      out int    ActualDamage, 
      Pawn       Victim, 
      Pawn       InstigatedBy, 
      out Vector HitLocation,
      out Vector Momentum, 
      name       DamageType
      )
    {
      local Shockwave explosion;
    
      if (Victim.IsA('Bot') || Victim.IsA('PlayerPawn'))
      {
        if (Victim.Health <= ActualDamage)
        {
          explosion = Spawn(class 'Shockwave',,,Victim.Location);
          explosion.Instigator = Victim;
        }
      }
    
      //
      //  Pass on the event to the next handler
      // 
      if ( NextDamageMutator != None )
        NextDamageMutator.MutatorTakeDamage( ActualDamage, Victim, InstigatedBy, HitLocation, Momentum, DamageType );
    }
        

    Create the interface file (.int file)

    In the System directory create a file called MyPackages.int. In it put the following:
    [Public]
    Object=(Name=MyPackages.Boom,Class=Class,MetaClass=Engine.Mutator,Description="When person dies they explode.")
    
    

    Register the script with Unreal Tournament

    Edit System/unrealtournament.ini. Find the selection with lines like EditPackages=. At the end of the section add the line:

    EditPackages=MyPackages
    

    Build the scripts

    Create a DOS (Command) Window. cd to your Unreal Tournament System directory. Type:

    ucc make and you should see something like:
    C:\Games\Unreal\UnrealTournament\System>ucc make
    --------------------Core--------------------
    --------------------Engine--------------------
    --------------------Editor--------------------
    --------------------UWindow--------------------
    --------------------Fire--------------------
    --------------------IpDrv--------------------
    --------------------UWeb--------------------
    --------------------UBrowser--------------------
    --------------------UnrealShare--------------------
    --------------------UnrealI--------------------
    --------------------UMenu--------------------
    --------------------IpServer--------------------
    --------------------Botpack--------------------
    --------------------UTServerAdmin--------------------
    --------------------UTMenu--------------------
    --------------------UTBrowser--------------------
    --------------------MyPackages--------------------
    Analyzing...
    Parsing Boom
    Compiling Boom
    Success - 0 error(s), 0 warnings
    

    Test the script

    Fire up Unreal Tournament. Pick a practice session, a map, the mutator "When person dies they explode.", several bots, and press "Start". Kill someone and watch them go boom:

    For more development info look at: Sample Unreal Tournament Mutator, Part Two