Homework #1

Weapons MOD


Description

For this assignment, you will be required to make a new type of weapon with a very specialized way of doing damage. 

You are to make a new type of weapon based on the ShockRifle.  The ShockRifle is your typical laser beam weapon.  Pressing fire when holding the ShockRifle produces a beam that shoots out of the gun.  Pressing "Alt fire" causes a ball of energy to launch from the gun that explodes on impact, causing damage to anyone within a certain radius.

You are to create a new type of ShockRifle called DiscriminatingShockRifle , which shoots a regular laser for the normal fire mode and a ball of energy or the "alt fire" mode, as expected.  Except, the ball of energy is fired using the "alt fire", it only does damage to Bots (e.g. characters in the game that are not controlled by human users).

Feel free to make any other creative modifications to the weapon, as long as it meets the requirements above.  For example, you can change what the ball of energy looks like, how much damage it does, how much momentum the weapon transfers to its victims when it explodes, etc.  Make sure that any additional changes are well documented.  You will not receive extra credit for any additional modifications, but creativity is encouraged.


Classes you should be aware of

Inventory

An Inventory is something that a Pawn can hold.  Inventory objects are usually picked up during game play when the player touches a Pickup object.  Weapons are types of Inventory.

PickupClass
A class descriptor referring to the type of Pickup that can spawn an inventory object.  You will probably want to change this in your DiscriminatingShockRifle so that it refers to class'DiscriminatingShockRiflePickup'.

Weapon

The Weapon class is the base class for all weapons, including the ShockRifle class.

simulated event ClientStartFire (int mode)
This function is called by the underlying game engine every time the user presses the fire or alt-fire button.  mode is an indicator of whether the regular fire or alternate fire mode should be used.  This function can be overridden if the weapon is to perform any special behavior when it is fired.
function bool BotFire (bool bFinished, optional name FiringMode)
This function is called when a Bot fires the weapon.  It does not use the same function as when a human player fires the weapon.
Instigator
Reference to a Pawn object that is using the weapon.
Owner
Reference to the Pawn object that is currently holding the weapon.
FireMode
An array of objects of type WeaponFire. A WeaponFire is an object that describes what happens when the weapon is fired.  Objects in this array are spawned dynamically by the weapon at runtime, based on the corresponding class descriptor in FireModeClass.
FireModeClass
An array of class descriptors that specify what type of object each FireMode is.  The array contains two elements, one for each firing mode and can be a different class.  This array must be changed in order for different weapon types to have different firing effects.  Each class descriptor must list a type of class that subclasses from WeaponFire.

ShockRifle

A specific type of weapon that shoots a beam for its regular firing mode and a ball of energy for its alternative firing mode.

WeaponFire

A WeaponFire is an object that describes the behavior of how a weapon fires.  For example, whether the weapon is a beam weapon (InstantFire) or a projectile weapon (ProjectileFire).  This class also specifies how to animate the weapon when it is fired.

DamageAtten
Floating point value that multiplies the amount of damage the firing mode will cause.
FireRate
Floating point that specifies how often the weapon can be fired in this mode.
Instigator
Reference to the Pawn object that fired the weapon.
function DoFireEffect ()
This function is called when the weapon is fired in this particular mode.

ProjectileFire

A specific type of WeaponFire in which a projectile is launched.

function projectile SpawnProjectile (Vector start, Rotator dir)
This function creates the actual projectile which is launched by this fire mode.  start specifies the location in absolute level coordinates of the place to spawn the projectile (typically just off the tip of the weapon itself).  dir specifies the orientation of the projectile and the direction it will travel.  The projectile spawned is of the ProjectileClass type.

ShockProjFire

A specific type of ProjectileFire describing how to shoot a ball of energy and how to animate the weapon when the ball of energy is fired.

Projectile

A base class for all projectiles that are shot out of projectile weapons.

Damage
Floating point value specifying the amount of damage to be applied to a victim (if it is a direct hit).
DamageRadius
Floating point value specifying how far from the exploding projectile a victim must be to incur damage.
MomentumTransfer
Floating point value specifying how much momentum is transfered to a victim (if it is a direct hit).  This is the "force" of the explosion.
Instigator
Reference to the Pawn object that is causing the damage.
simulated function ProcessTouch (Actor other, Vector hitLocation)
This function is called when the projectile touches something other than a wall.  other is a reference to the thing touched.  hitLocation is the place where the touch occured in absolute level coordinates.
simulated function Explode (Vector hitLocation, Vector hitNormal)
This function describes what happens when the projectile explodes.  Probably because it hit something.  hitLocation is the place the explosion occurs, in absolute level coordinates.
simulated function BlowUp (Vector hitLocation)
This function describes what happens when the projectile explodes for some reason other than impact.  hitLocation is the place the explosion occurs, in absolute level coordinates.
simulated final function HurtRadius (float damageAmount, float damageRadius, class<DamageType> damageType, float momentum, Vector hitLocation)
This function describes how to hand out damage to all actors in the explosion radius.  damageAmount is the maximum amount of damage to do.  damageRadius is the radius of affected objects.  momentum is the maximum amount of force the explosion has on an object. hitLocation is the place where the explosion occurs in absolute level coordinates.

ShockProjectile

The energy ball projectile.


Files that you will need

In order to complete your project you will need the following files:


Setting up your homework project

If this is the first time you are developing UT2004, you must gain access to all the class files in the UnrealScript class library.

  1. Open Unreal2004 Level Editor
  2. In the textures dialog (opens automatically when the editor is run), click on the "Actor Classes" tab.
  3. In the dialog, pull down the "File" menu and select "Export All Scripts".  This will export all the packages and the class files within to the UT2004 directory.

If you are using the WOTgreal editor for the first time.

  1. Open WOTGreal.  If this is the first time you have used WOTGreal, you should be presented with a Preferences dialog.  If not, select "Options" -> "Preferences".
  2. Enter the game information so that it looks like the following:

You must create a new package in the UT2004 class library.  All the new classes you write should be part of this package.  The name of your package should be "Hw1".

  1. Create a new directory, UT2004\Hw1\Classes.  All your class files should go in this directory.
  2. Open WOTGreal and select "ut2004" -> "Refresh Package/Class Tree" menu option.
  3. Edit UT2004\System\UT2004.ini and add "EditPackages=Hw1" to the appropriate section of the file.

Testing your project

To test your project, run UT2004 and start a Death Match game (you can use a multiplayer option or "instant action") using the DM-hw1 map.  The map should already contain a weapon pickup for a DiscriminatingShockRifle.

Pickup the weapon and practice shooting at Bots and at other players (including yourself).  You should be able to damage and kill Bots but not be able to hurt yourself or any other players that enter your game.  You can set the number of Bots in the level before starting the level.  I suggest keeping this number to 1 or 0.  Make sure you test your weapon on at least one other player that enters the game in multiplayer mode.


What you must turn in

To get credit for your work, you must submit a single UMod file.

The UMod file should contain your modified weapon class, written in DiscriminatingShockRifle.uc -- containing a subclass of ShockRifle -- as well as any additional class files that you created to complete your work.  You should not have modified any class file that is part of the original UT2004 distribution.

Most importantly, your UMod should contain your succesfully compiled package bytecode, hw1.u which should be unpacked into UT2004\System when the UMod is installed.

You should also write a readme.txt which describes exactly how your homework project works.  For example, what does your modified weapon do, exactly.  What special things do you have to do in the game to use your modified weapon correctly.  The readme.txt should be in your UT2004/Hw1 directory (not UT2004/Hw1/Classes).  Make sure that this file is included in your UMod.

Your UMod should not contain any map files!  Nor should it contain DiscriminatingShockRiflePickup.uc.

How to create a UMod for homework submission

Create a textfile called hw1mod.ini that looks something like this:

[Setup] Product=Hw1 Version=100 Archive=hw1-moriedl.umod SrcPath=. MasterPath=.. Group=SetupGroup Group=FilesGroup Group=SystemGroup Group=umodIncludeFilesGroup [SetupGroup] Copy=(Src=System\Manifest.*,Flags=3) [FilesGroup] File=(Src="Hw1\Classes\DiscriminatingShockRifle.uc") [SystemGroup] File=(Src="System\Hw1.u") [umodIncludeFilesGroup] File=(Src="Hw1\readme.txt")

Next create a textfile called hw1mod.int that looks something like this:

[Setup] LocalProduct=Hw1 Readme=Hw1\readme.txt SetupWindowTitle=Hw1 Setup AutoplayWindowTitle=Hw1 Options ProductURL=whatever VersionURL=whatever Developer=Mark Riedl DeveloperURL=whatever

Put these files in your UT2004/System directory. Then from the commandline run "ucc master hw1mod".

Or use UMod Wizard.

If your umod does not extract on the computer I use for grading, no credit will be given.