Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 |
//============================================================================= // Inventory // // Inventory is the parent class of all actors that can be carried by other actors. // Inventory items are placed in the holding actor's inventory chain, a linked list // of inventory actors. Each inventory class knows what pickup can spawn it (its // PickupClass). When tossed out (using the DropFrom() function), inventory items // spawn a DroppedPickup actor to hold them. // // Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. //============================================================================= class Inventory extends Actor abstract native nativereplication; //----------------------------------------------------------------------------- var Inventory Inventory; // Next Inventory in Linked List var InventoryManager InvManager; var databinding localized string ItemName; var bool bRenderOverlays; // If true, this inventory item will be given access to HUD Canvas. RenderOverlays() is called. var bool bReceiveOwnerEvents; // If true, receive Owner events. OwnerEvent() is called. /** if true, this inventory item should be dropped if the owner dies */ var bool bDropOnDeath; //----------------------------------------------------------------------------- // Pickup related properties var bool bDelayedSpawn; var bool bPredictRespawns; // high skill bots may predict respawns for this item var() float RespawnTime; // Respawn after this time, 0 for instant. var float MaxDesireability; // Maximum desireability this item will ever have. var() databinding localized string PickupMessage; // Human readable description when picked up. var() SoundCue PickupSound; var() string PickupForce; var class<DroppedPickup> DroppedPickupClass; var PrimitiveComponent DroppedPickupMesh; var PrimitiveComponent PickupFactoryMesh; var ParticleSystemComponent DroppedPickupParticles; // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // Network replication. replication { // Things the server should send to the client. if ( (Role==ROLE_Authority) && bNetDirty && bNetOwner ) Inventory, InvManager; } /** * Access to HUD and Canvas. Set bRenderOverlays=true to receive event. * Event called every frame when the item is in the InventoryManager * * @param HUD H */ simulated function RenderOverlays( HUD H ); /** * Access to HUD and Canvas. * Event always called when the InventoryManager considers this Inventory Item currently "Active" * (for example active weapon) * * @param HUD H */ simulated function ActiveRenderOverlays( HUD H ); simulated function String GetHumanReadableName() { return Default.ItemName; } event Destroyed() { // Notify Pawn's inventory manager that this item is being destroyed (remove from inventory manager). if ( Pawn(Owner) != None && Pawn(Owner).InvManager != None ) { Pawn(Owner).InvManager.RemoveFromInventory( Self ); } } /* Inventory has an AI interface to allow AIControllers, such as bots, to assess the * desireability of acquiring that pickup. The BotDesireability() method returns a * float typically between 0 and 1 describing how valuable the pickup is to the * AIController. This method is called when an AIController uses the * FindPathToBestInventory() navigation intrinsic. * @param PickupHolder - Actor in the world that holds the inventory item (usually DroppedPickup or PickupFactory) * @param P - the Pawn the AI is evaluating this item for * @param C - the Controller that is evaluating this item. Might not be P.Controller - the AI may choose to * evaluate the usability of the item by the driver Pawn of a vehicle it is currently controlling, for example */ static function float BotDesireability(Actor PickupHolder, Pawn P, Controller C) { local Inventory AlreadyHas; local float desire; desire = Default.MaxDesireability; if ( Default.RespawnTime < 10 ) { AlreadyHas = P.FindInventoryType(Default.class); if ( AlreadyHas != None ) { return -1; } } return desire; } /* DetourWeight() value of this path to take a quick detour (usually 0, used when on route to distant objective, but want to grab inventory for example) */ static function float DetourWeight(Pawn Other,float PathWeight) { return 0; } /* GiveTo: Give this Inventory Item to this Pawn. InvManager.AddInventory implements the correct behavior. */ final function GiveTo( Pawn Other ) { if ( Other != None && Other.InvManager != None ) { Other.InvManager.AddInventory( Self ); } } /* AnnouncePickup This inventory item was just picked up (from a DroppedPickup or PickupFactory) */ function AnnouncePickup(Pawn Other) { Other.HandlePickup(self); if (PickupSound != None) { Other.PlaySound( PickupSound ); } } /** * This Inventory Item has just been given to this Pawn * (server only) * * @param thisPawn new Inventory owner * @param bDoNotActivate If true, this item will not try to activate */ function GivenTo( Pawn thisPawn, optional bool bDoNotActivate ) { Instigator = ThisPawn; ClientGivenTo(thisPawn, bDoNotActivate); } /** * This Inventory Item has just been given to this Pawn * (owning client only) * * @param thisPawn new Inventory owner * @param bDoNotActivate If true, this item will not try to activate */ reliable client function ClientGivenTo(Pawn NewOwner, bool bDoNotActivate) { // make sure Owner is set - if Inventory item fluctuates Owners there is a chance this might not get updated normally SetOwner(NewOwner); Instigator = NewOwner; if (NewOwner != None && NewOwner.Controller != None) { NewOwner.Controller.NotifyAddInventory(self); } } /** * Event called when Item is removed from Inventory Manager. * Network: Authority */ function ItemRemovedFromInvManager(); /** DenyPickupQuery Function which lets existing items in a pawn's inventory prevent the pawn from picking something up. * @param ItemClass Class of Inventory our Owner is trying to pick up * @param Pickup the Actor containing that item (this may be a PickupFactory or it may be a DroppedPickup) * @return true to abort pickup or if item handles pickup */ function bool DenyPickupQuery(class<Inventory> ItemClass, Actor Pickup) { // By default, you can only carry a single item of a given class. if ( ItemClass == class ) { return true; } return false; } /** * Drop this item out in to the world * * @param StartLocation - The World Location to drop this item from * @param StartVelocity - The initial velocity for the item when dropped */ function DropFrom(vector StartLocation, vector StartVelocity) { local DroppedPickup P; if( Instigator != None && Instigator.InvManager != None ) { Instigator.InvManager.RemoveFromInventory(Self); } // if cannot spawn a pickup, then destroy and quit if( DroppedPickupClass == None || DroppedPickupMesh == None ) { Destroy(); return; } P = Spawn(DroppedPickupClass,,, StartLocation); if( P == None ) { Destroy(); return; } P.SetPhysics(PHYS_Falling); P.Inventory = self; P.InventoryClass = class; P.Velocity = StartVelocity; P.Instigator = Instigator; P.SetPickupMesh(DroppedPickupMesh); P.SetPickupParticles(DroppedPickupParticles); Instigator = None; GotoState(''); } static function string GetLocalString( optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2 ) { return Default.PickupMessage; } /* OwnerEvent: Used to inform inventory when owner event occurs (for example jumping or weapon change) set bReceiveOwnerEvents=true to receive events. */ function OwnerEvent(name EventName); defaultproperties { MaxDesireability=0.100000 PickupMessage="Snagged an item." DroppedPickupClass=Class'Engine.DroppedPickup' Begin Object Class=SpriteComponent Name=Sprite ObjName=Sprite Archetype=SpriteComponent'Engine.Default__SpriteComponent' HiddenGame=True AlwaysLoadOnClient=False AlwaysLoadOnServer=False Name="Sprite" ObjectArchetype=SpriteComponent'Engine.Default__SpriteComponent' End Object Components(0)=Sprite RemoteRole=ROLE_SimulatedProxy bHidden=True bOnlyRelevantToOwner=True bReplicateMovement=False bOnlyDirtyReplication=True NetPriority=1.400000 CollisionType=COLLIDE_CustomDefault Name="Default__Inventory" ObjectArchetype=Actor'Engine.Default__Actor' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |