Engine
Class Inventory

source: c:\runehov\Engine\Classes\Inventory.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
Direct Known Subclasses:Pickup, Shield, Weapon

class Inventory
extends Engine.Actor

//============================================================================= // The inventory class, the parent class of all objects which can be // picked up and carried by actors. //=============================================================================
Variables
 int AbsorptionPriority
           Which items absorb damage first (higher=first).
 int ArmorAbsorption
           Percent of damage item absorbs 0-100.
 byte AutoSwitchPriority
           Autoswitch value, 0=never autoswitch.
 float BobDamping
           how much to damp view bob
 int Charge
           Amount of armor or charge if not an armor (charge in time*10).
 float ExpireTime
           how much to damp view bob
 Texture Icon
           Maximum desireability this item will ever have.
 byte InventoryGroup
           The weapon/inventory set, 1-9 (0=none).
 string ItemArticle
           Human readable article (e.g. "a", "an")
 class ItemMessageClass
           Maximum desireability this item will ever have.
 string ItemName
           Human readable name of item
 String M_Activated
           Maximum desireability this item will ever have.
 String M_Deactivated
           Maximum desireability this item will ever have.
 String M_Selected
           Maximum desireability this item will ever have.
 float MaxDesireability
           Maximum desireability this item will ever have.
 Inventory NextArmor
           Temporary list created by Armors to prioritize damage absorption.
 FlashCount, OldFlashCount
           Maximum desireability this item will ever have.
 string PickupMessage
           Human readable description when picked up.
 class PickupMessageClass
           Maximum desireability this item will ever have.
 int PickupViewMesh
           Mesh to render (within skelmodel).
 float PickupViewScale
           Mesh scale.
 name PlayerLastTouched
           Player who last touched this item.
 int PlayerViewMesh
           Mesh to render (within skelmodel).
 vector PlayerViewOffset
           Offset from view center.
 float PlayerViewScale
           Mesh scale.
 name ProtectionType1
           Protects against DamageType (None if non-armor).
 name ProtectionType2
           Secondary protection type (None if non-armor).
 float RespawnTime
           Respawn after this time, 0 for instant.
 Texture StatusIcon
           Icon used with charge/power count.
 int ThirdPersonMesh
           Mesh to render (within skelmodel).
 float ThirdPersonScale
           Mesh scale.
 bool bActivatable
           Whether item can be activated.
 bool bDisplayableInv
           Item displayed in HUD.
 bool bFirstFrame
           Maximum desireability this item will ever have.
 bool bInstantRespawn
           Can be tagged so this item respawns instantly.
 bool bIsAnArmor
           Item will protect player.
 bool bRotatingPickup
           Rotates when in pickup state.
 bool bSteadyFlash3rd
           Maximum desireability this item will ever have.
 bool bSteadyToggle
           Maximum desireability this item will ever have.

States
Idle2, Sleeping, Activated, Pickup

Function Summary
 void Activate()
     
//
// Toggle Activation of selected Item.
// 
 void AltFire(float Value)
 int ArmorAbsorbDamage(int Damage, name DamageType, vector HitLocation)
     
//
// Absorb damage.
//
 void ArmorImpactEffect(vector HitLocation)
     
//
// This function is called by ArmorAbsorbDamage and displays a visual effect 
// for an impact on an armor.
//
 int ArmorPriority(name DamageType)
     
//
// Return armor value.
//
 void BecomeItem()
     
//
// Become an inventory item.
//
 void BecomePickup()
     
//
// Become a pickup.
//
 void ChangedWeapon()
     
//
// Used to inform inventory when owner weapon changes.
//
 void Destroyed()
     
//
// Called by engine when destroyed.
//
 
simulated
DrawStatusIconAt(Canvas Canvas, int X, int Y, optional float)
     
// overridable function to ask the inventory object to draw its StatusIcon
 void DropFrom(vector StartLocation)
     
//
// Toss this item out.
//
 void DropInventory()
 void Fire(float Value)
     
// Fire functions which must be implemented in child classes.
 String GetHumanName()
 int GetUsePriority()
     
//============================================================================
//
// GetUsePriority
//
// RUNE:  Returns the priority of the weapon, lower is better
//============================================================================
 void GiveTo(Pawn Other)
     
//
// Give this inventory item to a pawn.
//
 bool HandlePickupQuery(Inventory Item)
     
//
// 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 pickup, otherwise keep going through inventory list.
//
 float InventoryCapsFloat(name Property, Pawn Other, Actor Test)
     
// For future use.
 string InventoryCapsString(name Property, Pawn Other, Actor Test)
 void InventorySpecial1()
     
//=============================================================================
//
// InventorySpecial1
//
//=============================================================================
 void InventorySpecial2()
     
//=============================================================================
//
// InventorySpecial2
//
//=============================================================================
 void InventorySpecial3()
     
//=============================================================================
//
// InventorySpecial3
//
//=============================================================================
 void OwnerJumped()
     
//
// Used to inform inventory when owner jumps.
//
 void PostBeginPlay()
 Inventory PrioritizeArmor(int Damage, name DamageType, vector HitLocation)
     
//
// Return the best armor to use.
//
 Weapon RecommendWeapon(out float, out int)
 void ReduceDamage(out int, out int, name DamageType, vector HitLocation)
     
//
// Scan the player's inventory looking for items that reduce damage
// to the player.  If Armor's protection type matches DamageType, then no damage is taken.
// Returns the reduced damage.
//
 Inventory SelectNext()
     
//
// Select first activatable item.
//
 void SetOwnerDisplay()
     
// used to ask inventory if it needs to affect its owners display properties
 void SetRespawn()
     
//
// Set up respawn waiting if desired.
//
 Inventory SpawnCopy(Pawn Other)
     
// Either give this inventory to player Other, or spawn a copy
// and give it to the player Other, setting up original to be respawned.
//
 void Use(Pawn User)
 Weapon WeaponChange(byte F)
     
//
// Find a weapon in inventory that has an Inventory Group matching F.
//


State Idle2 Function Summary


State Sleeping Function Summary
 void EndState()
 void BeginState()


State Activated Function Summary
 void Activate()
 void EndState()
 void BeginState()


State Pickup Function Summary
 void EndState()
 void BeginState()
 void CheckTouching()
     
// Make sure no pawn already touching (while touch was disabled in sleep).
 void Landed(Vector HitNormal, Actor HitActor)
     
// Landed on ground.
 void Touch(Actor Other)
     
// When touched by an actor.
 bool ValidTouch(Actor Other)
     
// Validate touch, and if valid trigger event.
 bool CanBeUsed(Actor Other)
     
//============================================================================
 void ZoneChange(ZoneInfo NewZone)



Source Code


00001	//=============================================================================
00002	// The inventory class, the parent class of all objects which can be
00003	// picked up and carried by actors.
00004	//=============================================================================
00005	class Inventory extends Actor
00006		abstract
00007		native;
00008	//	nativereplication;
00009	
00010	#exec Texture Import File=Textures\Inventry.pcx Name=S_Inventory Mips=Off Flags=2
00011	
00012	//-----------------------------------------------------------------------------
00013	// Information relevant to Active/Inactive state.
00014	
00015	var() travel byte AutoSwitchPriority; // Autoswitch value, 0=never autoswitch.
00016	var() byte        InventoryGroup;     // The weapon/inventory set, 1-9 (0=none).
00017	var() bool        bActivatable;       // Whether item can be activated.
00018	var() bool	 	  bDisplayableInv;	  // Item displayed in HUD.
00019	var	travel bool   bActive;			  // Whether item is currently activated.
00020	var	  bool		  bSleepTouch;		  // Set when item is touched when leaving sleep state.
00021	var	  bool		  bHeldItem;		  // Set once an item has left pickup state.
00022	var	  bool        bTossedOut;		  // true if weapon was tossed out (so players can't cheat w/ weaponstay)
00023	var		bool		bExpireWhenTossed;	// Expire after ExpireTime when tossed out
00024	
00025	//-----------------------------------------------------------------------------
00026	// Ambient glow related info.
00027	
00028	var(Display) bool bAmbientGlow;		  // Whether to glow or not.
00029	
00030	//-----------------------------------------------------------------------------
00031	// Information relevant to Pickup state.
00032	
00033	var() bool		bInstantRespawn;	  // Can be tagged so this item respawns instantly.
00034	var() bool		bRotatingPickup;	  // Rotates when in pickup state.
00035	var() localized string PickupMessage; // Human readable description when picked up.
00036	var() localized string ItemName;      // Human readable name of item
00037	var() localized string ItemArticle;   // Human readable article (e.g. "a", "an")
00038	var() float     RespawnTime;          // Respawn after this time, 0 for instant.
00039	var name 		PlayerLastTouched;    // Player who last touched this item.
00040	
00041	//-----------------------------------------------------------------------------
00042	// Rendering information.
00043	
00044	// Player view rendering info.
00045	var() vector      PlayerViewOffset;   // Offset from view center.
00046	var() int         PlayerViewMesh;     // Mesh to render (within skelmodel).
00047	var() float       PlayerViewScale;    // Mesh scale.
00048	var() float		  BobDamping;		  // how much to damp view bob
00049	var() float		  ExpireTime;
00050	
00051	// Pickup view rendering info.
00052	var() int         PickupViewMesh;     // Mesh to render (within skelmodel).
00053	var() float       PickupViewScale;    // Mesh scale.
00054	
00055	// 3rd person mesh.
00056	var() int         ThirdPersonMesh;    // Mesh to render (within skelmodel).
00057	var() float       ThirdPersonScale;   // Mesh scale.
00058	
00059	//-----------------------------------------------------------------------------
00060	// Status bar info.
00061	
00062	var() texture     StatusIcon;         // Icon used with charge/power count.
00063	
00064	//-----------------------------------------------------------------------------
00065	// Armor related info.
00066	
00067	var() name		  ProtectionType1;	  // Protects against DamageType (None if non-armor).
00068	var() name		  ProtectionType2;	  // Secondary protection type (None if non-armor).
00069	var() travel int  Charge;			  // Amount of armor or charge if not an armor (charge in time*10).
00070	var() int		  ArmorAbsorption;	  // Percent of damage item absorbs 0-100.
00071	var() bool		  bIsAnArmor;		  // Item will protect player.
00072	var() int		  AbsorptionPriority; // Which items absorb damage first (higher=first).
00073	var() inventory	  NextArmor;		  // Temporary list created by Armors to prioritize damage absorption.
00074	
00075	//-----------------------------------------------------------------------------
00076	// AI related info.
00077	
00078	var() float		  MaxDesireability;	  // Maximum desireability this item will ever have.
00079	var	  InventorySpot MyMarker;
00080	
00081	//-----------------------------------------------------------------------------
00082	// 3rd person muzzleflash
00083	
00084	var bool bSteadyFlash3rd;
00085	var bool bFirstFrame;
00086	var(MuzzleFlash) bool bMuzzleFlashParticles;
00087	var(MuzzleFlash) bool bToggleSteadyFlash;
00088	var bool	bSteadyToggle;
00089	var byte FlashCount, OldFlashCount;
00090	var(MuzzleFlash) ERenderStyle MuzzleFlashStyle;
00091	var(MuzzleFlash) mesh MuzzleFlashMesh;
00092	var(MuzzleFlash) float MuzzleFlashScale;
00093	var(MuzzleFlash) texture MuzzleFlashTexture;
00094	
00095	//-----------------------------------------------------------------------------
00096	// Sound assignments.
00097	
00098	var(Sounds) sound PickupSound, ActivateSound, DeActivateSound, RespawnSound;
00099	var(Sounds) sound DropSound;
00100	
00101	//-----------------------------------------------------------------------------
00102	// HUD graphics.
00103	
00104	var() texture Icon;
00105	var() localized String M_Activated;
00106	var() localized String M_Selected;
00107	var() localized String M_Deactivated;
00108	
00109	//-----------------------------------------------------------------------------
00110	// Messaging
00111	
00112	var() class<LocalMessage> PickupMessageClass;
00113	var() class<LocalMessage> ItemMessageClass;
00114	
00115	
00116	// Network replication.
00117	replication
00118	{
00119		// Things the server should send to the client.
00120		reliable if( Role==ROLE_Authority && bNetOwner )
00121			bIsAnArmor, Charge, bActivatable, bActive, PlayerViewOffset, PlayerViewMesh, PlayerViewScale;
00122		unreliable if( Role==ROLE_Authority )
00123			FlashCount, bSteadyFlash3rd, ThirdPersonMesh, ThirdPersonScale;
00124	}
00125	
00126	function PostBeginPlay()
00127	{
00128		if ( ItemName == "" )
00129			ItemName = GetItemName(string(Class));
00130	
00131		Super.PostBeginPlay();
00132	}
00133	
00134	function String GetHumanName()
00135	{
00136		return ItemArticle@ItemName;
00137	}
00138	
00139	// overridable function to ask the inventory object to draw its StatusIcon
00140	simulated function DrawStatusIconAt( canvas Canvas, int X, int Y, optional float Scale )
00141	{
00142		if( Scale == 0.0 )
00143			Scale = 1.0;
00144		Canvas.SetPos( X, Y );
00145		Canvas.DrawIcon( StatusIcon, Scale );
00146	}
00147	
00148	//=============================================================================
00149	// AI inventory functions.
00150	
00151	event float BotDesireability( pawn Bot )
00152	{
00153		local Inventory AlreadyHas;
00154		local float desire;
00155		local bool bChecked;
00156	
00157		desire = MaxDesireability;
00158	
00159		if ( RespawnTime < 10 )
00160		{
00161			bChecked = true;
00162			AlreadyHas = Bot.FindInventoryType(class); 
00163			if ( (AlreadyHas != None) 
00164				&& (AlreadyHas.Charge >= Charge) )
00165					return -1;
00166		}
00167	
00168		if( bIsAnArmor )
00169		{
00170			if ( !bChecked )
00171				AlreadyHas = Bot.FindInventoryType(class); 
00172			if ( AlreadyHas != None )
00173				desire *= (1 - AlreadyHas.Charge * AlreadyHas.ArmorAbsorption * 0.00003);
00174			
00175			desire *= (Charge * 0.005);
00176			desire *= (ArmorAbsorption * 0.01);
00177			return desire;
00178		}
00179		else return desire;
00180	}
00181	
00182	function Weapon RecommendWeapon( out float rating, out int bUseAltMode )
00183	{
00184		if ( inventory != None )
00185			return inventory.RecommendWeapon(rating, bUseAltMode);
00186		else
00187		{
00188			rating = -1;
00189			return None;
00190		}
00191	}
00192	
00193	//============================================================================
00194	//
00195	// GetUsePriority
00196	//
00197	// RUNE:  Returns the priority of the weapon, lower is better
00198	//============================================================================
00199	
00200	function int GetUsePriority()
00201	{
00202		return(4);
00203	}
00204	
00205	//=============================================================================
00206	// Inventory travelling across servers.
00207	
00208	//
00209	// Called after a travelling inventory item has been accepted into a level.
00210	//
00211	event TravelPreAccept()
00212	{
00213		Super.TravelPreAccept();
00214		GiveTo( Pawn(Owner) );
00215		if( bActive )
00216			Activate();
00217	}
00218	
00219	//=============================================================================
00220	// General inventory functions.
00221	
00222	//
00223	// Called by engine when destroyed.
00224	//
00225	function Destroyed()
00226	{
00227		if (MyMarker != None )
00228			MyMarker.markedItem = None;	
00229		// Remove from owner's inventory.
00230		if( Pawn(Owner)!=None )
00231			Pawn(Owner).DeleteInventory( Self );
00232		Super.Destroyed();
00233	}
00234	
00235	
00236	//
00237	// Become a pickup.
00238	//
00239	function BecomePickup()
00240	{
00241	//	SkelMesh      = PickupViewMesh;
00242	//	DrawScale     = PickupViewScale;
00243	//	bOnlyOwnerSee = false;
00244		bHidden       = false;
00245	//	bCarriedItem  = false;
00246		NetPriority   = 1.4;
00247		SetCollision( true, false, false );
00248		bLookFocusPlayer = true;
00249		bLookFocusCreature = true;
00250	}
00251	
00252	//
00253	// Become an inventory item.
00254	//
00255	function BecomeItem()
00256	{
00257	//	SkelMesh      = PlayerViewMesh;
00258	//	DrawScale     = PlayerViewScale;
00259	//	bOnlyOwnerSee = true;
00260	//	bHidden       = true;
00261	//	bCarriedItem  = true;
00262		NetPriority   = 2.0;
00263		SetCollision( false, false, false );
00264		SetPhysics(PHYS_None);
00265	//	SetTimer(0.0,False);
00266		AmbientGlow = 0;
00267		bLookFocusPlayer = false;
00268		bLookFocusCreature = false;
00269	}
00270	
00271	//
00272	// Give this inventory item to a pawn.
00273	//
00274	function GiveTo( pawn Other )
00275	{
00276		Instigator = Other;
00277		BecomeItem();
00278		Other.AddInventory( Self );
00279		GotoState('Idle2');
00280	}
00281	
00282	// Either give this inventory to player Other, or spawn a copy
00283	// and give it to the player Other, setting up original to be respawned.
00284	//
00285	function inventory SpawnCopy( pawn Other )
00286	{
00287		local inventory Copy;
00288		if( Level.Game.ShouldRespawn(self) )
00289		{
00290			Copy = spawn(Class,Other,,,rot(0,0,0));
00291			if (Copy == None)
00292			{
00293				log(name@"cannot be spawned in spawncopy");
00294				return(Copy);
00295			}
00296			Copy.Tag           = Tag;
00297			Copy.Event         = Event;
00298			GotoState('Sleeping');
00299		}
00300		else
00301			Copy = self;
00302	
00303		Copy.bTossedOut = true;
00304		Copy.RespawnTime = 0.0;
00305		Copy.GiveTo( Other );
00306		return Copy;
00307	}
00308	
00309	//
00310	// Set up respawn waiting if desired.
00311	//
00312	function SetRespawn()
00313	{
00314		if( Level.Game.ShouldRespawn(self) )
00315			GotoState('Sleeping');
00316		else
00317			Destroy();
00318	}
00319	
00320	
00321	//
00322	// Toggle Activation of selected Item.
00323	// 
00324	function Activate()
00325	{
00326		if( bActivatable )
00327		{
00328			if (Level.Game.LocalLog != None)
00329				Level.Game.LocalLog.LogItemActivate(Self, Pawn(Owner));
00330			if (Level.Game.WorldLog != None)
00331				Level.Game.WorldLog.LogItemActivate(Self, Pawn(Owner));
00332	
00333			if ( M_Activated != "" )
00334				Pawn(Owner).ClientMessage(ItemName$M_Activated);	
00335			GoToState('Activated');
00336		}
00337	}
00338	
00339	//
00340	// Function which lets existing items in a pawn's inventory
00341	// prevent the pawn from picking something up. Return true to abort pickup
00342	// or if item handles pickup, otherwise keep going through inventory list.
00343	//
00344	function bool HandlePickupQuery( inventory Item )
00345	{
00346		if ( Item.Class == Class )
00347			return true;
00348		if ( Inventory == None )
00349			return false;
00350	
00351		return Inventory.HandlePickupQuery(Item);
00352	}
00353	
00354	//
00355	// Select first activatable item.
00356	//
00357	function Inventory SelectNext()
00358	{
00359		if ( bActivatable ) 
00360		{
00361			if ( M_Selected != "" )
00362				Pawn(Owner).ClientMessage(ItemName$M_Selected);
00363			return self;
00364		}
00365		if ( Inventory != None )
00366			return Inventory.SelectNext();
00367		else
00368			return None;
00369	}
00370	
00371	//
00372	// Toss this item out.
00373	//
00374	function DropFrom(vector StartLocation)
00375	{
00376		if ( !SetLocation(StartLocation) )
00377			return; 
00378		RespawnTime = 0.0; //don't respawn
00379		SetPhysics(PHYS_Falling);
00380		BecomePickup();
00381		NetPriority = 2.5;
00382		bCollideWorld = true;
00383		if ( Pawn(Owner) != None )
00384			Pawn(Owner).DeleteInventory(self);
00385		Inventory = None;
00386	//	GotoState('PickUp', 'Dropped');
00387		GotoState('PickUp');
00388	}
00389	
00390	function DropInventory()
00391	{
00392	}
00393	
00394	//=============================================================================
00395	// Capabilities: For feeding general info to bots.
00396	
00397	// For future use.
00398	function float InventoryCapsFloat( name Property, pawn Other, actor Test );
00399	function string InventoryCapsString( name Property, pawn Other, actor Test );
00400	
00401	//=============================================================================
00402	// Firing/using.
00403	
00404	// Fire functions which must be implemented in child classes.
00405	function Fire( float Value );
00406	function AltFire( float Value );
00407	function Use( pawn User );
00408	
00409	//=============================================================================
00410	// Weapon functions.
00411	
00412	//
00413	// Find a weapon in inventory that has an Inventory Group matching F.
00414	//
00415	
00416	function Weapon WeaponChange( byte F )
00417	{
00418		if( Inventory == None)
00419			return None;
00420		else
00421			return Inventory.WeaponChange( F );
00422	}
00423	
00424	//=============================================================================
00425	// Armor functions.
00426	
00427	//
00428	// Scan the player's inventory looking for items that reduce damage
00429	// to the player.  If Armor's protection type matches DamageType, then no damage is taken.
00430	// Returns the reduced damage.
00431	//
00432	function ReduceDamage( out int BluntDamage, out int SeverDamage, name DamageType, vector HitLocation )
00433	{
00434		local Inventory FirstArmor;
00435		local int ReducedAmount,ArmorDamage;
00436		
00437		if( BluntDamage<0 && SeverDamage<0)
00438		{
00439			BluntDamage = 0;
00440			SeverDamage = 0;
00441			return;
00442		}
00443	
00444		ReducedAmount = BluntDamage;
00445		FirstArmor = PrioritizeArmor(BluntDamage, DamageType, HitLocation);
00446		while( (FirstArmor != None) && (ReducedAmount > 0) )
00447		{
00448			ReducedAmount = FirstArmor.ArmorAbsorbDamage(ReducedAmount, DamageType, HitLocation);
00449			FirstArmor = FirstArmor.nextArmor;
00450		}
00451	
00452		BluntDamage = ReducedAmount;
00453	}
00454	
00455	//
00456	// Return the best armor to use.
00457	//
00458	function inventory PrioritizeArmor( int Damage, name DamageType, vector HitLocation )
00459	{
00460		local Inventory FirstArmor, InsertAfter;
00461	
00462		if ( Inventory != None )
00463			FirstArmor = Inventory.PrioritizeArmor(Damage, DamageType, HitLocation);
00464		else
00465			FirstArmor = None;
00466	
00467		if ( bIsAnArmor)
00468		{
00469			if ( FirstArmor == None )
00470			{
00471				nextArmor = None;
00472				return self;
00473			}
00474	
00475			// insert this armor into the prioritized armor list
00476			if ( FirstArmor.ArmorPriority(DamageType) < ArmorPriority(DamageType) )
00477			{
00478				nextArmor = FirstArmor;
00479				return self;
00480			}
00481			InsertAfter = FirstArmor;
00482			while ( (InsertAfter.nextArmor != None) 
00483				&& (InsertAfter.nextArmor.ArmorPriority(DamageType) > ArmorPriority(DamageType)) )
00484				InsertAfter = InsertAfter.nextArmor;
00485	
00486			nextArmor = InsertAfter.nextArmor;
00487			InsertAfter.nextArmor = self;
00488		}
00489		return FirstArmor;
00490	}
00491	
00492	//
00493	// Absorb damage.
00494	//
00495	function int ArmorAbsorbDamage(int Damage, name DamageType, vector HitLocation)
00496	{
00497		local int ArmorDamage;
00498	
00499		if ( DamageType != 'Drowned' )
00500			ArmorImpactEffect(HitLocation);
00501		if( (DamageType!='None') && ((ProtectionType1==DamageType) || (ProtectionType2==DamageType)) )
00502			return 0;
00503		
00504		if (DamageType=='Drowned') Return Damage;
00505		
00506		ArmorDamage = (Damage * ArmorAbsorption) / 100;
00507		if( ArmorDamage >= Charge )
00508		{
00509			ArmorDamage = Charge;
00510			Destroy();
00511		}
00512		else 
00513			Charge -= ArmorDamage;
00514		return (Damage - ArmorDamage);
00515	}
00516	
00517	//
00518	// Return armor value.
00519	//
00520	function int ArmorPriority(name DamageType)
00521	{
00522		if ( DamageType == 'Drowned' )
00523			return 0;
00524		if( (DamageType!='None') 
00525			&& ((ProtectionType1==DamageType) || (ProtectionType2==DamageType)) )
00526			return 1000000;
00527	
00528		return AbsorptionPriority;
00529	}
00530	
00531	//
00532	// This function is called by ArmorAbsorbDamage and displays a visual effect 
00533	// for an impact on an armor.
00534	//
00535	function ArmorImpactEffect(vector HitLocation){ }
00536	
00537	//
00538	// Used to inform inventory when owner jumps.
00539	//
00540	function OwnerJumped()
00541	{
00542		if( Inventory != None )
00543			Inventory.OwnerJumped();
00544	}
00545	
00546	//
00547	// Used to inform inventory when owner weapon changes.
00548	//
00549	function ChangedWeapon()
00550	{
00551		if( Inventory != None )
00552			Inventory.ChangedWeapon();
00553	}
00554	
00555	// used to ask inventory if it needs to affect its owners display properties
00556	function SetOwnerDisplay()
00557	{
00558		if( Inventory != None )
00559			Inventory.SetOwnerDisplay();
00560	}
00561	
00562	// ===== INVENTORY SPECIALS =====
00563	// These are functions that are called on the inventory item from an actor
00564	// when that actor received a particular notify function
00565	
00566	//=============================================================================
00567	//
00568	// InventorySpecial1
00569	//
00570	//=============================================================================
00571	
00572	function InventorySpecial1()
00573	{
00574	}
00575	
00576	//=============================================================================
00577	//
00578	// InventorySpecial2
00579	//
00580	//=============================================================================
00581	
00582	function InventorySpecial2()
00583	{
00584	}
00585	
00586	//=============================================================================
00587	//
00588	// InventorySpecial3
00589	//
00590	//=============================================================================
00591	
00592	function InventorySpecial3()
00593	{
00594	}
00595	
00596	//=============================================================================
00597	// Pickup state: this inventory item is sitting on the ground.
00598	
00599	auto state Pickup
00600	{
00601		singular function ZoneChange( ZoneInfo NewZone )
00602		{
00603			local float splashsize;
00604			local actor splash;
00605	
00606			if( NewZone.bWaterZone && !Region.Zone.bWaterZone ) 
00607			{
00608				splashSize = 0.000025 * Mass * (250 - 0.5 * Velocity.Z);
00609				if ( NewZone.EntrySound != None )
00610					PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize);
00611				if ( NewZone.EntryActor != None )
00612				{
00613					splash = Spawn(NewZone.EntryActor); 
00614					if ( splash != None )
00615						splash.DrawScale = 2 * splashSize;
00616				}
00617			}
00618		}
00619	
00620		//============================================================================
00621		//
00622		// CanBeUsed
00623		//
00624		//============================================================================
00625		function bool CanBeUsed(Actor Other)
00626		{
00627			if(Other.IsA('PlayerPawn') && Other.AnimProxy != None)
00628			{
00629				if(Other.AnimProxy.WantsToPickup(self))
00630				{
00631					return(true);
00632				}
00633			}
00634	
00635			return(false);
00636		}
00637	
00638		// Validate touch, and if valid trigger event.
00639		function bool ValidTouch( actor Other )
00640		{
00641			local Actor A;
00642	
00643			if( Other.bIsPawn && (Pawn(Other).Health > 0) && Level.Game.PickupQuery(Pawn(Other), self) )
00644			{
00645				if( Event != '' )
00646					foreach AllActors( class 'Actor', A, Event )
00647						A.Trigger( Other, Other.Instigator );
00648				return true;
00649			}
00650			return false;
00651		}
00652			
00653		// When touched by an actor.
00654		function Touch( actor Other )
00655		{
00656			local inventory Copy;
00657	
00658			// Logic for bAutoPickup is in PlayerProxy CanPickup()
00659	
00660			// If touched by a player pawn, let him pick this up. (
00661			if( ValidTouch(Other) )
00662			{
00663				if (Level.Game.LocalLog != None)
00664					Level.Game.LocalLog.LogPickup(Self, Pawn(Other));
00665				if (Level.Game.WorldLog != None)
00666					Level.Game.WorldLog.LogPickup(Self, Pawn(Other));
00667				Copy = SpawnCopy(Pawn(Other));
00668				if ( PickupMessageClass == None )
00669					Pawn(Other).ClientMessage(PickupMessage, 'Pickup');
00670				else
00671					Pawn(Other).ReceiveLocalizedMessage( PickupMessageClass, 0, None, None, Self.Class );
00672				Copy.PlaySound (PickupSound);
00673				if ( Level.Game.Difficulty > 1 )
00674					Other.MakeNoise(0.1 * Level.Game.Difficulty);
00675				if ( Pawn(Other).MoveTarget == self )
00676					Pawn(Other).MoveTimer = -1.0;		
00677				Pawn(Other).AcquireInventory(Copy); // RUNE
00678			}
00679		}
00680	
00681		// Landed on ground.
00682		function Landed(Vector HitNormal, actor HitActor)
00683		{
00684			local rotator newRot;
00685			newRot = Rotation;
00686			newRot.pitch = 0;
00687			SetRotation(newRot);
00688	//		SetTimer(2.0, false); // never used
00689		}
00690	
00691		// Make sure no pawn already touching (while touch was disabled in sleep).
00692		function CheckTouching()
00693		{
00694			local int i;
00695	
00696			bSleepTouch = false;
00697			for ( i=0; i<4; i++ )
00698				if ( (Touching[i] != None) && Touching[i].IsA('Pawn') )
00699					Touch(Touching[i]);
00700		}
00701	
00702		function BeginState()
00703		{
00704			BecomePickup();
00705			bCollideWorld = true;
00706			if ( Level.bStartup )
00707			{
00708				bAlwaysRelevant = true;
00709				NetUpdateFrequency = 8;
00710			}
00711		}
00712	
00713		function EndState()
00714		{
00715			bCollideWorld = false;
00716			bSleepTouch = false;
00717		}
00718	
00719	Begin:
00720		BecomePickup();
00721		if ( bRotatingPickup && (Physics != PHYS_Falling) )
00722			SetPhysics(PHYS_Rotating);
00723	
00724	Dropped:
00725		if( bAmbientGlow )
00726			AmbientGlow=0;
00727		if( bSleepTouch )
00728			CheckTouching();
00729	}
00730	
00731	//=============================================================================
00732	// Active state: this inventory item is armed and ready to rock!
00733	
00734	state Activated
00735	{
00736		function BeginState()
00737		{
00738			bActive = true;
00739			if ( Pawn(Owner).bIsPlayer && (ProtectionType1 != '') )
00740				Pawn(Owner).ReducedDamageType = ProtectionType1;
00741		}
00742	
00743		function EndState()
00744		{
00745			bActive = false;
00746			if ( (Pawn(Owner) != None)
00747				&& Pawn(Owner).bIsPlayer && (ProtectionType1 != '') )
00748				Pawn(Owner).ReducedDamageType = '';
00749		}
00750	
00751		function Activate()
00752		{
00753			if ( (Pawn(Owner) != None) && (M_Deactivated != "") )
00754				Pawn(Owner).ClientMessage(ItemName$M_Deactivated);	
00755			GoToState('DeActivated');	
00756		}
00757	}
00758	
00759	//=============================================================================
00760	// Sleeping state: Sitting hidden waiting to respawn.
00761	
00762	State Sleeping
00763	{
00764		ignores Touch;
00765	
00766		function BeginState()
00767		{
00768	//		BecomePickup();
00769			bSweepable=false;
00770			SetCollision( false, false, false );
00771			SetPhysics(PHYS_None);
00772			bLookFocusPlayer = false;
00773			bLookFocusCreature = false;
00774			bHidden = true;
00775		}
00776		function EndState()
00777		{
00778			local int i;
00779	
00780			bSweepable=Default.bSweepable;
00781			BecomePickup();
00782			bSleepTouch = false;
00783			for ( i=0; i<4; i++ )
00784				if ( (Touching[i] != None) && Touching[i].IsA('Pawn') )
00785					bSleepTouch = true;
00786		}			
00787	Begin:
00788		Sleep( ReSpawnTime );
00789		PlaySound( RespawnSound );	
00790		Sleep( Level.Game.PlaySpawnEffect(self) );
00791		GoToState( 'Pickup' );
00792	}
00793	
00794	
00795	//
00796	// Null state.
00797	//
00798	State Idle2
00799	{
00800	}
00801	
00802	defaultproperties
00803	{
00804	     bExpireWhenTossed=True
00805	     bRotatingPickup=True
00806	     PickupMessage="None"
00807	     ItemArticle="a"
00808	     PlayerViewScale=1.000000
00809	     BobDamping=0.960000
00810	     ExpireTime=45.000000
00811	     PickupViewScale=1.000000
00812	     ThirdPersonScale=1.000000
00813	     MaxDesireability=0.005000
00814	     bFirstFrame=True
00815	     bToggleSteadyFlash=True
00816	     M_Activated=" activated."
00817	     M_Selected=" selected."
00818	     M_Deactivated=" deactivated."
00819	     bLookFocusPlayer=True
00820	     bLookFocusCreature=True
00821	     DrawType=DT_SkeletalMesh
00822	     Texture=Texture'Engine.S_Inventory'
00823	     bIsItemGoal=True
00824	     bTravel=True
00825	     CollisionRadius=30.000000
00826	     CollisionHeight=30.000000
00827	     bCollideActors=True
00828	     bSweepable=True
00829	     bFixedRotationDir=True
00830	     RotationRate=(Yaw=5000)
00831	     DesiredRotation=(Yaw=30000)
00832	     NetPriority=1.400000
00833	}

End Source Code