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
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
//=============================================================================
// Pickup items.
//=============================================================================
class Pickup extends 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 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++;
            if (Level.Game.LocalLog != None)
                Level.Game.LocalLog.LogPickup(Item, Pawn(Owner));
            if (Level.Game.WorldLog != None)
                Level.Game.WorldLog.LogPickup(Item, Pawn(Owner));
            if ( Item.PickupMessageClass == None )
                // DEUS_EX CNN - use the itemArticle and itemName
//				Pawn(Owner).ClientMessage(item.PickupMessage, 'Pickup');
                Pawn(Owner).ClientMessage(item.PickupMessage @ item.itemArticle @ item.itemName, 'Pickup');
            else
                Pawn(Owner).ReceiveLocalizedMessage( item.PickupMessageClass, 0, None, None, item.Class );
            Item.PlaySound (Item.PickupSound,,2.0);
            Item.SetRespawn();
        }
        /* DEUS_EX AJY
        else if ( bDisplayableInv ) 
        {       
            if ( Charge<Item.Charge )   
                Charge= Item.Charge;
            if (Level.Game.LocalLog != None)
                Level.Game.LocalLog.LogPickup(Item, Pawn(Owner));
            if (Level.Game.WorldLog != None)
                Level.Game.WorldLog.LogPickup(Item, Pawn(Owner));
            if ( Item.PickupMessageClass == None )
                Pawn(Owner).ClientMessage(item.PickupMessage, 'Pickup');
            else
                Pawn(Owner).ReceiveLocalizedMessage( item.PickupMessageClass, 0, None, None, item.Class );
            Item.PlaySound (item.PickupSound,,2.0);
            Item.SetReSpawn();
        }
        */
        else if ( bDisplayableInv ) 
            return false;

        return true;                
    }
    if ( Inventory == None )
        return false;

    return Inventory.HandlePickupQuery(Item);
}

function SetRespawn()
{
    if( Level.Game.ShouldRespawn(self) )
    {
        GotoState('Sleeping');
    }
    else
    {
        //because of latent destroy, we just need to make sure num copies is 0 and then 
        //you at least won't be able to doublefrob.
        NumCopies = 0;
        Destroy();
    }
}

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
{   
    // changed from Touch to Frob - DEUS_EX CNN
    function Frob(Actor Other, Inventory frobWith)
//	function Touch( actor Other )
    {
        local Inventory Copy;
        if ( ValidTouch(Other) ) 
        {
            Copy = SpawnCopy(Pawn(Other));
            if (Level.Game.LocalLog != None)
                Level.Game.LocalLog.LogPickup(Self, Pawn(Other));
            if (Level.Game.WorldLog != None)
                Level.Game.WorldLog.LogPickup(Self, Pawn(Other));
//			if (bActivatable && Pawn(Other).SelectedItem==None) 
//				Pawn(Other).SelectedItem=Copy;
            if (bActivatable && bAutoActivate && Pawn(Other).bAutoActivate) Copy.Activate();
            if ( PickupMessageClass == None )
                // DEUS_EX CNN - use the itemArticle and itemName
//				Pawn(Other).ClientMessage(PickupMessage, 'Pickup');
                Pawn(Other).ClientMessage(PickupMessage @ itemArticle @ itemName, 'Pickup');
            else
                Pawn(Other).ReceiveLocalizedMessage( PickupMessageClass, 0, None, None, Self.Class );
            PlaySound (PickupSound,,2.0);   
            Pickup(Copy).PickupFunction(Pawn(Other));
        }
    }

    function BeginState()
    {
        Super.BeginState();

        // NumCopies = 1 means we have ONE of this item now
        // DEUS_EX AJY

//		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;
        }
        if (Level.Game.LocalLog != None)
            Level.Game.LocalLog.LogItemDeactivate(Self, Pawn(Owner));
        if (Level.Game.WorldLog != None)
            Level.Game.WorldLog.LogItemDeactivate(Self, Pawn(Owner));
        if ( ItemMessageClass != None )
            Pawn(Owner).ReceiveLocalizedMessage( ItemMessageClass, 0, None, None, Self.Class );
        else
            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: Mon 8/11/2021 16:22:48.000 - Creation time: Mon 8/11/2021 16:31:31.270 - Created with UnCodeX