I'm a doctor, not a mechanic

Legacy:Stat Points System/Ammo Pickup Modifier

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

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

Vindexus:Does this work in UT2003/4? I think I got a mutator that used AmmoAmount+=1 or something and it didnt' work with UT2004

Comments

Related Topics

Stat Points System/Damage Modifier: Your next recommended step

UnrealScript Lessons