## XIII
Class Keys

source: C:\XIII\XIII\Classes\Keys.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Inventory
             |
             +--Engine.Powerups
                |
                +--XIII.XIIIItems
                   |
                   +--XIII.Keys

Direct Known Subclasses:PRock01aCorridorKey, PRock01aRotondeExitKey, PRock01aRotondeKey, PRock01aStairsKey, PRock03CellKey, Palace1BRoom41Key, Plage01CahuteKey, Plage01UselessKey, SM02Key, Spads03BossKey, USA02PortKey, LockPick

class Keys
extends XIII.XIIIItems

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`String` | `KeyCodeName`
`bool` | `bDestroyAfterDownEnd` destroy the key after the down end (no more use for this key)
`bool` | `bPicking` to validate the beginning of the picking process
`bool` | `bUsed` to activate alt set of anims w/ tool in place

States
for, DownItem, UsingEnd, idle, InUse

Function Summary
`bool` | `HandlePickupQuery(Pickup Item)`
    //_____________________________________________________________________________
`void` | `UseMe()`
    //_____________________________________________________________________________
    // ELR

State for Function Summary
`void` | `PlayUsingEnd()`
    //_____________________________________________________________________________

State DownItem Function Summary

State UsingEnd Function Summary

State idle Function Summary

State InUse Function Summary
`void` | `Activate()`

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class Keys extends XIIIItems;
    00005
    00006	var Travel String KeyCodeName;
    00007
    00008	var bool bPicking;  // to validate the beginning of the picking process
    00009	var bool bUsed;     // to activate alt set of anims w/ tool in place
    00010	var bool bDestroyAfterDownEnd;  // destroy the key after the down end (no more use for this key)
    00011
    00012	//_____________________________________________________________________________
    00013	function bool HandlePickupQuery( Pickup Item )
    00014	{
    00015	    //Default = always allowed to have multiple copies (multiple events)
    00016	    if ( Inventory == None )
    00017	      return false;
    00018
    00019	    return Inventory.HandlePickupQuery(Item);
    00020	}
    00021
    00022	//_____________________________________________________________________________
    00023	// ELR
    00024	function UseMe()
    00025	{
    00026	//    log("UseMe Call for "$self);
    00027	    if ( !XIIIPlayerController(XIIIpawn(Owner).controller).TryPickLock() )
    00028	      GotoState('Idle');
    00029	}
    00030
    00031	//_____________________________________________________________________________
    00032	State InUse
    00033	{
    00034	    event BeginState()
    00035	    {
    00036	      PlayUsing();
    00037	      UseMe();
    00038	    }
    00039
    00040	    event EndState()
    00041	    {
    00042	      bPicking = false;
    00043	    }
    00044
    00045	    function Activate() {}
    00046
    00047	    simulated event AnimEnd(int Channel)
    00048	    {
    00049	      if ( bChangeItem )
    00050	      {
    00051	        XIIIPlayerController(XIIIpawn(Owner).controller).CancelPickLock();
    00052	        GotoState('DownItem');
    00053	        return;
    00054	      }
    00055	      if ( !bPicking )
    00056	      {
    00057	        bPicking = true;
    00058	//        UseMe();
    00059	//        enable('tick');
    00060	      }
    00061	      PlayUsing();
    00062	    }
    00063
    00064	    event Tick(float dT)
    00065	    {
    00066	//      log("Tick Call for "$self);
    00067	      if ( XIIIPlayerController(XIIIpawn(Owner).controller).CheckPickLock() )
    00068	      {
    00069	        PlayUsingEnd();
    00070	        GotoState('UsingEnd');
    00071	      }
    00072	    }
    00073	}
    00074
    00075	//_____________________________________________________________________________
    00076	state idle
    00077	{
    00078	    simulated function Activate()
    00079	    {
    00080	      if ( !XIIIPlayerController(XIIIpawn(Owner).controller).CanUseLockPick() )
    00081	        return;
    00082	      if ( XIIIPawn(Owner).bHaveOnlyOneHandFree && (IHand == IH_2H) )
    00083	        PlayerController(Pawn(owner).controller).MyHud.LocalizedMessage(class'XIIISoloMessage', 8);
    00084	      else
    00085	        GotoState('InUse');
    00086	    }
    00087	}
    00088
    00089	//_____________________________________________________________________________
    00090	State UsingEnd
    00091	{
    00092	    ignores Activate;
    00093
    00094	    event AnimEnd(int channel)
    00095	    {
    00096	      local XIIIPorte PorteTmp;
    00097	      local bool bPorteTrouvee; // I assume that is false by default
    00098
    00099	      DebugLog("  > UsingEnd AnimEnd for "$self);
    00100
    00101	      foreach DynamicActors(class'XIIIPorte',PorteTmp)
    00102	      {
    00103	        if ((PorteTmp.GetStateName() == 'locked')
    00104	          && (PorteTmp.UnlockItemCode == KeyCodeName))
    00105	        {
    00106	          bPorteTrouvee = true;
    00107	          break;
    00108	        }
    00109	      }
    00110	      if (!bPorteTrouvee)
    00111	      {
    00112	        if ( Pawn(Owner) != None )
    00113	        {
    00114	          XIIIPlayercontroller(XIIIPawn(Owner).controller).NextWeapon();
    00115	//          XIIIPawn(Owner).ChangedWeapon(); // ELR don't need as sent when down animend
    00116	        }
    00117	        bDestroyAfterDownEnd = true;
    00118	        bDisplayableInv = false;
    00119	        bActivatable = false;
    00120	        GotoState('DownItem');
    00121	        return;
    00122	      }
    00123	      if ( bChangeItem )
    00124	      {
    00125	        GotoState('DownItem');
    00126	        return;
    00127	      }
    00128	      GotoState('Idle');
    00129	    }
    00130	}
    00131
    00132	//_____________________________________________________________________________
    00133	state DownItem
    00134	{
    00135	    simulated function BeginState()
    00136	    {
    00137	      DebugLog("  > DownItem BeginState for "$self);
    00138	      PlayDown();
    00139	      EndUse();
    00140	    }
    00141
    00142	    simulated event AnimEnd(int Channel)
    00143	    {
    00144	      DebugLog("  > DownItem AnimEnd for "$self@"bDestroyAfterDownEnd="$bDestroyAfterDownEnd);
    00145	      if ( bDestroyAfterDownEnd )
    00146	      {
    00147	        if ( Pawn(Owner).SelectedItem == self )
    00148	          Pawn(Owner).SelectedItem = none;
    00149	        if ( Pawn(Owner).PendingItem == self )
    00150	          Pawn(Owner).PendingItem = none;
    00151	        Pawn(Owner).ChangedWeapon();
    00152	        Destroy();
    00153	        return;
    00154	      }
    00155	//      Log("DownItem AnimEnd");
    00156	      bChangeItem = false;
    00157	      GotoState('');
    00158	      Pawn(Owner).ChangedWeapon();
    00159	      if ( (Pawn(Owner).SelectedItem != self) || XIIIPlayerController(Pawn(Owner).Controller).bWeaponMode )
    00160	      {
    00161	        bRendered = false;
    00162	        bHidden = true;
    00163	        RefreshDisplaying();
    00164	      }
    00165	    }
    00166
    00167	    simulated function Activate() {}
    00168	}
    00169
    00170	//_____________________________________________________________________________
    00171	simulated function PlayUsing()
    00172	{
    00173	    PlayAnim('Fire', 2.0);
    00174	}
    00175
    00176	//_____________________________________________________________________________
    00177	function PlayUsingEnd()
    00178	{
    00179	    TweenAnim('Wait', 0.2);
    00180	}
    00181
    00182
    00183
    00184	defaultproperties
    00185	{
    00186	     KeyCodeName="DEFAULTKEY"
    00187	     MeshName="XIIIDeco.FPSClefM"
    00188	     hSelectItemSound=Sound'XIIIsound.Items.LockSel1'
    00189	     IconNumber=22
    00190	     sItemName="Key"
    00191	     bAutoActivate=True
    00192	     bActivatable=True
    00193	     ExpireMessage="Key was used."
    00194	     ActivateSound=Sound'XIIIsound.Items.LockFire1'
    00195	     InventoryGroup=4
    00196	     bDisplayableInv=True
    00197	     PickupClass=Class'XIII.KeyPicks'
    00198	     Charge=1
    00199	     PlayerViewOffset=(X=12.000000,Y=3.000000,Z=-8.000000)
    00200	     ItemName="Key"
    00201	}

End Source Code