The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall
Legacy:TheHealer/TUTHealerAmmo
Contents
TUTHealerAmmo - The Healer Part 3 of 9[edit]
In this part of the Healer tutorial, we will set up our ammo class – what defines the ammunition for our Healer. Before we get into the code, make sure that your file is set up correctly.
Filename: {Base Directory}/TheHealer/classes/TUTHealerAmmo.uc
If you've changed the name of the package folder or the filename itself, make sure you make those changes throughout the code we'll be working with.
Quick Link: This is the complete source code for people who want to skip ahead. If you want to copy/paste into your file, this is the page to do it on.
Here's something that you should remember, as it may come up on the SAT's or something:
Weapon is to WeaponPickup as Ammo is to AmmoPickup.
This is to say, Ammo (like Weapon), is not what you see in the game.
Heading and Class Declaration[edit]
In order to keep our code reader-friendly (always a good thing if you need someone's help!), we will add a standard comment block to the top of the file. This will describe what's going on in the file.
After the comment block, we declare the class. Make sure you name the class with the same name as the filename, or bad things happen.
//------------------------------------------------------------------------------ // class name : TUTHealerAmmo // class type : Ammunition // description: The Healer's ammunition properties // author : HSDanClark //------------------------------------------------------------------------------ // TODO : // //------------------------------------------------------------------------------ class TUTHealerAmmo extends Ammunition;
- Our pickup extends (or is a child of, so-to-speak) the Ammunition class.
Exec Directives and Variable Declarations[edit]
#EXEC OBJ LOAD FILE=InterfaceContent.utx
Here we load our texture package via an EXEC directive. This texture package contains the icon for the ammunition. We don't need any variables, since we have no functions.
Functions[edit]
None.
Default Properties[edit]
defaultproperties { ItemName="Tutorial Healer Ammo" IconMaterial=Material'InterfaceContent.Hud.SkinA' IconCoords=(X1=545,Y1=150,X2=644,Y2=224) PickupClass=class'TUTHealerAmmoPickup' // This links the ammo to the pickup // that you need to place in the game. MaxAmmo=120 // The maximum Healer ammo you can carry InitialAmount=40 // The amount of ammo you get when you // first pick up the Healer }
Check out the comments in the script for details. Notice that we don't define how much each ammo pack is worth when you pick it up! That amount is defined in the ammo's pickup class, which we will see next.
The Next Step[edit]
Continue to Part 4, TheHealer/TUTHealerAmmoPickup
The complete tutorial map:
- Legacy:TheHealer/TUTHealer – Our main weapon class.
- Filename: {Base Directory}/TheHealer/classes/TUTHealer.uc
- Legacy:TheHealer/TUTHealerPickup – Our weapon's pickup class, what you see on the ground.
- Filename: {Base Directory}/TheHealer/classes/TUTHealerPickup.uc
- Legacy:TheHealer/TUTHealerAmmo – Our weapon's ammo class.
- Filename: {Base Directory}/TheHealer/classes/TUTHealerAmmo.uc
- Legacy:TheHealer/TUTHealerAmmoPickup – The ammo's pickup class, what you see on the ground.
- Filename: {Base Directory}/TheHealer/classes/TUTHealerAmmoPickup.uc
- Legacy:TheHealer/TUTHealerFire – Our weapon's primary fire class.
- Filename: {Base Directory}/TheHealer/classes/TUTHealerFire.uc
- Legacy:TheHealer/TUTHealerAltFire – Our weapon's alternate (secondary) fire class.
- Filename: {Base Directory}/TheHealer/classes/TUTHealerAltFire.uc
- Legacy:TheHealer/TUTHealerBeamEffect – The Healer's Beam Effect
- Filename: {Base Directory}/TheHealer/classes/TUTHealerBeamEffect.uc
- Legacy:TheHealer/TUTHealerAttachment – Our weapon's attachment class.
- Filename: {Base Directory}/TheHealer/classes/TUTHealerAttachment.uc
- Legacy:TheHealer/TUT The End – Putting it all together.