XIII
Class Hook

source: C:\XIII\XIII\Classes\Hook.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Powerups
            |
            +--XIII.XIIIItems
               |
               +--XIII.Hook
Direct Known Subclasses:None

class Hook
extends XIII.XIIIItems

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 bool ActivatedByAltFire
           used for playing animation chain (firing then down then selectcommande)
 bool ActivatedByDuck
           used for playing animation chain (firing then down then selectcommande)
 bool ActivatedByFire
           used for playing animation chain (firing then down then selectcommande)
 bool ActivatedByJump
           used for playing animation chain (firing then down then selectcommande)
 int AnimState
           used for playing animation chain (firing then down then selectcommande)
 HookUpSpeed, HookDownSpeed
           Speed we are climbing/dropping while hooked
 InventoryAttachment HookHarn
           Used for rope visual
 float HookLength
           Position on the Rope to the HookPoint
 InventoryAttachment HookMec
           Used for rope visual
 float HookMecPrep
           -//-, make the hookmec go out smoothly when activated
 float HookMecRot
           -//-, make the hookmec rotate according to movement
 vector HookPoint
           Hooking point
 float HookSpring
           -//-, make the hookmec move up/down if going up/down
 float MaxHookLength
           Max Lenght of the Hook Rope
 HookProjectile MyHook
           If there is a Hookpoint in the Crosshair
 HookLink MyLink
           If there is a Hookpoint in the Crosshair
 Texture PotHookIcon
           Icon to use to display the potential hook points on screen
 HookPoint PotHookPoint
           If there is a Hookpoint in the Crosshair
 array PotentialHP
           Array of potentials HP in the level
 bGoUp, bGoDown
           Speed we are climbing/dropping while hooked
 bool bHooked
           used for playing right animations
 bool bMirrored
           used for playing animation chain (firing then down then selectcommande)
 sound hHookClik
           Icon to use to display the potential hook points on screen
 sound hHookEndSound
           Icon to use to display the potential hook points on screen
 sound hHookFireSound
           Icon to use to display the potential hook points on screen
 sound hHookMoveSound
           Icon to use to display the potential hook points on screen
 sound hHookReleaseSound
           Icon to use to display the potential hook points on screen
 vector tV
           used for playing animation chain (firing then down then selectcommande)

States
for, DownItemRopeCut, ActivatedHookInUse, for, ActivatedHookInUse, DownHookInUse, for, IdleHookInUse, DownHookInUse, for, DownHookInUse, HookInUse, for, HookInUse, for, Idle, for, Activated

Function Summary
 
simulated
DrawTargets(Canvas C)
     
//_____________________________________________________________________________
 
simulated
GetLinksCoords(out vector, out vector, out Vector, out Vector)
     
//_____________________________________________________________________________
// ELR
 
simulated
InitPotentialTargets()
     
//_____________________________________________________________________________
 
simulated
OutlinePotentialTarget(Canvas C)
     
//_____________________________________________________________________________
 void Release()
     
//_____________________________________________________________________________
// Onyl used while active
 void ResetPotentialTargets()
     
//_____________________________________________________________________________
// Used to reset coll size when releasing hook
 void StaticParseDynamicLoading(LevelInfo MyLI)
     
//_____________________________________________________________________________
 
simulated
UseMe()
     
//_____________________________________________________________________________


State for Function Summary


State DownItemRopeCut Function Summary


State ActivatedHookInUse Function Summary


State for Function Summary
 void Release()


State ActivatedHookInUse Function Summary


State DownHookInUse Function Summary


State for Function Summary
 void Release()


State IdleHookInUse Function Summary


State DownHookInUse Function Summary


State for Function Summary
 void Release()


State DownHookInUse Function Summary


State HookInUse Function Summary
 void Timer()
 void Tick(float DeltaTime)


State for Function Summary
 void Activate()
 void Release()
 void IncreaseRopeLength(float DT)
 void ReduceRopeLength(float DT)
 void EndState()


State HookInUse Function Summary
 void BeginState()


State for Function Summary
 void Activate()


State Idle Function Summary


State for Function Summary


State Activated Function Summary



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class Hook extends XIIIItems;
00005	
00006	var HookPoint PotHookPoint;     // If there is a Hookpoint in the Crosshair
00007	
00008	var HookProjectile MyHook;
00009	var HookLink MyLink;
00010	//var FreeHookLink MyFHLink;
00011	
00012	var vector HookPoint;           // Hooking point
00013	var float HookLength;           // Position on the Rope to the HookPoint
00014	var float MaxHookLength;        // Max Lenght of the Hook Rope
00015	var float HookUpSpeed, HookDownSpeed;   // Speed we are climbing/dropping while hooked
00016	var bool bGoUp, bGoDown;
00017	
00018	var array<hookpoint> PotentialHP;   // Array of potentials HP in the level
00019	var texture PotHookIcon;            // Icon to use to display the potential hook points on screen
00020	
00021	var sound hHookMoveSound;
00022	var sound hHookEndSound;
00023	var sound hHookFireSound;
00024	var sound hHookReleaseSound;
00025	var sound hHookClik;
00026	
00027	var bool bHooked;               // used for playing right animations
00028	var int AnimState;              // used for playing animation chain (firing then down then selectcommande)
00029	
00030	var bool ActivatedByJump;
00031	var bool ActivatedByDuck;
00032	var bool ActivatedByAltFire;
00033	var bool ActivatedByFire;
00034	var bool bMirrored;
00035	var vector tV;
00036	
00037	var InventoryAttachment HookMec;  // Used for rope visual
00038	var InventoryAttachment HookHarn; // Used for rope visual
00039	var float HookSpring;             // -//-, make the hookmec move up/down if going up/down
00040	var float HookMecRot;             // -//-, make the hookmec rotate according to movement
00041	var float HookMecPrep;            // -//-, make the hookmec go out smoothly when activated
00042	
00043	//var localized string sHooked, sHookUp, sHookDown;
00044	
00045	CONST DBHook=false;
00046	
00047	//_____________________________________________________________________________
00048	Static function StaticParseDynamicLoading(LevelInfo MyLI)
00049	{
00050	    Log("Hook StaticParseDynamicLoading class="$default.class);
00051	    Super.StaticParseDynamicLoading(MyLI);
00052	    MyLI.ForcedMeshes[MyLI.ForcedMeshes.Length] =
00053	      Mesh(DynamicLoadObject(default.MeshName, class'mesh'));
00054	    MyLI.ForcedStaticMeshes[MyLI.ForcedStaticMeshes.Length] =
00055	      StaticMesh(DynamicLoadObject("MeshArmesPickup.Grappin_harnais", class'StaticMesh'));
00056	    MyLI.ForcedStaticMeshes[MyLI.ForcedStaticMeshes.Length] =
00057	      StaticMesh(DynamicLoadObject("MeshArmesPickup.Grappin_moulinet", class'StaticMesh'));
00058	}
00059	
00060	//_____________________________________________________________________________
00061	// ELR Add displayfov and bWeaponMode
00062	simulated event RenderOverlays( canvas Canvas )
00063	{
00064	    if ( bRendered && bHidden )
00065	    {
00066	      bHidden = false;
00067	      RefreshDisplaying();
00068	    }
00069	
00070	    if ( !XIIIPlayerController(Pawn(Owner).Controller).bWeaponMode )
00071	    {
00072	      if ( (Instigator == None) || (Instigator.Controller == None))
00073	        return;
00074	      SetLocation( Instigator.Location + Instigator.CalcDrawOffset(self) );
00075	      SetRotation( Instigator.GetViewRotation() );
00076	      SetBase(Pawn(Owner).Controller);
00077	      DrawTargets(Canvas);
00078	    }
00079	}
00080	
00081	/*
00082	//_____________________________________________________________________________
00083	// ELR
00084	simulated function GetLinksCoords(out vector S1, out vector E1, out Vector S2, out Vector E2);
00085	*/
00086	
00087	//_____________________________________________________________________________
00088	simulated function DrawTargets(Canvas C)
00089	{
00090	    if ( (XIIIPlayerController(Pawn(Owner).Controller).MyInteraction.TargetActor != none) && !XIIIPlayerController(Pawn(Owner).Controller).MyInteraction.TargetActor.bDeleteMe )
00091	      PotHookPoint = HookPoint(XIIIPlayerController(Pawn(Owner).Controller).MyInteraction.TargetActor);
00092	    else
00093	      PotHookPoint = none;
00094	//    if ( PotHookPoint != none )
00095	//      Log("POTHOOK Radius"@PotHookPoint.CollisionRadius@"x"@PotHookPoint.CollisionHeight);
00096	    if ( !IsInState('HookInUse') && (PotHookPoint == none) )
00097	      OutlinePotentialTarget(C);
00098	}
00099	
00100	//_____________________________________________________________________________
00101	// Used to reset coll size when releasing hook
00102	function ResetPotentialTargets()
00103	{
00104	    local int i;
00105	    local vector V;
00106	
00107	    if ( PotentialHP.Length > 0 )
00108	    {
00109	      for (i=0;i<PotentialHP.Length;i++)
00110	      {
00111	        // Reset collision size of hookpoints
00112	        PotentialHP[i].SetCollisionSize(PotentialHP[i].Default.CollisionRadius, PotentialHP[i].Default.CollisionHeight);
00113	      }
00114	    }
00115	}
00116	
00117	//_____________________________________________________________________________
00118	simulated function OutlinePotentialTarget(Canvas C)
00119	{
00120	    local int i;
00121	    local vector V, hitLoc, HitNorm;
00122	    local material HitMat;
00123	    local actor A;
00124	
00125	    if ( PotentialHP.Length > 0 )
00126	    {
00127	      for (i=0;i<PotentialHP.Length;i++)
00128	      {
00129	        A = Trace(HitLoc, HitNorm,
00130	          PotentialHP[i].Location, Location,
00131	          false,
00132	          vect(0,0,0),
00133	          HitMat,
00134	          TRACETYPE_DiscardIfCanShootThroughWithRayCastingWeapon);
00135	        if ( PotentialHP[i].bInteractive && (A == none)
00136	        && ( vector(Pawn(Owner).Controller.Rotation) dot (PotentialHP[i].Location - Location) > 0.707 )
00137	          )
00138	        {
00139	          // Try setting collision size of hookpoints to grow w/ distance to player
00140	          PotentialHP[i].SetCollisionSize(
00141	            Max(PotentialHP[i].Default.CollisionRadius, vSize(Location - PotentialHP[i].Location) / 500.0 * PotentialHP[i].Default.CollisionRadius),
00142	            Max(PotentialHP[i].Default.CollisionHeight, vSize(Location - PotentialHP[i].Location) / 500.0 * PotentialHP[i].Default.CollisionHeight)
00143	            );
00144	          //
00145	          V = XIIIPlayerController(Pawn(Owner).Controller).Player.Console.WorldToScreen(PotentialHP[i].Location);
00146	          C.SetPos(V.X - PotHookIcon.USize/4.0, V.Y - PotHookIcon.VSize/4.0);
00147	          C.Style = ERenderStyle.STY_Alpha;
00148	          if ( VSize(PotentialHP[i].Location - Pawn(Owner).Location) + 50.0 > PotentialHP[i].RopeLength )
00149	            C.SetDrawColor(255,0,0,255);
00150	          else
00151	            C.SetDrawColor(255,255,255,255);
00152	//          C.DrawTile(PotHookIcon, PotHookIcon.USize, PotHookIcon.VSize, 0, 0, PotHookIcon.USize, PotHookIcon.VSize);
00153	          C.DrawIcon(PotHookIcon, 0.5);
00154	//          Log("Potential HP target="$PotentialHP[i]);
00155	        }
00156	      }
00157	    }
00158	}
00159	
00160	//_____________________________________________________________________________
00161	simulated function InitPotentialTargets()
00162	{
00163	    local HookPoint HP;
00164	
00165	    PotentialHP.Length = 0; // Clean Array
00166	    foreach AllActors(class'HookPoint', HP)
00167	      if ( HP != none )
00168	      {
00169	        PotentialHP.Length = PotentialHP.Length + 1;
00170	        PotentialHP[PotentialHP.Length - 1] = Hp;
00171	      }
00172	}
00173	
00174	//_____________________________________________________________________________
00175	Simulated function UseMe()
00176	{
00177	//    if ( TryHooking() )
00178	    if ( DBHook ) log(self@"UseMe, PotHookPoint="$PotHookPoint);
00179	
00180	    if ( PotHookPoint != none )
00181	    {
00182	      HookPoint = PotHookPoint.Location;
00183	      PotHookPoint.SetCollisionSize(PotHookPoint.Default.CollisionRadius/2.0, PotHookPoint.Default.CollisionHeight/2.0);
00184	      HookLength = VSize(HookPoint - Pawn(Owner).Location) + 50.0;
00185	      MaxHookLength = PotHookPoint.RopeLength;
00186	      if ( MaxHookLength < HookLength ) // Too far away
00187	        return;
00188	//      log("    HookLength="$HookLength@"MaxHookLength="$MaxHookLength);
00189	
00190	//      MyHook=Spawn(class'HookProjectile',,, Owner.Location + Instigator.CalcDrawOffset(self),Rotator(HookPoint-Location));
00191	//    PlayerViewOffset=(X=5.00,Y=6.00,Z=-5.80)
00192	      PlayerViewOffset = vect(8.0, 4.0, -5.8);
00193	      MyHook=Spawn(class'HookProjectile',,, Owner.Location + Instigator.CalcDrawOffset(self),Rotator(HookPoint-Location));
00194	      PlayerViewOffset = default.PlayerViewOffset;
00195	      if (MyHook != none)
00196	      {
00197	        MyHook.SetOwner(self);
00198	        if ( MyLink != none )
00199	          MyLink.ForceDestroy(); // erase old link
00200	        MyLink = Spawn(class'HookLink',,, Owner.Location + Instigator.CalcDrawOffset(self),Rotator(HookPoint-Location));
00201	        if (MyLink != none)
00202	        {
00203	          MyLink.HStart = self;
00204	          MyLink.HEnd = MyHook;
00205	          MyLink.LinkIndex = 0;
00206	        }
00207	        HookMecPrep = -1.0;
00208	        if ( HookMec == none )
00209	          HookMec = spawn(class'HookMecanismAttach');
00210	        else
00211	        {
00212	          HookMec.bHidden = false;
00213	          HookMec.RefreshDisplaying();
00214	        }
00215	        if ( HookHarn == none )
00216	          HookHarn = spawn(class'HookHarnessAttach');
00217	        else
00218	        {
00219	          HookHarn.bHidden = false;
00220	          HookHarn.RefreshDisplaying();
00221	        }
00222	
00223	
00224	/*
00225	        MyFHLink=Spawn(class'FreeHookLink',,, Owner.Location + Instigator.CalcDrawOffset(self),Rotator(HookPoint-Location));
00226	        if ( MyFHLink != none )
00227	        {
00228	          MyFHLink.HStart=self;
00229	          MyFHLink.HEnd=MyHook;
00230	          MyFHLink.LinkIndex = 0;
00231	        }
00232	*/
00233	      }
00234	      PlayRolloffSound(hHookFireSound, self);
00235	      XIIIPawn(Owner).GoHooking(self);
00236	      SetTimer(0.25, false);
00237	      bHooked = true;
00238	      ActivatedByAltFire = false;
00239	      if ( !ActivatedByFire && (Pawn(Owner).Physics == PHYS_Falling) )
00240	        ActivatedByJump = true; // else we will go down non-stop until surface
00241	      else
00242	        ActivatedByJump = false;
00243	      ActivatedByDuck = false;
00244	      bGoUp = false;
00245	      PlayUsing();
00246	      GotoState('HookInUse');
00247	      if ( ActivatedByFire ) // after gotostate to change bGoDown to true
00248	        bGoDown = true;
00249	      else
00250	        bGodown = false;
00251	    }
00252	}
00253	
00254	//_____________________________________________________________________________
00255	// Onyl used while active
00256	function Release()
00257	{
00258	}
00259	
00260	//_____________________________________________________________________________
00261	event Destroyed()
00262	{
00263	    Super.Destroyed();
00264	    if ( DBHook ) log(self$" Destroyed");
00265	    if (MyHook != none)
00266	      MyHook.Destroy();
00267	    if (MyLink != none)
00268	      MyLink.Destroy();
00269	    if ( HookMec != none )
00270	      HookMec.Destroy();
00271	    if ( HookHarn != none )
00272	      HookHarn.Destroy();
00273	}
00274	
00275	//_____________________________________________________________________________
00276	state Activated
00277	{
00278	    simulated function BeginState()
00279	    {
00280	      Instigator = Pawn(Owner);
00281	      if ( DBHook ) Log(">>> Activated BeginState for "$self@"AnimState="$AnimState);
00282	      PlaySelect();
00283	      InitPotentialTargets();
00284	      bRendered = true;
00285	//      bHidden = false;
00286	//      RefreshDisplaying();
00287	      bChangeItem = false;
00288	    }
00289	}
00290	
00291	//_____________________________________________________________________________
00292	state Idle
00293	{
00294	    simulated function BeginState()
00295	    {
00296	      if ( DBHook ) Log(">>> Idle BeginState for "$self@"AnimState="$AnimState);
00297	    }
00298	    function Activate()
00299	    {
00300	      if ( DBHook ) Log("  > Idle Activate for "$self);
00301	      UseMe();
00302	    }
00303	    simulated function AnimEnd(int Channel)
00304	    {
00305	      if ( DBHook ) Log("  > Idle AnimEnd for "$self@"AnimState="$AnimState);
00306	      if (Charge <= 0)
00307	      {
00308	        UsedUp();
00309	        return;
00310	      }
00311	      if ( bChangeItem )
00312	      {
00313	        GotoState('DownItem');
00314	        return;
00315	      }
00316	      if (AnimState == 3)
00317	      {
00318	        PlaySelect();
00319	        AnimState = 0;
00320	      }
00321	      else
00322	        PlayIdle();
00323	    }
00324	    event EndState()
00325	    {
00326	      ResetPotentialTargets();
00327	    }
00328	}
00329	
00330	//_____________________________________________________________________________
00331	// In Use
00332	state HookInUse
00333	{
00334	    function BeginState()
00335	    {
00336	      if ( DBHook ) Log(">>> HookInUse BeginState for "$self@"Instigator="$Instigator);
00337	      bGoUp = false;
00338	      bGoDown = false;
00339	      disable('Tick');
00340	    }
00341	    function EndState()
00342	    {
00343	    }
00344	
00345	    simulated function AnimEnd(int Channel)
00346	    {
00347	      if ( DBHook ) Log("  > HookInUse AnimEnd AnimState="$AnimState);
00348	      if ( bChangeItem )
00349	      {
00350	        bChangeItem = false;
00351	        GotoState('DownHookInUse');
00352	        return;
00353	      }
00354	      if ( AnimState == 1 )
00355	      {
00356	        PlaySelect();
00357	        AnimState = 2;
00358	      }
00359	      else
00360	      {
00361	        if ( (AnimState == 2) && bGoUp )
00362	          PlayClimbUp();
00363	        else
00364	          PlayIdle();
00365	        AnimState = 0;
00366	      }
00367	    }
00368	
00369	    function ReduceRopeLength(float DT)
00370	    {
00371	      if ( HookLength>150 )
00372	      {
00373	        HookLength = vSize(HookPoint - Pawn(Owner).Location); // don't allow teleports
00374	        HookLength -= (DT * HookUpSpeed);
00375	        if ( HookLength<150 ) HookLength = 150;
00376	      }
00377	//      if ( DBHook ) log(" reduce HookLength="$HookLength@"DT="$DT);
00378	    }
00379	    function IncreaseRopeLength(float DT)
00380	    {
00381	      if ( (HookLength<(100+vSize(HookPoint - Pawn(Owner).Location))) && (HookLength < MaxHookLength) )
00382	      {
00383	        HookLength += (DT * HookDownSpeed);
00384	        if (HookLength > MaxHookLength) HookLength = MaxHookLength;
00385	      }
00386	//      if ( DBHook ) log(" increase HookLength="$HookLength@"DT="$DT);
00387	    }
00388	
00389	    function Release()
00390	    {
00391	      if ( DBHook ) log(self$" Released");
00392	      if (MyHook != none)
00393	        MyHook.Destroy();
00394	      if (MyLink != none)
00395	        MyLink.ShouldDestroy();
00396	/*
00397	      if (MyFHLink != none)
00398	        MyFHLink.Destroy();
00399	*/
00400	      Disable('tick');
00401	      GoToState('Idle');
00402	      StopSound(hHookMoveSound);
00403	      PlayRolloffSound(hHookReleaseSound,self);
00404	      if (AnimState != 0)
00405	        TweenDown();
00406	      else
00407	        PlayDown();
00408	      bHooked = false;
00409	      XIIIPlayerController(Instigator.Controller).bHooked = false;
00410	      bGoUp = false;
00411	      bGoDown = false;
00412	    }
00413	
00414	    function Activate()
00415	    {
00416	      if ( DBHook ) log(self$" Activated in state HookInUse");
00417	      SetTimer(0.25, false);
00418	      PlaySound(hHookClik);
00419	    }
00420	
00421	    function Tick(float DeltaTime)
00422	    {
00423	      local vector V1,V2;
00424	
00425	      if ( (Pawn(Owner).Physics==PHYS_Walking) || (Pawn(Owner).Physics == PHYS_Swimming) )
00426	      {
00427	        if ( bGoDown )
00428	        {
00429	          bGoDown = false;
00430	          disable('tick');
00431	//          ItemName = sHooked;
00432	          ActivatedByJump=false;
00433	          ActivatedByDuck=false;
00434	          ActivatedByFire=false;
00435	          ActivatedByAltFire=false;
00436	        }
00437	      }
00438	      else if ( (Pawn(Owner).Physics != PHYS_Falling) && (Pawn(Owner).Physics != PHYS_Swimming) )
00439	      {
00440	        Release();
00441	        return;
00442	      }
00443	      if ( (XIIIPlayerController(Pawn(Owner).controller).bWeaponMode) || (Pawn(Owner).SelectedItem != self) )
00444	      {
00445	        bGoUp = false;
00446	        bGoDown = false;
00447	        disable('tick');
00448	//        ItemName = sHooked;
00449	        ActivatedByJump=false;
00450	        ActivatedByDuck=false;
00451	        ActivatedByFire=false;
00452	        ActivatedByAltFire=false;
00453	      }
00454	
00455	//      log(self$" Tick w/ bGoUp="$bGoUp$" bGoDown="$bGoDown);
00456	      if ( bGoUp )
00457	      {
00458	        if ( (ActivatedByFire && Pawn(Owner).PressingFire()) || (ActivatedByJump && (XIIIPlayercontroller(Pawn(Owner).Controller).bAltJump > 0.0)) )
00459	        {
00460	          ReduceRopeLength(DeltaTime);
00461	          if ( HookLength == 150 )
00462	          {
00463	            // Should try to climb there
00464	            if ( (PotHookPoint != none) && (PotHookPoint.ClimbableHookNavPoint != none) )
00465	            {
00466	              V1 = PotHookPoint.ClimbableHookNavPoint.location - HookPoint;
00467	              V1.Z = 0.0;
00468	              V2 = Pawn(Owner).location - HookPoint;
00469	              V2.Z = 0.0;
00470	              if ( V1 dot V2 < 0.0 )
00471	              {
00472	//                log("PotHookPoint="$PotHookPoint$" HookNavPoint="$PotHookPoint.ClimbableHookNavPoint);
00473	                Release();
00474	                XIIIPlayerController(Pawn(Owner).controller).GoClimbHookNavPoint(PotHookPoint, PotHookPoint.ClimbableHookNavPoint);
00475	              }
00476	            }
00477	//            else
00478	//              log("PotHookPoint="$PotHookPoint$" no HookNavPoint, Not climbing");
00479	          }
00480	        }
00481	        else
00482	        { // stop going up as no more order is given
00483	          bGoUp = false;
00484	          bGoDown = false;
00485	          disable('tick');
00486	//          ItemName = sHooked;
00487	          StopSound(hHookMoveSound);
00488	          PlayRolloffSound(hHookEndSound, self);
00489	          PlaySound(hHookClik);
00490	          PlayStop();
00491	          ActivatedByJump=false;
00492	          ActivatedByDuck=false;
00493	          ActivatedByFire=false;
00494	          ActivatedByAltFire=false;
00495	        }
00496	      }
00497	      else if ( bGoDown )
00498	      {
00499	//        log("Tick ActivatedByDuck="$ActivatedByDuck@"bAltDuck="$XIIIPlayerController(Pawn(Owner).controller).bAltDuck);
00500	        if ( (ActivatedByAltFire && !Pawn(Owner).PressingAltFire()) || (ActivatedByDuck && (XIIIPlayerController(Pawn(Owner).controller).bAltDuck == 0.0)) )
00501	        { // stop going down as no more order is given
00502	          bGoUp = false;
00503	          bgoDown = false;
00504	          disable('Tick');
00505	//          ItemName = sHooked;
00506	          StopSound(hHookMoveSound);
00507	          PlayRolloffSound(hHookEndSound, self);
00508	          PlaySound(hHookClik);
00509	          ActivatedByJump=false;
00510	          ActivatedByDuck=false;
00511	          ActivatedByFire=false;
00512	          ActivatedByAltFire=false;
00513	        }
00514	        else
00515	          IncreaseRopeLength(DeltaTime);
00516	      }
00517	      else
00518	      {
00519	        disable('Tick');
00520	//        ItemName = sHooked;
00521	        StopSound(hHookMoveSound);
00522	        PlayRolloffSound(hHookEndSound, self);
00523	        PlaySound(hHookClik);
00524	//        ActivatedByJump=false;
00525	//        ActivatedByDuck=false;
00526	//        ActivatedByFire=false;
00527	//        ActivatedByAltFire=false;
00528	      }
00529	    }
00530	
00531	    function Timer()
00532	    {
00533	      if ( DBHook ) log(self$" timer Going UP/Down"@bGoUp@bGoDown@"Activated by Fire="$ActivatedByFire@"Duck="$ActivatedByDuck@"Jump="$ActivatedByJump@"AltFire="$ActivatedByAltFire);
00534	      if ( (ActivatedByFire && Pawn(Owner).PressingFire()) || (ActivatedByJump && (XIIIPlayercontroller(Pawn(Owner).Controller).bAltJump > 0.0)) )
00535	      { // order is given to go up
00536	        if ( bGoDown )
00537	        {
00538	          StopSound(hHookMoveSound);
00539	          PlayRolloffSound(hHookEndSound, self);
00540	        }
00541	        if ( DBHook ) log(self$" checking climbing, goin'up");
00542	        bGoUp = true;
00543	        bGoDown = false;
00544	//        ItemName = sHookUp;
00545	        enable('tick');
00546	        PlayClimbUp();
00547	        PlayRolloffSound(hHookMoveSound, self);
00548	        ActivatedByDuck=false;
00549	        ActivatedByAltFire=false;
00550	      }
00551	      else if ( (ActivatedByAltFire && Pawn(Owner).PressingAltFire()) || (ActivatedByDuck && (XIIIPlayercontroller(Pawn(Owner).Controller).bAltDuck > 0.0)) )
00552	      { // order is given to go Down
00553	        if ( bGoUp )
00554	        {
00555	          StopSound(hHookMoveSound);
00556	          PlayRolloffSound(hHookEndSound, self);
00557	        }
00558	        if ( DBHook ) log(self$" checking climbing, goin'down");
00559	        Enable('tick');
00560	//        ItemName = sHookDown;
00561	        bGoUp = false;
00562	        bGoDown = true;
00563	        PlayClimbDown();
00564	        PlayRolloffSound(hHookMoveSound, self);
00565	        ActivatedByJump=false;
00566	        ActivatedByFire=false;
00567	      }
00568	      else if ( !ActivatedByJump || ActivatedByFire )
00569	      {
00570	        if ( bGoDown )
00571	        {
00572	          if ( DBHook ) log(self$" checking climbing, stop goin'down");
00573	          Disable('tick');
00574	          bGoUp = false;
00575	          bGoDown = false;
00576	//          ItemName = sHooked;
00577	          StopSound(hHookMoveSound);
00578	          PlayRolloffSound(hHookEndSound, self);
00579	          PlayClimbDown();
00580	          ActivatedByJump=false;
00581	          ActivatedByDuck=false;
00582	        }
00583	        else
00584	        {
00585	          if ( DBHook ) log(self$" checking climbing, goin'down");
00586	          Enable('tick');
00587	//          ItemName = sHookDown;
00588	          bGoUp = false;
00589	          bGoDown = true;
00590	          PlayClimbDown();
00591	          PlayRolloffSound(hHookMoveSound, self);
00592	          ActivatedByJump=false;
00593	        }
00594	      }
00595	      else // activated by jump but jump released
00596	      {
00597	        Disable('tick');
00598	        bGoUp = false;
00599	        bGoDown = false;
00600	//        ItemName = sHooked;
00601	        StopSound(hHookMoveSound);
00602	        PlayRolloffSound(hHookEndSound, self);
00603	        PlayClimbDown();
00604	        ActivatedByJump=false;
00605	        ActivatedByDuck=false;
00606	      }
00607	    }
00608	}
00609	
00610	//_____________________________________________________________________________
00611	// In Use but down
00612	state DownHookInUse
00613	{
00614	    simulated function BeginState()
00615	    {
00616	      if ( DBHook ) Log(">>> DownHookInUse BeginState for "$self@"AnimState="$AnimState);
00617	      StopSound(hHookMoveSound);
00618	      bGoUp = false;
00619	      bGoDown = false;
00620	      AnimState = 0;
00621	      PlayDown();
00622	//      EndUse();
00623	    }
00624	
00625	    simulated function AnimEnd(int Channel)
00626	    {
00627	      if ( DBHook ) Log(">>> DownHookInUse AnimEnd for "$self@"AnimState="$AnimState);
00628	      bChangeItem = false;
00629	      if ( bHooked )
00630	        GotoState('IdleHookInUse');
00631	      else
00632	        GotoState('');
00633	      Pawn(Owner).ChangedWeapon();
00634	    }
00635	
00636	    simulated function Activate() {}
00637	
00638	    function Release()
00639	    { // Released while going down
00640	      if ( DBHook ) log(self$" Released in state DownHookInUse");
00641	      if (MyHook != none)
00642	        MyHook.Destroy();
00643	      if (MyLink != none)
00644	        MyLink.ShouldDestroy();
00645	      Disable('tick');
00646	//      GotoState('Down');
00647	      StopSound(hHookMoveSound);
00648	      PlayRolloffSound(hHookReleaseSound, self);
00649	      bHooked = false;
00650	      XIIIPlayerController(Instigator.Controller).bHooked = false;
00651	      bGoUp = false;
00652	      bGoDown = false;
00653	      AnimState = 0;
00654	    }
00655	}
00656	
00657	//_____________________________________________________________________________
00658	// In Use but down
00659	state IdleHookInUse
00660	{
00661	    simulated event BeginState()
00662	    {
00663	      if ( DBHook ) Log(">>> IdleHookInUse BeginState for "$self@"AnimState="$AnimState);
00664	    }
00665	
00666	    function Release()
00667	    { // Released while down
00668	      if ( DBHook ) log(self$" Released in state DownHookInUse");
00669	      if (MyHook != none)
00670	        MyHook.Destroy();
00671	      if (MyLink != none)
00672	        MyLink.ShouldDestroy();
00673	/*
00674	      if (MyFHLink != none)
00675	        MyFHLink.Destroy();
00676	*/
00677	      Disable('tick');
00678	//      bChangeItem = true;
00679	      GoToState('DownItemRopeCut');
00680	      StopSound(hHookMoveSound);
00681	      PlayRolloffSound(hHookReleaseSound, self);
00682	/*      if (AnimState != 0)
00683	        TweenDown();
00684	      else
00685	        PlayDown(); */
00686	      bHooked = false;
00687	      XIIIPlayerController(Instigator.Controller).bHooked = false;
00688	      bGoUp = false;
00689	      bGoDown = false;
00690	      AnimState = 0;
00691	    }
00692	
00693	    simulated function BringUp()
00694	    {
00695	      if( bActivatable )
00696	      {
00697	        if ( (Level.Game != none) && (Level.Game.StatLog != None) )
00698	          Level.Game.StatLog.LogItemActivate(Self, Pawn(Owner));
00699	        GoToState('ActivatedHookInUse');
00700	      }
00701	    }
00702	    simulated function Activate() {}
00703	}
00704	
00705	//_____________________________________________________________________________
00706	state ActivatedHookInUse
00707	{
00708	    simulated function BeginState()
00709	    {
00710	      Instigator = Pawn(Owner);
00711	      if ( DBHook ) Log(">>> ActivatedHookInUse BeginState for "$self@"AnimState="$AnimState);
00712	      PlaySelect();
00713	    }
00714	
00715	    simulated function AnimEnd(int Channel)
00716	    {
00717	      if ( DBHook ) Log("  > ActivatedHookInUse AnimEnd bChangeItem="$bChangeItem);
00718	      if ( bChangeItem )
00719	      {
00720	        GotoState('DownHookInUse');
00721	        return;
00722	      }
00723	      PlayIdle();
00724	      GotoState('HookInUse');
00725	    }
00726	
00727	    simulated function Activate() {}
00728	
00729	    function Release()
00730	    { // Released while down
00731	      if ( DBHook ) log(self$" Released in state ActivatedHookInUse");
00732	      if (MyHook != none)
00733	        MyHook.Destroy();
00734	      if (MyLink != none)
00735	        MyLink.ShouldDestroy();
00736	      Disable('tick');
00737	      bHooked = false;
00738	      XIIIPlayerController(Instigator.Controller).bHooked = false;
00739	      bGoUp = false;
00740	      bGoDown = false;
00741	      AnimState = 0;
00742	      GoToState('Activated');
00743	      StopSound(hHookMoveSound);
00744	      PlayRolloffSound(hHookReleaseSound, self);
00745	    }
00746	}
00747	
00748	//_____________________________________________________________________________
00749	state DownItemRopeCut
00750	{
00751	    simulated function BeginState()
00752	    {
00753	      if ( DBHook ) Log(">>> DownItemRopeCut BeginState for "$self@"AnimState="$AnimState);
00754	//      PlayDown(); // Don't play anim
00755	      AnimState = 0;
00756	      EndUse();
00757	    }
00758	
00759	    simulated function AnimEnd(int Channel)
00760	    {
00761	      if ( DBHook ) Log("  > DownItem AnimEnd");
00762	      bChangeItem = false;
00763	      GotoState('');
00764	//      Pawn(Owner).ChangedWeapon();
00765	      if ( (Pawn(Owner).SelectedItem != self) || XIIIPlayerController(Pawn(Owner).Controller).bWeaponMode )
00766	      {
00767	        bRendered = false;
00768	        bHidden = true;
00769	        RefreshDisplaying();
00770	      }
00771	    }
00772	
00773	    simulated function Activate() {}
00774	}
00775	
00776	//_____________________________________________________________________________
00777	simulated function PlaySelect()
00778	{
00779	    if ( DBHook ) Log(self@"PlaySelect, bHooked="$bHooked);
00780	    if ( bHooked )
00781	    {
00782	      if ( !bMirrored )
00783	      {
00784	        PlayerViewOffset.y = - default.PlayerViewOffset.y;
00785	        tV = default.DrawScale3D;
00786	        tV.x *= -1.0;
00787	        SetDrawScale3D(tV);
00788	        bMirrored = true;
00789	        RefreshDisplaying();
00790	      }
00791	      PlayAnim('SelectCommande',1.0);
00792	    }
00793	    else
00794	    {
00795	      if ( bMirrored )
00796	      {
00797	        PlayerViewOffset.y = default.PlayerViewOffset.y;
00798	        tV = default.DrawScale3D;
00799	        SetDrawScale3D(tV);
00800	        bMirrored = false;
00801	        RefreshDisplaying();
00802	      }
00803	      PlayAnim('Select',1.0);
00804	      PlayRolloffSound(hSelectItemSound, self);
00805	    }
00806	}
00807	
00808	//_____________________________________________________________________________
00809	simulated function PlayDown()
00810	{
00811	    if ( DBHook ) Log(self@"PlayDown, bHooked="$bHooked@"AnimState="$AnimState);
00812	    if ( bHooked )
00813	    {
00814	      if ( AnimState == 1 )
00815	      {
00816	        if ( bMirrored )
00817	        {
00818	          PlayerViewOffset.y = default.PlayerViewOffset.y;
00819	          tV = default.DrawScale3D;
00820	          SetDrawScale3D(tV);
00821	          bMirrored = false;
00822	          RefreshDisplaying();
00823	        }
00824	        PlayAnim('Down',1.0);
00825	      }
00826	      else
00827	      {
00828	        if ( !bMirrored )
00829	        {
00830	          PlayerViewOffset.y = - default.PlayerViewOffset.y;
00831	          tV = default.DrawScale3D;
00832	          tV.x *= -1.0;
00833	          SetDrawScale3D(tV);
00834	          bMirrored = true;
00835	          RefreshDisplaying();
00836	        }
00837	        PlayAnim('DownCommande',1.0);
00838	        AnimState = 3;
00839	      }
00840	    }
00841	    else
00842	    {
00843	      if ( bMirrored )
00844	      {
00845	        PlayerViewOffset.y = default.PlayerViewOffset.y;
00846	        tV = default.DrawScale3D;
00847	        SetDrawScale3D(tV);
00848	        bMirrored = false;
00849	        RefreshDisplaying();
00850	      }
00851	      PlayAnim('Down', 1.0);
00852	    }
00853	}
00854	
00855	//_____________________________________________________________________________
00856	simulated function TweenDown()
00857	{
00858	    if ( DBHook ) Log(self@"TweenDown, bHooked="$bHooked@"AnimState="$AnimState);
00859	    if ( AnimState == 1 )
00860	    {
00861	      bHooked = false;
00862	      XIIIPlayerController(Instigator.Controller).bHooked = false;
00863	      PlaySelect();
00864	      AnimState = 0;
00865	    }
00866	    else
00867	    {
00868	      if ( !bMirrored )
00869	      {
00870	        PlayerViewOffset.y = - default.PlayerViewOffset.y;
00871	        tV = default.DrawScale3D;
00872	        tV.x *= -1.0;
00873	        SetDrawScale3D(tV);
00874	        bMirrored = true;
00875	        RefreshDisplaying();
00876	      }
00877	      PlayAnim('DownCommande',3.0,0.2);
00878	      AnimState = 3;
00879	    }
00880	}
00881	
00882	//_____________________________________________________________________________
00883	simulated function PlayIdle()
00884	{
00885	    if ( DBHook ) Log(self@"PlayIdle, bHooked="$bHooked);
00886	    if ( bHooked )
00887	    {
00888	      if ( !bMirrored )
00889	      {
00890	        PlayerViewOffset.y = - default.PlayerViewOffset.y;
00891	        tV = default.DrawScale3D;
00892	        tV.x *= -1.0;
00893	        SetDrawScale3D(tV);
00894	        bMirrored = true;
00895	        RefreshDisplaying();
00896	      }
00897	      PlayAnim('WaitCommande',1.0);
00898	    }
00899	    else
00900	    {
00901	      if ( bMirrored )
00902	      {
00903	        PlayerViewOffset.y = default.PlayerViewOffset.y;
00904	        tV = default.DrawScale3D;
00905	        SetDrawScale3D(tV);
00906	        bMirrored = false;
00907	        RefreshDisplaying();
00908	      }
00909	      PlayAnim('Wait', 1.0);
00910	    }
00911	}
00912	
00913	//_____________________________________________________________________________
00914	simulated function PlayUsing()
00915	{
00916	    if ( DBHook ) Log(self@"PlayUsing");
00917	    if ( bMirrored )
00918	    {
00919	      PlayerViewOffset.y = default.PlayerViewOffset.y;
00920	      tV = default.DrawScale3D;
00921	      SetDrawScale3D(tV);
00922	      bMirrored = false;
00923	      RefreshDisplaying();
00924	    }
00925	    PlayAnim('Fire', 2.0);
00926	    AnimState = 1;
00927	}
00928	//_____________________________________________________________________________
00929	simulated function PlayClimbUp()
00930	{
00931	    if ( AnimState == 1 ) // hook has been fired
00932	      return;
00933	    if ( DBHook ) Log(self@"PlayClimbUp");
00934	    if ( !bMirrored )
00935	    {
00936	      PlayerViewOffset.y = - default.PlayerViewOffset.y;
00937	      tV = default.DrawScale3D;
00938	      tV.x *= -1.0;
00939	      SetDrawScale3D(tV);
00940	      bMirrored = true;
00941	      RefreshDisplaying();
00942	    }
00943	    if ( AnimState == 0 )
00944	      PlayAnim('ClimbUp', 2.0);
00945	}
00946	//_____________________________________________________________________________
00947	simulated function PlayClimbDown()
00948	{
00949	    if ( AnimState == 1 ) // hook has been fired
00950	      return;
00951	    if ( DBHook ) Log(self@"PlayClimbDown");
00952	    if ( !bMirrored )
00953	    {
00954	      PlayerViewOffset.y = - default.PlayerViewOffset.y;
00955	      tV = default.DrawScale3D;
00956	      tV.x *= -1.0;
00957	      SetDrawScale3D(tV);
00958	      bMirrored = true;
00959	      RefreshDisplaying();
00960	    }
00961	    if ( AnimState == 0 )
00962	      PlayAnim('ClimbDown', 2.0);
00963	}
00964	//_____________________________________________________________________________
00965	simulated function PlayStop()
00966	{
00967	    if ( DBHook ) Log(self@"PlayStop");
00968	    if ( !bMirrored )
00969	    {
00970	      PlayerViewOffset.y = - default.PlayerViewOffset.y;
00971	      tV = default.DrawScale3D;
00972	      tV.x *= -1.0;
00973	      SetDrawScale3D(tV);
00974	      bMirrored = true;
00975	      RefreshDisplaying();
00976	    }
00977	    PlayAnim('Stop', 2.0);
00978	}
00979	
00980	/*
00981	    sHooked="Hook (Hooked)"
00982	    sHookUp="Hook (Up)"
00983	    sHookDown="Hook (Down)"
00984	*/
00985	
00986	
00987	defaultproperties
00988	{
00989	     HookUpSpeed=150.000000
00990	     HookDownSpeed=300.000000
00991	     PotHookIcon=Texture'XIIIMenu.HUD.Hand_GrapplePoint'
00992	     hHookMoveSound=Sound'XIIIsound.SpecActions.HookMov'
00993	     hHookEndSound=Sound'XIIIsound.SpecActions.HookEnd'
00994	     hHookFireSound=Sound'XIIIsound.SpecActions.HookFire'
00995	     hHookReleaseSound=Sound'XIIIsound.SpecActions.HookLet'
00996	     hHookClik=Sound'XIIIsound.SpecActions.HookClick'
00997	     MeshName="XIIIArmes.FpsGrappinM"
00998	     CrossHair=Texture'XIIIMenu.HUD.MireGrappin'
00999	     IHand=IH_2H
01000	     hSelectItemSound=Sound'XIIIsound.SpecActions.HookSel'
01001	     IconNumber=21
01002	     sItemName="Hook"
01003	     bCanHaveMultipleCopies=True
01004	     bAutoActivate=True
01005	     bActivatable=True
01006	     ExpireMessage="Hook was used."
01007	     InventoryGroup=5
01008	     bDisplayableInv=True
01009	     PickupClassName="XIII.HookPick"
01010	     Charge=1
01011	     PlayerViewOffset=(X=5.000000,Y=6.000000,Z=-5.800000)
01012	     BobDamping=0.975000
01013	     ItemName="HOOK"
01014	}

End Source Code