Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Engine.Ammunition


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
//=============================================================================
// Ammunition: the base class of weapon ammunition
//
// This is a built-in Unreal class and it shouldn't be modified.
//=============================================================================

class Ammunition extends Inventory
    abstract
    native
    nativereplication;

var travel int MaxAmmo;                     // Max amount of ammo
var travel int AmmoAmount;
var int InitialAmount; // sjs					// Amount of Ammo current available
var travel int PickupAmmo;                  // Amount of Ammo to give when this is picked up for the first time	

// Used by Bot AI

var     bool    bRecommendSplashDamage;
var     bool    bTossed;
var     bool    bTrySplash;
var     bool    bLeadTarget;
var     bool    bInstantHit;
var     bool    bSplashDamage;  
var     bool    bTryHeadShot; 


// Damage and Projectile information

var class<Projectile> ProjectileClass;
var class<DamageType> MyDamageType;
var float WarnTargetPct;
var float RefireRate;

var Sound FireSound;

var float MaxRange; // for autoaim
var() Material IconFlashMaterial;

// Network replication
//

replication
{
    // Things the server should send to the client.
    reliable if( bNetOwner && bNetDirty && (Role==ROLE_Authority) )
        AmmoAmount;
}

simulated function CheckOutOfAmmo()
{
    if (AmmoAmount <= 0)
        Pawn(Owner).Weapon.OutOfAmmo();
}

simulated function bool UseAmmo(int AmountNeeded, optional bool bAmountNeededIsMax)
{
    if (bAmountNeededIsMax && AmmoAmount < AmountNeeded)
        AmountNeeded = AmmoAmount;
        
    if (AmmoAmount < AmountNeeded)
    {
        CheckOutOfAmmo();
        return false;   // Can't do it
    }
    
    AmmoAmount -= AmountNeeded;
    NetUpdateTime = Level.TimeSeconds - 1;
    
    if (Level.NetMode == NM_StandAlone || Level.NetMode == NM_ListenServer)
        CheckOutOfAmmo();
    
    return true;
}

simulated function bool HasAmmo()
{
    return ( AmmoAmount > 0 );
}

simulated function DisplayDebug(Canvas Canvas, out float YL, out float YPos)
{
    Canvas.DrawText("Ammunition "$GetItemName(string(self))$" amount "$AmmoAmount$" Max "$MaxAmmo);
    YPos += YL;
    Canvas.SetPos(4,YPos);
}
    
function bool HandlePickupQuery( pickup Item )
{
    if ( class == item.InventoryType ) 
    {
        if (AmmoAmount==MaxAmmo) 
            return true;
        item.AnnouncePickup(Pawn(Owner));
        AddAmmo(Ammo(item).AmmoAmount);
        item.SetRespawn(); 
        return true;                
    }
    if ( Inventory == None )
        return false;

    return Inventory.HandlePickupQuery(Item);
}

// If we can, add ammo and return true.  
// If we are at max ammo, return false
//
function bool AddAmmo(int AmmoToAdd)
{
    if ( Level.GRI.WeaponBerserk > 1.0 )
        AmmoAmount = MaxAmmo;
    else if ( AmmoAmount < MaxAmmo )
        AmmoAmount = Min(MaxAmmo, AmmoAmount+AmmoToAdd);
    NetUpdateTime = Level.TimeSeconds - 1;
    return true;
}

defaultproperties
{
     InitialAmount=10
     MyDamageType=Class'Engine.DamageType'
     WarnTargetPct=0.500000
     RefireRate=0.500000
     NetUpdateFrequency=1.000000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 23/10/2006 20:25:18.000 - Creation time: Wed 7/2/2007 19:16:33.359 - Created with UnCodeX