Advertisement
Guest User

Engine/Classes/Inventory.uc

a guest
Aug 2nd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // The inventory class, the parent class of all objects which can be
  3. // picked up and carried by actors.
  4. //=============================================================================
  5. class Inventory extends Actor
  6.     abstract
  7.         native
  8.             NativeReplication;
  9.  
  10. #exec Texture Import File=Textures\Inventry.pcx Name=S_Inventory Mips=Off Flags=2
  11.  
  12. //-----------------------------------------------------------------------------
  13. // Information relevant to Active/Inactive state.
  14.  
  15. var() travel byte AutoSwitchPriority; // Autoswitch value, 0=never autoswitch.
  16. var() byte        InventoryGroup;     // The weapon/inventory set, 1-9 (0=none).
  17. var() bool        bActivatable;       // Whether item can be activated.
  18. var() bool        bDisplayableInv;    // Item displayed in HUD.
  19. var travel bool   bActive;            // Whether item is currently activated.
  20. var   bool        bSleepTouch;        // Set when item is touched when leaving sleep state.
  21. var   bool        bHeldItem;          // Set once an item has left pickup state.
  22. var() bool        bNoInventoryMarker; // 227j: Do not add an inventory spot marker for this item.
  23.  
  24. // Network replication.
  25. var bool bRepMuzzleFlash; // Replicate muzzle flash variables.
  26. var bool bRepPlayerView; // Replicate player view stuff (offset, mesh, scale).
  27.  
  28. // 3rd person muzzleflash
  29. var bool bSteadyFlash3rd;
  30. var bool bFirstFrame;
  31. var(MuzzleFlash) bool bMuzzleFlashParticles;
  32. var(MuzzleFlash) bool bToggleSteadyFlash;
  33. var bool    bSteadyToggle;
  34.  
  35. //-----------------------------------------------------------------------------
  36. // Ambient glow related info.
  37.  
  38. var(Display) bool bAmbientGlow;       // Whether to glow or not.
  39.  
  40. //-----------------------------------------------------------------------------
  41. // Information relevant to Pickup state.
  42.  
  43. var() bool      bInstantRespawn;      // Can be tagged so this item respawns instantly.
  44. var() bool      bRotatingPickup;      // Rotates when in pickup state.
  45. var() localized string PickupMessage; // Human readable description when picked up.
  46. var() localized string ItemName;      // Human readable name of item
  47. var() localized string ItemArticle;   // Human readable article (e.g. "a", "an")
  48. var() float     RespawnTime;          // Respawn after this time, 0 for instant.
  49. var name        PlayerLastTouched;    // Player who last touched this item.
  50.  
  51. //-----------------------------------------------------------------------------
  52. // Rendering information.
  53.  
  54. // Player view rendering info.
  55. var() vector      PlayerViewOffset;   // Offset from view center.
  56. var() mesh        PlayerViewMesh;     // Mesh to render.
  57. var() float       PlayerViewScale;    // Mesh scale.
  58. var() float       BobDamping;         // how much to damp view bob
  59.  
  60. // Pickup view rendering info.
  61. var() mesh        PickupViewMesh;     // Mesh to render.
  62. var() float       PickupViewScale;    // Mesh scale.
  63.  
  64. // 3rd person mesh.
  65. var() mesh        ThirdPersonMesh;    // Mesh to render.
  66. var() float       ThirdPersonScale;   // Mesh scale.
  67.  
  68. //-----------------------------------------------------------------------------
  69. // Status bar info.
  70.  
  71. var() texture     StatusIcon;         // Icon used with ammo/charge/power count.
  72.  
  73. //-----------------------------------------------------------------------------
  74. // Armor related info.
  75.  
  76. var() name        ProtectionType1;    // Protects against DamageType (None if non-armor).
  77. var() name        ProtectionType2;    // Secondary protection type (None if non-armor).
  78. var() travel int  Charge;             // Amount of armor or charge if not an armor (charge in time*10).
  79. var() int         ArmorAbsorption;    // Percent of damage item absorbs 0-100.
  80. var() bool        bIsAnArmor;         // Item will protect player.
  81. var() int         AbsorptionPriority; // Which items absorb damage first (higher=first).
  82. var() inventory   NextArmor;          // Temporary list created by Armors to prioritize damage absorption.
  83.  
  84. //-----------------------------------------------------------------------------
  85. // AI related info.
  86.  
  87. var() float       MaxDesireability;   // Maximum desireability this item will ever have.
  88. var   InventorySpot myMarker;
  89.  
  90. //-----------------------------------------------------------------------------
  91. // 3rd person muzzleflash
  92.  
  93. var byte FlashCount, OldFlashCount;
  94. var(MuzzleFlash) ERenderStyle MuzzleFlashStyle;
  95. var(MuzzleFlash) mesh MuzzleFlashMesh;
  96. var(MuzzleFlash) float MuzzleFlashScale;
  97. var(MuzzleFlash) texture MuzzleFlashTexture;
  98.  
  99. //-----------------------------------------------------------------------------
  100. // Sound assignments.
  101.  
  102. var() sound PickupSound, ActivateSound, DeActivateSound, RespawnSound;
  103.  
  104. //-----------------------------------------------------------------------------
  105. // HUD graphics.
  106.  
  107. var() texture Icon;
  108. var() localized String M_Activated;
  109. var() localized String M_Selected;
  110. var() localized String M_Deactivated;
  111.  
  112. replication
  113. {
  114.     // Things the server should send to the client.
  115.     reliable if ( Role==ROLE_Authority && bNetOwner )
  116.         bIsAnArmor, Charge, bActivatable, bActive, PlayerViewOffset, PlayerViewMesh, PlayerViewScale;
  117.     unreliable if ( Role==ROLE_Authority )
  118.         FlashCount, bSteadyFlash3rd, ThirdPersonMesh, ThirdPersonScale;
  119. }
  120.  
  121. function PostBeginPlay()
  122. {
  123.     if ( ItemName == "" )
  124.         ItemName = GetItemName(string(Class));
  125.  
  126.     Super.PostBeginPlay();
  127. }
  128.  
  129. // Draw first person view of inventory
  130. simulated event RenderOverlays( canvas Canvas )
  131. {
  132.     if ( Owner == None )
  133.         return;
  134.     if ( (Level.NetMode == NM_Client) && (!Owner.IsA('PlayerPawn') || (PlayerPawn(Owner).Player == None)) )
  135.         return;
  136.     SetLocation( Owner.Location + CalcDrawOffset() );
  137.     SetRotation( Pawn(Owner).ViewRotation );
  138.     Canvas.DrawActor(self, false);
  139. }
  140.  
  141. function String GetHumanName()
  142. {
  143.     return ItemArticle@ItemName;
  144. }
  145.  
  146. //MWP:begin
  147. // overridable function to ask the inventory object to draw its StatusIcon
  148. simulated function DrawStatusIconAt( canvas Canvas, int X, int Y, optional float Scale )
  149. {
  150.     if ( Scale == 0.0 )
  151.         Scale = 1.0;
  152.     Canvas.SetPos( X, Y );
  153.     Canvas.DrawIcon( StatusIcon, Scale );
  154. }
  155. //MWP:end
  156.  
  157. //=============================================================================
  158. // AI inventory functions.
  159.  
  160. event float BotDesireability( pawn Bot )
  161. {
  162.     local Inventory AlreadyHas;
  163.     local float desire;
  164.     local bool bChecked;
  165.  
  166.     desire = MaxDesireability;
  167.  
  168.     if ( RespawnTime < 10 )
  169.     {
  170.         bChecked = true;
  171.         AlreadyHas = Bot.FindInventoryType(class);
  172.         if ( (AlreadyHas != None)
  173.                 && (AlreadyHas.Charge >= Charge) )
  174.             return -1;
  175.     }
  176.  
  177.     if ( bIsAnArmor )
  178.     {
  179.         if ( !bChecked )
  180.             AlreadyHas = Bot.FindInventoryType(class);
  181.         if ( AlreadyHas != None )
  182.             desire *= 0.4;
  183.  
  184.         desire *= (Charge * 0.005);
  185.         desire *= (ArmorAbsorption * 0.01);
  186.         return desire;
  187.     }
  188.     else return desire;
  189. }
  190.  
  191. function Weapon RecommendWeapon( out float rating, out int bUseAltMode )
  192. {
  193.     if ( inventory != None )
  194.         return inventory.RecommendWeapon(rating, bUseAltMode);
  195.     else
  196.     {
  197.         rating = -1;
  198.         return None;
  199.     }
  200. }
  201.  
  202. //=============================================================================
  203. // Inventory travelling across servers.
  204.  
  205. //
  206. // Called after a travelling inventory item has been accepted into a level.
  207. //
  208. event TravelPreAccept()
  209. {
  210.     Super.TravelPreAccept();
  211.     GiveTo( Pawn(Owner) );
  212.     if ( bActive )
  213.         Activate();
  214. }
  215.  
  216. //=============================================================================
  217. // General inventory functions.
  218.  
  219. //
  220. // Called by engine when destroyed.
  221. //
  222. function Destroyed()
  223. {
  224.     if (myMarker != None )
  225.         myMarker.markedItem = None;
  226.     // Remove from owner's inventory.
  227.     if ( Pawn(Owner)!=None )
  228.         Pawn(Owner).DeleteInventory( Self );
  229. }
  230.  
  231. //
  232. // Compute offset for drawing.
  233. //
  234. simulated final function vector CalcDrawOffset()
  235. {
  236.     local vector DrawOffset, WeaponBob;
  237.     local Pawn PawnOwner;
  238.  
  239.     PawnOwner = Pawn(Owner);
  240.     DrawOffset = ((0.01 * PlayerViewOffset) >> PawnOwner.ViewRotation);
  241.  
  242.     if ( (Level.NetMode == NM_DedicatedServer)
  243.             || ((Level.NetMode == NM_ListenServer) && (Owner.RemoteRole == ROLE_AutonomousProxy)) )
  244.         DrawOffset += (PawnOwner.BaseEyeHeight * vect(0,0,1));
  245.     else
  246.     {
  247.         DrawOffset += (PawnOwner.EyeHeight * vect(0,0,1));
  248.         WeaponBob = BobDamping * PawnOwner.WalkBob;
  249.         WeaponBob.Z = (0.45 + 0.55 * BobDamping) * PawnOwner.WalkBob.Z;
  250.         DrawOffset += WeaponBob;
  251.     }
  252.     return DrawOffset;
  253. }
  254.  
  255. //
  256. // Become a pickup.
  257. //
  258. function BecomePickup()
  259. {
  260.     if ( Physics != PHYS_Falling )
  261.         RemoteRole    = ROLE_SimulatedProxy;
  262.     Mesh          = PickupViewMesh;
  263.     DrawScale     = PickupViewScale;
  264.     bOnlyOwnerSee = false;
  265.     bHidden       = false;
  266.     bCarriedItem  = false;
  267.     NetPriority   = 2;
  268.     SetCollision( true, false, false );
  269. }
  270.  
  271. //
  272. // Become an inventory item.
  273. //
  274. function BecomeItem()
  275. {
  276.     RemoteRole    = ROLE_DumbProxy;
  277.     Mesh          = PlayerViewMesh;
  278.     DrawScale     = PlayerViewScale;
  279.     bOnlyOwnerSee = true;
  280.     bHidden       = true;
  281.     bCarriedItem  = true;
  282.     NetPriority   = 2;
  283.     SetCollision( false, false, false );
  284.     SetPhysics(PHYS_None);
  285.     SetTimer(0.0,False);
  286.     AmbientGlow = 0;
  287. }
  288.  
  289. //
  290. // Give this inventory item to a pawn.
  291. //
  292. function GiveTo( pawn Other )
  293. {
  294.     Instigator = Other;
  295.     BecomeItem();
  296.     Other.AddInventory( Self );
  297.     GotoState('Idle2');
  298. }
  299.  
  300. // Either give this inventory to player Other, or spawn a copy
  301. // and give it to the player Other, setting up original to be respawned.
  302. //
  303. function inventory SpawnCopy( pawn Other )
  304. {
  305.     local inventory Copy;
  306.     if ( Level.Game.ShouldRespawn(self) )
  307.     {
  308.         Copy = spawn(Class,Other);
  309.         Copy.Tag           = Tag;
  310.         Copy.Event         = Event;
  311.         GotoState('Sleeping');
  312.     }
  313.     else
  314.         Copy = self;
  315.  
  316.     Copy.RespawnTime = 0.0;
  317.     Copy.bHeldItem = true;
  318.     Copy.GiveTo( Other );
  319.     return Copy;
  320. }
  321.  
  322. //
  323. // Set up respawn waiting if desired.
  324. //
  325. function SetRespawn()
  326. {
  327.     if ( Level.Game.ShouldRespawn(self) )
  328.         GotoState('Sleeping');
  329.     else
  330.         Destroy();
  331. }
  332.  
  333.  
  334. //
  335. // Toggle Activation of selected Item.
  336. //
  337. function Activate()
  338. {
  339.     if ( bActivatable )
  340.     {
  341.         if (Level.Game.LocalLog != None)
  342.             Level.Game.LocalLog.LogItemActivate(Self, Pawn(Owner));
  343.         if (Level.Game.WorldLog != None)
  344.             Level.Game.WorldLog.LogItemActivate(Self, Pawn(Owner));
  345.  
  346.         Pawn(Owner).ClientMessage(ItemName$M_Activated);
  347.         GoToState('Activated');
  348.     }
  349. }
  350.  
  351. //
  352. // Function which lets existing items in a pawn's inventory
  353. // prevent the pawn from picking something up. Return true to abort pickup
  354. // or if item handles pickup, otherwise keep going through inventory list.
  355. //
  356. function bool HandlePickupQuery( inventory Item )
  357. {
  358.     if ( Item.Class == Class )
  359.         return true;
  360.     if ( Inventory == None )
  361.         return false;
  362.  
  363.     return Inventory.HandlePickupQuery(Item);
  364. }
  365.  
  366. //
  367. // Select first activatable item.
  368. //
  369. function Inventory SelectNext()
  370. {
  371.     if ( bActivatable )
  372.     {
  373.         Pawn(Owner).ClientMessage(ItemName$M_Selected);
  374.         return self;
  375.     }
  376.     if ( Inventory != None )
  377.         return Inventory.SelectNext();
  378.     else
  379.         return None;
  380. }
  381.  
  382. //
  383. // Toss this item out.
  384. //
  385. function DropFrom(vector StartLocation)
  386. {
  387.     if ( !SetLocation(StartLocation) )
  388.         return;
  389.     RespawnTime = 0.0; //don't respawn
  390.     SetPhysics(PHYS_Falling);
  391.     RemoteRole = ROLE_DumbProxy;
  392.     BecomePickup();
  393.     NetPriority = 6;
  394.     bCollideWorld = true;
  395.     if ( Pawn(Owner) != None )
  396.         Pawn(Owner).DeleteInventory(self);
  397.     GotoState('PickUp', 'Dropped');
  398. }
  399.  
  400. //=============================================================================
  401. // Capabilities: For feeding general info to bots.
  402.  
  403. // For future use.
  404. function float InventoryCapsFloat( name Property, pawn Other, actor Test );
  405. function string InventoryCapsString( name Property, pawn Other, actor Test );
  406.  
  407. //=============================================================================
  408. // Firing/using.
  409.  
  410. // Fire functions which must be implemented in child classes.
  411. function Fire( float Value );
  412. function AltFire( float Value );
  413. function Use( pawn User );
  414.  
  415. //=============================================================================
  416. // Weapon functions.
  417.  
  418. //
  419. // Find a weapon in inventory that has an Inventory Group matching F.
  420. //
  421.  
  422. function Weapon WeaponChange( byte F )
  423. {
  424.     if ( Inventory == None)
  425.         return None;
  426.     else
  427.         return Inventory.WeaponChange( F );
  428. }
  429.  
  430. //=============================================================================
  431. // Armor functions.
  432.  
  433. //
  434. // Scan the player's inventory looking for items that reduce damage
  435. // to the player.  If Armor's protection type matches DamageType, then no damage is taken.
  436. // Returns the reduced damage.
  437. //
  438. function int ReduceDamage( int Damage, name DamageType, vector HitLocation )
  439. {
  440.     local Inventory FirstArmor;
  441.     local int ReducedAmount;
  442.  
  443.     if ( Damage<0 )
  444.         return 0;
  445.  
  446.     ReducedAmount = Damage;
  447.     FirstArmor = PrioritizeArmor(Damage, DamageType, HitLocation);
  448.     while ( (FirstArmor != None) && (ReducedAmount > 0) )
  449.     {
  450.         ReducedAmount = FirstArmor.ArmorAbsorbDamage(ReducedAmount, DamageType, HitLocation);
  451.         FirstArmor = FirstArmor.nextArmor;
  452.     }
  453.     return ReducedAmount;
  454. }
  455.  
  456. //
  457. // Return the best armor to use.
  458. //
  459. function inventory PrioritizeArmor( int Damage, name DamageType, vector HitLocation )
  460. {
  461.     local Inventory FirstArmor, InsertAfter;
  462.  
  463.     if ( Inventory != None )
  464.         FirstArmor = Inventory.PrioritizeArmor(Damage, DamageType, HitLocation);
  465.     else
  466.         FirstArmor = None;
  467.  
  468.     if ( bIsAnArmor)
  469.     {
  470.         if ( FirstArmor == None )
  471.         {
  472.             nextArmor = None;
  473.             return self;
  474.         }
  475.  
  476.         // insert this armor into the prioritized armor list
  477.         if ( FirstArmor.ArmorPriority(DamageType) < ArmorPriority(DamageType) )
  478.         {
  479.             nextArmor = FirstArmor;
  480.             return self;
  481.         }
  482.         InsertAfter = FirstArmor;
  483.         while ( (InsertAfter.nextArmor != None)
  484.                 && (InsertAfter.nextArmor.ArmorPriority(DamageType) > ArmorPriority(DamageType)) )
  485.             InsertAfter = InsertAfter.nextArmor;
  486.  
  487.         nextArmor = InsertAfter.nextArmor;
  488.         InsertAfter.nextArmor = self;
  489.     }
  490.     return FirstArmor;
  491. }
  492.  
  493. //
  494. // Absorb damage.
  495. //
  496. function int ArmorAbsorbDamage(int Damage, name DamageType, vector HitLocation)
  497. {
  498.     local int ArmorDamage;
  499.  
  500.     if ( DamageType != 'Drowned' )
  501.         ArmorImpactEffect(HitLocation);
  502.     if ( (DamageType!='None') && ((ProtectionType1==DamageType) || (ProtectionType2==DamageType)) )
  503.         return 0;
  504.  
  505.     if (DamageType=='Drowned') Return Damage;
  506.  
  507.     ArmorDamage = (Damage * ArmorAbsorption) / 100;
  508.     if ( ArmorDamage >= Charge )
  509.     {
  510.         ArmorDamage = Charge;
  511.         Destroy();
  512.     }
  513.     else
  514.         Charge -= ArmorDamage;
  515.     return (Damage - ArmorDamage);
  516. }
  517.  
  518. //
  519. // Return armor value.
  520. //
  521. function int ArmorPriority(name DamageType)
  522. {
  523.     if ( DamageType == 'Drowned' )
  524.         return 0;
  525.     if ( (DamageType!='None')
  526.             && ((ProtectionType1==DamageType) || (ProtectionType2==DamageType)) )
  527.         return 1000000;
  528.  
  529.     return AbsorptionPriority;
  530. }
  531.  
  532. //
  533. // This function is called by ArmorAbsorbDamage and displays a visual effect
  534. // for an impact on an armor.
  535. //
  536. function ArmorImpactEffect(vector HitLocation) { }
  537.  
  538. //
  539. // Used to inform inventory when owner jumps.
  540. //
  541. function OwnerJumped()
  542. {
  543.     if ( Inventory != None )
  544.         Inventory.OwnerJumped();
  545. }
  546.  
  547. //
  548. // Used to inform inventory when owner weapon changes.
  549. //
  550. function ChangedWeapon()
  551. {
  552.     if ( Inventory != None )
  553.         Inventory.ChangedWeapon();
  554. }
  555.  
  556. // used to ask inventory if it needs to affect its owners display properties
  557. function SetOwnerDisplay()
  558. {
  559.     if ( Inventory != None )
  560.         Inventory.SetOwnerDisplay();
  561. }
  562.  
  563. //=============================================================================
  564. // Pickup state: this inventory item is sitting on the ground.
  565.  
  566. auto state Pickup
  567. {
  568.     singular function ZoneChange( ZoneInfo NewZone )
  569.     {
  570.         local float splashsize;
  571.         local actor splash;
  572.  
  573.         if ( NewZone.bWaterZone && !Region.Zone.bWaterZone )
  574.         {
  575.             splashSize = 0.000025 * Mass * (250 - 0.5 * Velocity.Z);
  576.             if ( NewZone.EntrySound != None )
  577.                 PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize);
  578.             if ( NewZone.EntryActor != None )
  579.             {
  580.                 splash = Spawn(NewZone.EntryActor);
  581.                 if ( splash != None )
  582.                     splash.DrawScale = 2 * splashSize;
  583.             }
  584.         }
  585.     }
  586.  
  587.     // Validate touch, and if valid trigger event.
  588.     function bool ValidTouch( actor Other )
  589.     {
  590.         local Actor A;
  591.  
  592.         if ( Other.bIsPawn && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0) && Level.Game.PickupQuery(Pawn(Other), self) )
  593.         {
  594.             if ( Event != '' )
  595.                 foreach AllActors( class 'Actor', A, Event )
  596.                 A.Trigger( Other, Other.Instigator );
  597.             return true;
  598.         }
  599.         return false;
  600.     }
  601.  
  602.     // When touched by an actor.
  603.     function Touch( actor Other )
  604.     {
  605.         // If touched by a player pawn, let him pick this up.
  606.         if ( ValidTouch(Other) )
  607.         {
  608.             if (Level.Game.LocalLog != None)
  609.                 Level.Game.LocalLog.LogPickup(Self, Pawn(Other));
  610.             if (Level.Game.WorldLog != None)
  611.                 Level.Game.WorldLog.LogPickup(Self, Pawn(Other));
  612.             SpawnCopy(Pawn(Other));
  613.             Pawn(Other).ClientMessage(PickupMessage, 'Pickup');
  614.             PlaySound (PickupSound);
  615.             if ( Level.Game.Difficulty > 1 )
  616.                 Other.MakeNoise(0.1 * Level.Game.Difficulty);
  617.         }
  618.     }
  619.  
  620.     // Landed on ground.
  621.     function Landed(Vector HitNormal)
  622.     {
  623.         local rotator newRot;
  624.         newRot = Rotation;
  625.         newRot.pitch = 0;
  626.         SetRotation(newRot);
  627.         SetTimer(2.0, false);
  628.     }
  629.  
  630.     // Make sure no pawn already touching (while touch was disabled in sleep).
  631.     function CheckTouching()
  632.     {
  633.         local Pawn P;
  634.  
  635.         SetLocation(Location); // Update touchlist
  636.         bSleepTouch = false;
  637.         foreach TouchingActors(Class'Pawn',P)
  638.             Touch(P);
  639.     }
  640.  
  641.     function Timer()
  642.     {
  643.         if ( RemoteRole != ROLE_SimulatedProxy )
  644.         {
  645.             NetPriority = 2;
  646.             RemoteRole = ROLE_SimulatedProxy;
  647.             if (Physics == PHYS_Falling)
  648.                 bSimulatedPawnRep = true;
  649.             if ( bHeldItem )
  650.                 SetTimer(40.0, false);
  651.             return;
  652.         }
  653.  
  654.         if ( bHeldItem )
  655.             Destroy();
  656.     }
  657.  
  658.     function BeginState()
  659.     {
  660.         BecomePickup();
  661.         bCollideWorld = true;
  662.         if ( bHeldItem )
  663.             SetTimer(45, false);
  664.         else
  665.             SetTimer(0, false);
  666.     }
  667.  
  668.     function EndState()
  669.     {
  670.         if (Physics != PHYS_Falling)
  671.             bCollideWorld = false;
  672.         bSleepTouch = false;
  673.     }
  674.  
  675.     function Reset()
  676.     {
  677.         if( bHeldItem )
  678.             Destroy();
  679.     }
  680.  
  681. Begin:
  682.     BecomePickup();
  683.     if ( bRotatingPickup && (Physics != PHYS_Falling) )
  684.         SetPhysics(PHYS_Rotating);
  685.  
  686. Dropped:
  687.     if ( bAmbientGlow )
  688.         AmbientGlow=255;
  689.     if ( bSleepTouch )
  690.         CheckTouching();
  691. }
  692.  
  693. //=============================================================================
  694. // Active state: this inventory item is armed and ready to rock!
  695.  
  696. state Activated
  697. {
  698.     function BeginState()
  699.     {
  700.         bActive = true;
  701.         if ( Pawn(Owner).bIsPlayer && (ProtectionType1 != '') )
  702.             Pawn(Owner).ReducedDamageType = ProtectionType1;
  703.     }
  704.  
  705.     function EndState()
  706.     {
  707.         bActive = false;
  708.         if ( (Pawn(Owner) != None)
  709.                 && Pawn(Owner).bIsPlayer && (ProtectionType1 != '') )
  710.             Pawn(Owner).ReducedDamageType = '';
  711.     }
  712.  
  713.     function Activate()
  714.     {
  715.         if (Level.Game.LocalLog != None)
  716.             Level.Game.LocalLog.LogItemDeactivate(Self, Pawn(Owner));
  717.         if (Level.Game.WorldLog != None)
  718.             Level.Game.WorldLog.LogItemDeactivate(Self, Pawn(Owner));
  719.  
  720.         if ( Pawn(Owner) != None )
  721.             Pawn(Owner).ClientMessage(ItemName$M_Deactivated);
  722.         GoToState('DeActivated');
  723.     }
  724. }
  725.  
  726. //=============================================================================
  727. // Sleeping state: Sitting hidden waiting to respawn.
  728.  
  729. State Sleeping
  730. {
  731.     ignores Touch;
  732.  
  733.     function BeginState()
  734.     {
  735.         BecomePickup();
  736.         bHidden = true;
  737.     }
  738.     function EndState()
  739.     {
  740.         local Pawn P;
  741.  
  742.         bSleepTouch = false;
  743.         foreach TouchingActors(Class'Pawn',P)
  744.             bSleepTouch = true;
  745.     }
  746.     function Reset()
  747.     {
  748.         GoToState( 'Pickup' );
  749.     }
  750. Begin:
  751.     Sleep( ReSpawnTime );
  752.     PlaySound( RespawnSound );
  753.     Sleep( Level.Game.PlaySpawnEffect(self) );
  754.     GoToState( 'Pickup' );
  755. }
  756.  
  757. function ActivateTranslator(bool bHint)
  758. {
  759.     if ( Inventory!=None )
  760.         Inventory.ActivateTranslator( bHint );
  761. }
  762.  
  763. //
  764. // Null state.
  765. //
  766. State Idle2
  767. {
  768. }
  769.  
  770. // Spawn any missing markers.
  771. function NotifyPathDefine( bool bPreNotify )
  772. {
  773.     local vector HL,HN;
  774.  
  775.     if( bNoInventoryMarker )
  776.     {
  777.         if( myMarker!=None )
  778.             myMarker.Destroy();
  779.         myMarker = None;
  780.     }
  781.     else if( !bPreNotify )
  782.     {
  783.         if( myMarker==None || myMarker.bDeleteMe || myMarker.markedItem!=Self )
  784.             myMarker = Spawn(Class'InventorySpot',,,,rot(0,0,0));
  785.         myMarker.markedItem = Self;
  786.  
  787.         // Move inventory spot above floor.
  788.         if( Trace(HL,HN,Location-vect(0,0,32),Location,false)!=None )
  789.             HL.Z += myMarker.CollisionHeight;
  790.         else HL = Location;
  791.         myMarker.SetLocation(HL);
  792.         myMarker.bHiddenEd = true;
  793.     }
  794. }
  795.  
  796. defaultproperties
  797. {
  798.                 bRepMuzzleFlash=True
  799.                 bRepPlayerView=True
  800.                 bFirstFrame=True
  801.                 bToggleSteadyFlash=True
  802.                 bAmbientGlow=True
  803.                 bRotatingPickup=True
  804.                 PickupMessage="Snagged an item"
  805.                 ItemArticle="a"
  806.                 PlayerViewScale=1.000000
  807.                 BobDamping=0.960000
  808.                 PickupViewScale=1.000000
  809.                 ThirdPersonScale=1.000000
  810.                 MaxDesireability=0.005000
  811.                 M_Activated=" activated"
  812.                 M_Selected=" selected"
  813.                 M_Deactivated=" deactivated"
  814.                 bIsItemGoal=True
  815.                 bTravel=True
  816.                 bCollideActors=True
  817.                 bFixedRotationDir=True
  818.                 RemoteRole=ROLE_SimulatedProxy
  819.                 DrawType=DT_Mesh
  820.                 Texture=Texture'Engine.S_Inventory'
  821.                 AmbientGlow=255
  822.                 CollisionRadius=30.000000
  823.                 CollisionHeight=30.000000
  824.                 RotationRate=(Yaw=5000)
  825.                 DesiredRotation=(Yaw=30000)
  826.                 NetPriority=2.000000
  827. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement