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

Engine.Pickup


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
00127
00128
00129
00130
00131
00132
00133
//=============================================================================
// Pickup items.
//=============================================================================
class Pickup expands Inventory
    abstract;

var inventory Inv;
var travel int NumCopies;
var() bool bCanHaveMultipleCopies;  // if player can possess more than one of this
var() bool bCanActivate;            // Item can be selected and activated
var() localized String[64] ExpireMessage; // Messages shown when pickup charge runs out
var() bool bAutoActivate;

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

function TravelPostAccept()
{
    Super.TravelPostAccept();
    PickupFunction(Pawn(Owner));
}

//
// Advanced function which lets existing items in a pawn's inventory
// prevent the pawn from picking something up. Return true to abort pickup
// or if item handles the pickup
function bool HandlePickupQuery( inventory Item )
{
    if (item.class == class) 
    {
        if (bCanHaveMultipleCopies) 
        {   // for items like Artifact
            NumCopies++;
            Pawn(Owner).ClientMessage(PickupMessage, 'Pickup');             
            Item.PlaySound (Item.PickupSound,,2.0);
            Item.SetRespawn();
        }
        else if ( bDisplayableInv ) 
        {       
            if ( Charge<Item.Charge )   
                Charge= Item.Charge;
            Pawn(Owner).ClientMessage(PickupMessage, 'Pickup');                     
            Item.PlaySound (PickupSound,,2.0);
            Item.SetReSpawn();
        }
        return true;                
    }
    if ( Inventory == None )
        return false;

    return Inventory.HandlePickupQuery(Item);
}

function float UseCharge(float Amount);

function inventory SpawnCopy( pawn Other )
{
    local inventory Copy;

    Copy = Super.SpawnCopy(Other);
    Copy.Charge = Charge;
    return Copy;
}

auto state Pickup
{   
    function Touch( actor Other )
    {
        local Inventory Copy;
        if ( ValidTouch(Other) ) 
        {
            Copy = SpawnCopy(Pawn(Other));
            if (bActivatable && Pawn(Other).SelectedItem==None) 
                Pawn(Other).SelectedItem=Copy;
            if (bActivatable && bAutoActivate && Pawn(Other).bAutoActivate) Copy.Activate();
            Pawn(Other).ClientMessage(PickupMessage, 'Pickup'); // add to inventory and run pickupfunction	
            PlaySound (PickupSound,,2.0);   
            Pickup(Copy).PickupFunction(Pawn(Other));
        }
    }

    function BeginState()
    {
        Super.BeginState();
        NumCopies = 0;
    }
}

function PickupFunction(Pawn Other)
{
}

//
// This is called when a usable inventory item has used up it's charge.
//
function UsedUp()
{
    if ( Pawn(Owner) != None )
    {
        bActivatable = false;
        Pawn(Owner).NextItem();
        if (Pawn(Owner).SelectedItem == Self) {
            Pawn(Owner).NextItem(); 
            if (Pawn(Owner).SelectedItem == Self) Pawn(Owner).SelectedItem=None;
        }
        Pawn(Owner).ClientMessage(ExpireMessage);   
    }
    Owner.PlaySound(DeactivateSound);
    Destroy();
}


state Activated
{
    function Activate()
    {
        if ( (Pawn(Owner) != None) && Pawn(Owner).bAutoActivate 
            && bAutoActivate && (Charge>0) )
                return;

        Super.Activate();   
    }
}

defaultproperties
{
     bRotatingPickup=False
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Sun 21/2/2010 23:48:40.000 - Creation time: Sun 21/2/2010 23:49:52.959 - Created with UnCodeX