## XIII
Class HookLink

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

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Effects
             |
             +--XIII.HookLink

Direct Known Subclasses:None

class HookLink
extends Engine.Effects

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

Variables
`HookProjectile` | `HEnd`
`Hook` | `HStart`
`int` | `LinkIndex`
`HookLink` | `NextLink`
`HookLink` | `PrevLink`
`bool` | `bDestroyWhenDown`
`bool` | `bForceDestroy`

Function Summary
`void` | `ForceDestroy()`
    //_____________________________________________________________________________
`void` | `ShouldDestroy()`
    //_____________________________________________________________________________
`void` | `Tick(float deltatime)`
    //_____________________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class HookLink extends Effects;
    00005
    00006	var Hook HStart;
    00007	var HookProjectile HEnd;
    00008	var int LinkIndex;
    00009	var HookLink NextLink;
    00010	var HookLink PrevLink;
    00011	const LinkLength = 100.0;
    00012	var bool bDestroyWhenDown;
    00013	var bool bForceDestroy;
    00014
    00015	//_____________________________________________________________________________
    00016	function Tick(float deltatime)
    00017	{
    00018	    local vector vDir, vStart, vEnd, X,Y,Z, U,V,W, tV, HitLoc, HitNorm;
    00019	    Local material HitMat;
    00020	    local vector CamLoc;
    00021	    local rotator CamRot;
    00022	    local actor A;
    00023
    00024	    // Just release if obstacle.
    00025	    if ( HStart.bHooked )
    00026	    {
    00027	      A = Trace(HitLoc, HitNorm,
    00028	        HEnd.Location,
    00029	        HStart.Owner.Location + Pawn(HStart.Owner).EyeHeight * vect(0,0,1),
    00030	        false,
    00031	        vect(0,0,0),
    00032	        HitMat,
    00033	        TRACETYPE_DiscardIfCanShootThroughWithRayCastingWeapon);
    00034	  //    if ( !FastTrace(HEnd.Location, HStart.Owner.Location + Pawn(HStart.Owner).EyeHeight * vect(0,0,1)) )
    00035	      if ( A != none )
    00036	      {
    00037	        Log("Releasing hook because obstacle"@A);
    00038	        HStart.Release();
    00039	      }
    00040	    }
    00041
    00042	    XIIIPlayerController(Pawn(HStart.Owner).Controller).PlayerCalcView(A, CamLoc, CamRot);
    00043	    GetAxes(CamRot, X, Y, Z);
    00044	    if ( PrevLink == none )
    00045	    { // Update HookSpring
    00046	      if ( HStart.bGoUp )
    00047	      {
    00048	        HStart.HookSpring = fMin(1.0, HStart.HookSpring + DeltaTime*4.0);
    00049	        HStart.HookMecRot += DeltaTime*4.0;
    00050	//        Log("GOUP HookSpring"@HStart.HookSpring);
    00051	      }
    00052	      else if ( HStart.bGodown )
    00053	      {
    00054	        HStart.HookSpring = fMax(-1.0, HStart.HookSpring - DeltaTime*6.0);
    00055	        HStart.HookMecRot -= DeltaTime*5.5;
    00056	//        Log("GODOWN HookSpring"@HStart.HookSpring);
    00057	      }
    00058	      else if ( HStart.HookSpring > 0 )
    00059	      {
    00060	        HStart.HookSpring = fMax(0.0, HStart.HookSpring - DeltaTime*3.0);
    00061	//        Log("RELUP HookSpring"@HStart.HookSpring);
    00062	      }
    00063	      else if ( HStart.HookSpring < 0 )
    00064	      {
    00065	        HStart.HookSpring = fMin(0.0, HStart.HookSpring + DeltaTime*3.0);
    00066	//        Log("RELDOWN HookSpring"@HStart.HookSpring);
    00067	      }
    00068	    }
    00069	    if ( bDestroyWhenDown )
    00070	    {
    00071	      HStart.HookMecPrep = fMax(0.0, HStart.HookMecPrep - DeltaTime*8.0);
    00072	      if ( HStart.HookMecPrep <= 0.0 )
    00073	      {
    00074	        if ( HStart.HookMec != none )
    00075	        {
    00076	          HStart.HookMec.bHidden = true;
    00077	          HStart.HookMec.RefreshDisplaying();
    00078	        }
    00079	        if ( HStart.HookHarn != none )
    00080	        {
    00081	          HStart.HookHarn.bHidden = true;
    00082	          HStart.HookHarn.RefreshDisplaying();
    00083	        }
    00084	        Destroy();
    00085	      }
    00086	    }
    00087	    else
    00088	      HStart.HookMecPrep = fMin(1.0, HStart.HookMecPrep + DeltaTime*8.0);
    00089
    00090	    vStart = CamLoc + X*10 - Y*(6.0-2*X.z) - Z*(8.5 - HStart.HookMecPrep * 4.0 - Sin((X.z+1)*(pi/2.0))) + vect(0,0,0.85)*HStart.HookSpring;
    00091	    vEnd = HEnd.Location;
    00092	    vDir = vEnd - vStart;
    00093	    SetRotation( rotator(vDir) );
    00094	    if ( NextLink == none )
    00095	    {
    00096	      SetLocation( vStart + Normal(vDir) * (LinkLength * 0.5) );
    00097	      // update hook mecanism pos/rot.
    00098	      // First Transformation, put along axis (rotate around X)
    00099	      V = Z*cos(pi/2.0*0.08) - Y*sin(pi/2.0*0.08);
    00100	      W = Y*cos(pi/2.0*0.08) + Z*sin(pi/2.0*0.08);
    00101	      CamRot = Orthorotation(X,W,V);
    00102	      GetAxes( CamRot, U,V,W);
    00103	      HStart.HookMec.SetLocation(vStart + V*1.15 + (vect(0,0,1) cross V)*0.85);
    00104	      HStart.HookHarn.SetLocation(vStart + V*1.15 + (vect(0,0,1) cross V)*0.85);
    00105	      HStart.HookHarn.SetRotation( CamRot );
    00106	      // second transformation, rotate according to up/down (should be U & W rotating around Y)
    00107	      tV = W*cos(pi/2.0*HStart.HookMecRot) + U*sin(pi/2.0*HStart.HookMecRot);
    00108	      U = U*cos(pi/2.0*HStart.HookMecRot) - W*sin(pi/2.0*HStart.HookMecRot);
    00109	      W = tV;
    00110	      HStart.HookMec.SetRotation( OrthoRotation(U,V,W) );
    00111	    }
    00112	    else
    00113	    {
    00114	      SetLocation( vEnd - Normal(vDir) * LinkLength * (LinkIndex+0.5) );
    00115	    }
    00116
    00117	    if ( bDestroyWhenDown )
    00118	      return;
    00119
    00120	    if ( (vSize(vDir) > (LinkLength*(LinkIndex+1))) && (NextLink == none) )
    00121	    {
    00122	      NextLink=Spawn(class'HookLink',,, Location,Rotation);
    00123	      if (NextLink != none)
    00124	      {
    00125	        NextLink.HStart=HStart;
    00126	        NextLink.HEnd=HEnd;
    00127	        NextLink.LinkIndex = LinkIndex + 1;
    00128	        NextLink.PrevLink = self;
    00129	      }
    00130	    }
    00131	    if ( vSize(vDir) < (LinkLength*(LinkIndex)) )
    00132	    {
    00133	      PrevLink.NextLink = none;
    00134	      Destroy();
    00135	    }
    00136	}
    00137
    00138	//_____________________________________________________________________________
    00139	function ShouldDestroy()
    00140	{ // Link destroyed, still handle hookmec position until down then destroy
    00141	//    Log(self@"ShouldDestroy, PrevLink="@PrevLink@"NextLink="@NextLink);
    00142	    if ( NextLink == none )
    00143	    {
    00144	      bDestroyWhenDown = true;
    00145	      bHidden = true;
    00146	      RefreshDisplaying();
    00147	    }
    00148	    else
    00149	    {
    00150	      NextLink.ShouldDestroy();
    00151	      Destroy();
    00152	    }
    00153	}
    00154
    00155	//_____________________________________________________________________________
    00156	function ForceDestroy()
    00157	{
    00158	    bDestroyWhenDown = false;
    00159	    if ( NextLink != none )
    00160	    {
    00161	      NextLink.bDestroyWhenDown = false;
    00162	      NextLink.ForceDestroy();
    00163	    }
    00164	    Destroy();
    00165	}
    00166
    00167	//_____________________________________________________________________________
    00168	event Destroyed()
    00169	{
    00170	/*  if ( PrevLink != none )
    00171	    PrevLink.NextLink = none; */
    00172	  if ( (NextLink != none) && !NextLink.bDestroyWhenDown )
    00173	    NextLink.Destroy();
    00174	}
    00175
    00176	//     DrawType=DT_Mesh
    00177	//     Mesh=VertMesh'XIIIArmes.GrappinCordeM'
    00178
    00179
    00180	defaultproperties
    00181	{
    00182	     RemoteRole=ROLE_SimulatedProxy
    00183	     DrawType=DT_StaticMesh
    00184	     StaticMesh=StaticMesh'MeshArmesPickup.grappincorde'
    00185	     DrawScale3D=(Y=0.350000,Z=0.350000)
    00186	}

End Source Code