| Home Page | Recent Changes | Preferences

# Stat Points System/Ammo Pickup Modifier

This is a continuing part of a stat point system tutorial. For this tutorial will will be changing the MinigunAmmoPickup file to increase the amount of ammo every time you get an ammo pickup for the minigun.

First we must add the appropriate variable:

    variable() float StatPoints

Now we must add this code:

    simulated function PostBeginPlay()
    {
        Super.PostBeginPlay();
        ModeTick(var dt)
        {
            if (StatPoints > 0)
                 AmmoAmount = (StatPoints / 5) + AmmoAmount;
            else
                 AmmoAmount = 50;
        }
    }

This says the variable AmmoAmount, if StatPoints is over 0, is equal to the StatPoints divided by 5 + the old ammo amount. If the statpoints are 0, then the ammo amount for the pickup is 50.

Here is the final code:

    class MinigunAmmoPickup extends UTAmmoPickup;

    var() float StatPoints

    simulated function PostBeginPlay()
    {
        Super.PostBeginPlay();
        ModeTick(var dt)
        {
            if (StatPoints > 0)
                 AmmoAmount = (StatPoints / 5) + AmmoAmount;
            else
                 AmmoAmount = 50;
        }
    }

    defaultproperties
    {
         AmmoAmount=50 //Amount of ammo you get
         InventoryType=Class'XWeapons.MinigunAmmo'
         PickupMessage="You picked up (var AmmoAmount) bullets." //The message you get when picking up the bullets
         PickupSound=Sound'PickupSounds.MinigunAmmoPickup'
         PickupForce="MinigunAmmoPickup"
         DrawType=DT_StaticMesh
         StaticMesh=StaticMesh'WeaponStaticMesh.MinigunAmmoPickup'
         CollisionHeight=12.750000
    }

As always any corrections or comments are appreciated

## Comments

## Related Topics

Stat Points System/Damage Modifier: Your next recommended step

UnrealScript Lessons

Category Class (UT2003)

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