Engine
Class Pickup

source: e:\games\UnrealTournament\Engine\Classes\Pickup.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Pickup
Direct Known Subclasses:TournamentHealth, TournamentPickup, Ammo, Dampener, ForceField, Invisibility, JumpBoots, Seeds, Amplifier, Armor, Flare, Flashlight, Health, SCUBAGear, ShieldBelt, Suits, Translator, VoiceBox, WeaponPowerUp

class Pickup
extends Engine.Inventory

//============================================================================= // Pickup items. //=============================================================================
Variables
 String ExpireMessage
           Messages shown when pickup charge runs out
 Inventory Inv
 int NumCopies
 bool bAutoActivate
           Messages shown when pickup charge runs out
 bool bCanActivate
           Item can be selected and activated
 bool bCanHaveMultipleCopies
           if player can possess more than one of this

States
Activated, Pickup

Function Summary
 bool HandlePickupQuery(Inventory Item)
     
//
// 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
 Inventory SpawnCopy(Pawn Other)
 void TravelPostAccept()
 float UseCharge(float Amount)


State Activated Function Summary
 void Activate()


State Pickup Function Summary
 void UsedUp()
     
//
// This is called when a usable inventory item has used up it's charge.
//
 void PickupFunction(Pawn Other)
 void BeginState()
 void Touch(Actor Other)



Source Code


00001	//=============================================================================
00002	// Pickup items.
00003	//=============================================================================
00004	class Pickup extends Inventory
00005		abstract
00006		native
00007		nativereplication;
00008	
00009	var inventory Inv;
00010	var travel int NumCopies;
00011	var() bool bCanHaveMultipleCopies;  // if player can possess more than one of this
00012	var() bool bCanActivate;			// Item can be selected and activated
00013	var() localized String ExpireMessage; // Messages shown when pickup charge runs out
00014	var() bool bAutoActivate;
00015	
00016	replication
00017	{
00018		// Things the server should send to the client.
00019		reliable if( bNetOwner && (Role==ROLE_Authority) )
00020			NumCopies;
00021	}
00022	
00023	function TravelPostAccept()
00024	{
00025		Super.TravelPostAccept();
00026		PickupFunction(Pawn(Owner));
00027	}
00028	
00029	//
00030	// Advanced function which lets existing items in a pawn's inventory
00031	// prevent the pawn from picking something up. Return true to abort pickup
00032	// or if item handles the pickup
00033	function bool HandlePickupQuery( inventory Item )
00034	{
00035		if (item.class == class) 
00036		{
00037			if (bCanHaveMultipleCopies) 
00038			{   // for items like Artifact
00039				NumCopies++;
00040				if (Level.Game.LocalLog != None)
00041					Level.Game.LocalLog.LogPickup(Item, Pawn(Owner));
00042				if (Level.Game.WorldLog != None)
00043					Level.Game.WorldLog.LogPickup(Item, Pawn(Owner));
00044				if ( Item.PickupMessageClass == None )
00045					Pawn(Owner).ClientMessage(item.PickupMessage, 'Pickup');
00046				else
00047					Pawn(Owner).ReceiveLocalizedMessage( item.PickupMessageClass, 0, None, None, item.Class );
00048				Item.PlaySound (Item.PickupSound,,2.0);
00049				Item.SetRespawn();
00050			}
00051			else if ( bDisplayableInv ) 
00052			{		
00053				if ( Charge<Item.Charge )	
00054					Charge= Item.Charge;
00055				if (Level.Game.LocalLog != None)
00056					Level.Game.LocalLog.LogPickup(Item, Pawn(Owner));
00057				if (Level.Game.WorldLog != None)
00058					Level.Game.WorldLog.LogPickup(Item, Pawn(Owner));
00059				if ( Item.PickupMessageClass == None )
00060					Pawn(Owner).ClientMessage(item.PickupMessage, 'Pickup');
00061				else
00062					Pawn(Owner).ReceiveLocalizedMessage( item.PickupMessageClass, 0, None, None, item.Class );
00063				Item.PlaySound (item.PickupSound,,2.0);
00064				Item.SetReSpawn();
00065			}
00066			return true;				
00067		}
00068		if ( Inventory == None )
00069			return false;
00070	
00071		return Inventory.HandlePickupQuery(Item);
00072	}
00073	
00074	function float UseCharge(float Amount);
00075	
00076	function inventory SpawnCopy( pawn Other )
00077	{
00078		local inventory Copy;
00079	
00080		Copy = Super.SpawnCopy(Other);
00081		Copy.Charge = Charge;
00082		return Copy;
00083	}
00084	
00085	auto state Pickup
00086	{	
00087		function Touch( actor Other )
00088		{
00089			local Inventory Copy;
00090			if ( ValidTouch(Other) ) 
00091			{
00092				Copy = SpawnCopy(Pawn(Other));
00093				if (Level.Game.LocalLog != None)
00094					Level.Game.LocalLog.LogPickup(Self, Pawn(Other));
00095				if (Level.Game.WorldLog != None)
00096					Level.Game.WorldLog.LogPickup(Self, Pawn(Other));
00097				if (bActivatable && Pawn(Other).SelectedItem==None) 
00098					Pawn(Other).SelectedItem=Copy;
00099				if (bActivatable && bAutoActivate && Pawn(Other).bAutoActivate) Copy.Activate();
00100				if ( PickupMessageClass == None )
00101					Pawn(Other).ClientMessage(PickupMessage, 'Pickup');
00102				else
00103					Pawn(Other).ReceiveLocalizedMessage( PickupMessageClass, 0, None, None, Self.Class );
00104				PlaySound (PickupSound,,2.0);	
00105				Pickup(Copy).PickupFunction(Pawn(Other));
00106			}
00107		}
00108	
00109		function BeginState()
00110		{
00111			Super.BeginState();
00112			NumCopies = 0;
00113		}
00114	}
00115	
00116	function PickupFunction(Pawn Other)
00117	{
00118	}
00119	
00120	//
00121	// This is called when a usable inventory item has used up it's charge.
00122	//
00123	function UsedUp()
00124	{
00125		if ( Pawn(Owner) != None )
00126		{
00127			bActivatable = false;
00128			Pawn(Owner).NextItem();
00129			if (Pawn(Owner).SelectedItem == Self) {
00130				Pawn(Owner).NextItem();	
00131				if (Pawn(Owner).SelectedItem == Self) Pawn(Owner).SelectedItem=None;
00132			}
00133			if (Level.Game.LocalLog != None)
00134				Level.Game.LocalLog.LogItemDeactivate(Self, Pawn(Owner));
00135			if (Level.Game.WorldLog != None)
00136				Level.Game.WorldLog.LogItemDeactivate(Self, Pawn(Owner));
00137			if ( ItemMessageClass != None )
00138				Pawn(Owner).ReceiveLocalizedMessage( ItemMessageClass, 0, None, None, Self.Class );
00139			else
00140				Pawn(Owner).ClientMessage(ExpireMessage);	
00141		}
00142		Owner.PlaySound(DeactivateSound);
00143		Destroy();
00144	}
00145	
00146	
00147	state Activated
00148	{
00149		function Activate()
00150		{
00151			if ( (Pawn(Owner) != None) && Pawn(Owner).bAutoActivate 
00152				&& bAutoActivate && (Charge>0) )
00153					return;
00154	
00155			Super.Activate();	
00156		}
00157	}
00158	
00159	defaultproperties
00160	{
00161	     bRotatingPickup=False
00162	}

End Source Code