XIII
Class XIIIPlayerPawn

source: C:\XIII\XIII\Classes\XIIIPlayerPawn.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--XIII.XIIIPawn
            |
            +--XIII.XIIIPlayerPawn
Direct Known Subclasses:XIIIMPPlayerPawn

class XIIIPlayerPawn
extends XIII.XIIIPawn

//============================================================================= // XIIIPlayerPawn. //=============================================================================
Variables
 SixSenseSkill SSSk
           To memorize the actor (not searching it everytime.
 bool bCanStun
           to memorize the stunning ability
 bool bIsSniper
           to memorize sniper ability
 bool bSilent
           to memorize silentwalk skill
 sound hHealSound
           to memorize silentwalk skill

States
Dying

Function Summary
 bool CanHoldDualWeapons()
     
//_____________________________________________________________________________
 bool CanStun(optional XIIIPawn)
     
//_____________________________________________________________________________
 void DoJump(bool bUpdating)
     
//_____________________________________________________________________________
//Player Jumped
// ELR Added bAllowJump (Pawn Grabbed)
 int GetDamageWarningSide(vector HitLocation)
     
//_____________________________________________________________________________
// ELR CheckDamageLocation
 void HandlePickup(Pickup pick)
     
//_____________________________________________________________________________
 void Heal(int H)
     
//_____________________________________________________________________________
// ELR to heal
 bool IsDead()
 void SC(bool b)
     
//_____________________________________________________________________________
 
simulated
Tick(float DT)
     
//_____________________________________________________________________________
//
 void YouCantClimb()
     
//_____________________________________________________________________________


State Dying Function Summary
 void BeginState()



Source Code


00001	//=============================================================================
00002	// XIIIPlayerPawn.
00003	//=============================================================================
00004	class XIIIPlayerPawn extends XIIIPawn;
00005	
00006	var travel SixSenseSkill SSSk;    // To memorize the actor (not searching it everytime.
00007	var travel bool bCanStun;         // to memorize the stunning ability
00008	var travel bool bIsSniper;        // to memorize sniper ability
00009	var travel bool bSilent;          // to memorize silentwalk skill
00010	var sound hHealSound;
00011	
00012	//var float LastSnipercheckTime;
00013	
00014	//_____________________________________________________________________________
00015	exec function SC( bool b )
00016	{
00017	    bSpineControl = b;
00018	}
00019	
00020	//_____________________________________________________________________________
00021	// ELR
00022	simulated event PostBeginPlay()
00023	{
00024	    if ( Level.bLonePlayer )
00025	      bActorShadows = false; // Cancel shadow for Solo player
00026	
00027	    Super(Pawn).PostBeginPlay();
00028	    SetTimer( 1.0, false );
00029	    EnableChannelNotify(FIRINGCHANNEL, 1);
00030	    SetTimer2(1.0, true);
00031	}
00032	
00033	//_____________________________________________________________________________
00034	function YouCantClimb() // used to send message on-screen.
00035	{
00036	   PlayerController(Controller).MyHud.LocalizedMessage(class'XIIIDialogMessage', 5);
00037	}
00038	
00039	//_____________________________________________________________________________
00040	event GainedChild( Actor Other )
00041	{
00042	    if ( XIIISkill(Other) == none ) // don't treat all the tests after
00043	      return;
00044	
00045	    if ( SniperSkill(Other) != none )
00046	      bIsSniper = true;
00047	    else if ( StunningSkill(Other) != none )
00048	      bCanStun = true;
00049	    else if ( SilentWalkSkill(Other) != none )
00050	      bSilent = true;
00051	}
00052	
00053	/*
00054	//_____________________________________________________________________________
00055	event FellOutOfWorld()
00056	{
00057	    Log("PLAYER FellOutOfWorld !!!");
00058	    if ( Role < ROLE_Authority )
00059	      return;
00060	    Health = -1;
00061	    SetPhysics(PHYS_None);
00062	    Weapon = None;
00063	    Died(None, class'Gibbed', Location);
00064	}
00065	*/
00066	
00067	//_____________________________________________________________________________
00068	event Landed(vector HitNormal)
00069	{
00070	//    Log("PLAYER Landed");
00071	// if receving Landed in hooked behaviour, then adjust speed to avoid dying of damages because of increasing speed
00072	    if ( ( (Controller != none) && Controller.IsA('XIIIPlayerController') ) && ( XIIIPlayerController(Controller).bHooked ) )
00073	      Velocity = vect(0,0,0);
00074	    Super.Landed(HitNormal);
00075	}
00076	
00077	//_____________________________________________________________________________
00078	// ELR CheckDamageLocation
00079	function int GetDamageWarningSide( vector HitLocation )
00080	{
00081	    local vector offset;
00082	
00083	    // Use the hitlocation to determine where the pawn is hit
00084	    // Transform the worldspace hitlocation into objectspace
00085	    // In objectspace, X is front to back Y is side to side, and Z is top to bottom
00086	    offset = normal((HitLocation - Location) << Rotation);
00087	
00088	//    Log("GetDamageWarningSide, Offset="$offset);
00089	    if ( offset.y > 0.707 )
00090	      return 1; // Right
00091	    else if ( offset.x > 0.707 )
00092	      return 0; // Front
00093	    else if ( offset.x < -0.707 )
00094	      return 3; // Back
00095	    else
00096	      return 2; // Left
00097	}
00098	
00099	//_____________________________________________________________________________
00100	// ELR Take Damage with Damage Location
00101	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
00102	{
00103	    if ( Controller == none )
00104	    { // should only happen when in flashback
00105	      return;
00106	    }
00107	//    Log("PLAYER TakeDamage class="$DamageType);
00108	    if ( (InstigatedBy != none) && (InstigatedBy != self) )
00109	      if( XIIIPlayerController(Controller) != none )
00110	        XIIIPlayerController(Controller).ClientAddDamageWarn( GetDamageWarningSide(InstigatedBy.Location) );
00111	//        XIIIBaseHUD(XIIIPlayerController(Controller).MyHud).AddDamageWarn( GetDamageWarningSide(InstigatedBy.Location) );
00112	
00113	    if ( ( Level.bLonePlayer ) && ( DamageType==class'DTGrenaded' || DamageType==class'DTRocketed' ) )
00114	    {
00115	      XIIIPlayerController(Controller).MaxShakeFrame.X = 0.12;
00116	      XIIIPlayerController(Controller).MaxShakeFrame.Y = 0.09;
00117	      XIIIPlayerController(Controller).MaxShakeFrame.Z = Level.TimeSeconds; // EffectStartDate
00118	      XIIIPlayerController(Controller).ShakeFrameTime = 3; //0.06*100;
00119	    }
00120	    if( ( Level.bLonePlayer ) && ( damageType != class'DTFell') )
00121	    {
00122	      Damage *= ((1+Level.Game.Difficulty)*0.15+Level.AdjustDifficulty/100);
00123	    }
00124	    Super.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
00125	}
00126	
00127	//_____________________________________________________________________________
00128	// ELR to heal
00129	function Heal(int H)
00130	{
00131	    Local int i;
00132	
00133	//    log("Heal called w/ ammount="$H);
00134	    Health = Min(Default.Health, Health+H);
00135	    PlaySound(hHealSound);
00136	//    CheckMaluses(); // no need in this now that we don't have any negative fx for low health
00137	}
00138	
00139	//_____________________________________________________________________________
00140	function bool CanStun(optional XIIIPawn P)
00141	{
00142	    local vector U,V;
00143	
00144	    if ( Region.Zone.FlashEffectDesc.IsActivated )
00145	      return false;
00146	    if ( DecoWeapon(Weapon) != none )
00147	      return true;
00148	    if ( !bCanStun )
00149	      return false;
00150	
00151	    U = P.Location - Location; U.Z = 0.0;
00152	    V = vector(P.rotation); V.Z = 0.0;
00153	    return ( (U dot V > 0.707) && (Fists(Weapon) != none) && XIIIPlayerController(controller).bWeaponMode );
00154	}
00155	
00156	//_____________________________________________________________________________
00157	simulated function bool CanHoldDualWeapons()
00158	{
00159	    return ( FindInventoryKind('DualWeaponSkill') != none );
00160	}
00161	
00162	//_____________________________________________________________________________
00163	event Heard(float Loudness, Actor NoiseMaker)
00164	{
00165	    if ( SSSk == none )
00166	      return;
00167	    if ( Region.Zone.FlashEffectDesc.IsActivated )
00168	      return;
00169	
00170	    if ( XIIIPawn(NoiseMaker) != none )
00171	      SSSk.Heard(NoiseMaker);
00172	    else
00173	      SSSk.ResetTimer();
00174	//      log(self@"heard"@NoiseMaker@"w/ loudness="$Loudness);
00175	}
00176	
00177	function bool IsDead()
00178	{
00179	    if ( Health <= 0 )
00180	      return true;
00181	    return false;
00182	}
00183	//_____________________________________________________________________________
00184	// used for Six Sense skill update
00185	event Timer2()
00186	{
00187	    if ( SSSk != none )
00188	    {
00189	      if ( (bMoving && !bIsWalking) || ((Physics == PHYS_Falling) && !XIIIPlayerController(Controller).bHooked)  )
00190	        SSSk.ResetTimer();
00191	      if ( (LHand != none) && (LHand.pOnShoulder != none) && !LHand.pOnShoulder.bIsDead )
00192	        SSSk.ResetTimer();
00193	      if ( XIIIPlayerController(Controller).bHooked && (hook(SelectedItem) != none) && (hook(SelectedItem).bGoUp || hook(SelectedItem).bGoDown) )
00194	        SSSk.ResetTimer();
00195	    }
00196	}
00197	
00198	//_____________________________________________________________________________
00199	//Player Jumped
00200	// ELR Added bAllowJump (Pawn Grabbed)
00201	function DoJump( bool bUpdating )
00202	{
00203	    Super.DoJump( bUpdating );
00204	    Timer();
00205	}
00206	
00207	//_____________________________________________________________________________
00208	//
00209	simulated function Tick(float DT)
00210	{
00211	    local int i;
00212	    local XIIIPawn XP;
00213	
00214	    if ( ((Controller != None) && Controller.bControlAnimations) || (Controller == none) )
00215	    {
00216	      SetBoneDirection( FIRINGBLENDBONE, rot(0,0,0), vect(0,0,0), 0.0 );
00217	    }
00218	
00219	    if ( BaffeTimer > 0.0 )
00220	    {
00221	      BaffeTimer -= DT;
00222	      if ( BaffeTimer <= 0.0 )
00223	      {
00224	        bPaf = true;
00225	        Timer();
00226	      }
00227	    }
00228	    if (MyOldAcceleration != Acceleration)
00229	    {
00230	      if (MyOldAcceleration == vect(0,0,0)) // Start to move
00231	      {
00232	        if ( bDBAnim ) Log("@@ Tick == Animation Start Moving");
00233	        bMoving=true;
00234	        Timer();
00235	      }
00236	      else if ( Acceleration == vect(0,0,0) ) // Stopped moving
00237	      {
00238	        if ( bDBAnim ) Log("@@ Tick == Animation Stop Moving");
00239	        if ( bMoving && (Physics == PHYS_Walking) )
00240	          PlayEndStep();
00241	        bMoving=false;
00242	        Timer();
00243	      }
00244	    }
00245	    MyOldAcceleration = Acceleration;
00246	
00247	    // Auto pickup when touching corpses
00248	
00249	    if( Controller == none )
00250	        return;
00251	
00252	    if ( Level.bLonePlayer && Controller.IsA('XIIIPlayerController') && XIIIPlayerController(Controller).bAutoPickup && (Touching.Length > 0) )
00253	    {
00254	      for (i=0; i<Touching.Length; i++)
00255	      {
00256	        XP = XIIIPawn(Touching[i]);
00257	        if ( (XP != none) && XP.bSearchable && (XP.Inventory != none) )
00258	        {
00259	//          Log("@@@ AUTOPICKUP On touching"@XP);
00260	          XIIIPlayerController(Controller).SearchPawn(XP);
00261	        }
00262	      }
00263	    }
00264	}
00265	
00266	/*
00267	//_____________________________________________________________________________
00268	event Touch(actor other)
00269	{
00270	    local XIIIPawn XP;
00271	
00272	    Log(self@"touched"@other);
00273	    XP = XIIIPawn(Other);
00274	    if ( (XP.Inventory != none) && XIIIPlayerController(Controller).bAutoPickup )
00275	    {
00276	      XIIIPlayerController(Pawn(Other).Controller).SearchPawn(XP);
00277	    }
00278	}
00279	*/
00280	
00281	//_____________________________________________________________________________
00282	function HandlePickup(Pickup pick)
00283	{
00284	    if ( Level.NetMode == NM_StandAlone ) // else pickup sounds will by played by replication
00285	    { // solo/multi offline playing pickup sound
00286	//      Log(Self@"SND HandlePickup"@Pick.PickupSound);
00287	      PlaySound(Pick.PickupSound);
00288	    }
00289	    Super.HandlePickup(pick);
00290	}
00291	
00292	//_____________________________________________________________________________
00293	simulated event PlayEndStep()
00294	{
00295	    local material M;
00296	//    local actor A;
00297	//    local vector HitLoc, HitNorm;
00298	
00299	    if ( (base == none) || (bIsWalking && bSilent) )
00300	      return; // avoid all cases to prevent trace abuse
00301	
00302	//    A = Trace(HitLoc, HitNorm, Location - (CollisionHeight + CollisionRadius) * vect(0,0,1), location, true, vect(0,0,0), M);
00303	    M = LastCollidedMaterial;
00304	
00305	/*
00306	    if ( TerrainInfo(A) != none )
00307	    {
00308	      if ( Level.bReplaceHXScripts )
00309	        PlaySndXIIIStep(TerrainInfo(A).XIIISndStep, vsize(velocity), -2, bSilent );
00310	      else
00311	        PlaySound(TerrainInfo(A).XIIIFootstepSound, int(vsize(velocity)), -2, int(bSilent) );
00312	      Instigator = self;
00313	      if ( bIsWalking )
00314	      {
00315	        if ( !bSilent )
00316	          MakeNoise(TerrainInfo(A).NoiseLoudness / 5.0);
00317	      }
00318	      else
00319	      {
00320	        if ( !bSilent )
00321	          MakeNoise(TerrainInfo(A).NoiseLoudness);
00322	        else
00323	          MakeNoise(TerrainInfo(A).NoiseLoudness / 5.0);
00324	      }
00325	    }
00326	    else */
00327	    if (M != none)
00328	    {
00329	      if ( Level.bReplaceHXScripts )
00330	        PlaySndXIIIStep(M.XIIISndStep, vsize(velocity), -2, bSilent );
00331	      else
00332	        PlaySound(M.XIIIFootstepSound, int(vsize(velocity)), -2, int(bSilent) );
00333	      Instigator = self;
00334	      if ( bIsWalking )
00335	      {
00336	        if ( !bSilent )
00337	          MakeNoise(M.NoiseLoudness / 5.0);
00338	      }
00339	      else
00340	      {
00341	        if ( !bSilent )
00342	          MakeNoise(M.NoiseLoudness);
00343	        else
00344	          MakeNoise(M.NoiseLoudness / 5.0);
00345	      }
00346	    }
00347	}
00348	
00349	//_____________________________________________________________________________
00350	// ELR
00351	event HeadVolumeChange(PhysicsVolume newHeadVolume)
00352	{
00353	    if ( (Level.NetMode == NM_Client) || (Controller == None) )
00354	      return;
00355	
00356	    SetBreatheOn(); // Security/Anti-bug purpose // ::TODO:: Check if may be removed
00357	
00358	    //Log("@@@ "$self$" have HeadVolume"$HeadVolume@"newHeadVolume="$newHeadVolume@"Location="$Location);
00359	    if ( HeadVolume.bWaterVolume )
00360	    {
00361	      if (!newHeadVolume.bWaterVolume)
00362	      {
00363	        if ( IsPlayerPawn() && (BreathTime > 0) && (BreathTime < 8) )
00364	          Gasp();
00365	        BreathTime = DTimerStep;
00366	        DrownTimer += 2.0*DTimerStep;
00367	        if ( IsPlayerPawn() )
00368	          PlaySound(hSwimmingSound, 0);
00369	        TriggerEvent('WaterSwitch', self, self);
00370	        //Log("@@@ hSwimmingSound param 0");
00371	      }
00372	    }
00373	    else
00374	    {
00375	      if ( newHeadVolume.bWaterVolume )
00376	      {
00377	        BreathTime = 0.5;
00378	        bDrawBreathtimer = true;
00379	        DrownTimer = min(UnderWaterTime, Drowntimer);
00380	        if ( IsPlayerPawn() )
00381	          PlaySound(hSwimmingSound, 1);
00382	        if ( !HeadVolume.bWatervolume )
00383	          TriggerEvent('WaterSwitch', self, self);
00384	        //Log("@@@ hSwimmingSound param 1");
00385	      }
00386	    }
00387	}
00388	//_____________________________________________________________________________
00389	simulated event PlayFootStep()
00390	{
00391	    local material M;
00392	    local actor A;
00393	    local vector HitLoc, HitNorm;
00394	
00395	//    Log("PlayFootStep"@self@"base="$Base@"bMoving="$bMoving);
00396	    if ( (base == none) || (!bMoving && IsLocallyControlled()) )
00397	      return; // avoid all cases to prevent trace abuse
00398	
00399	    if ( (Level.NetMode == NM_client) && !IsLocallyControlled() )
00400	      A = Trace(HitLoc, HitNorm, Location - (CollisionHeight + CollisionRadius) * vect(0,0,1), location, true, vect(0,0,0), M);
00401	    else
00402	      M = LastCollidedMaterial;
00403	//    Log(" > Material="$M);
00404	
00405	    if (M != none)
00406	    {
00407	      if ( Level.bReplaceHXScripts )
00408	        PlaySndXIIIStep(M.XIIISndStep, vsize(velocity), SoundStepCategory, bSilent );
00409	      else
00410	        PlaySound(M.XIIIFootstepSound, int(vsize(velocity)), SoundStepCategory, int(bSilent) );
00411	      Instigator = self;
00412	      if ( (bIsWalking && bSilent) || bIsCrouched )
00413	        return;
00414	      if ( bIsWalking )
00415	      {
00416	        if ( !bSilent )
00417	          MakeNoise(M.NoiseLoudness / 10.0);
00418	      }
00419	      else
00420	      {
00421	        if ( !bSilent )
00422	          MakeNoise(M.NoiseLoudness);
00423	        else
00424	          MakeNoise(M.NoiseLoudness / 10.0);
00425	      }
00426	    }
00427	}
00428	
00429	//_____________________________________________________________________________
00430	// ELR Override dying begin state from xiiipawn
00431	state Dying
00432	{
00433	    function BeginState()
00434	    {
00435	      if ( bTearOff && (Level.NetMode == NM_DedicatedServer) )
00436	        LifeSpan = 1.0;
00437	      SetTimer(2.0, false);
00438	
00439	      SetPhysics(PHYS_Falling);
00440	      bInvulnerableBody = true;
00441	      if ( Controller != none )
00442	        Controller.PawnDied();
00443	    }
00444	}
00445	
00446	
00447	
00448	defaultproperties
00449	{
00450	     hHealSound=Sound'XIIIsound.XIIIPerso__XIII_othersOnos.XIII_othersOnos__hXIIIonoMedik'
00451	     bCanCrouch=True
00452	     bCanClimbLadders=True
00453	     bCanStrafe=True
00454	     bCanPickupInventory=True
00455	     bSameZoneHearing=True
00456	     bAdjacentZoneHearing=True
00457	     bMuffledHearing=True
00458	     bAroundCornerHearing=True
00459	     bEnableSpineControl=True
00460	     HearingThreshold=5600.000000
00461	     PawnName="XIII"
00462	     Alliance="Player"
00463	     hJumpSound=Sound'XIIIsound.XIIIPerso__XIIIJump.XIIIJump__hXIIIJump'
00464	     hHitSound=Sound'XIIIsound.XIIIPerso__XIIIPaf.XIIIPaf__hXIIIPaf'
00465	     hNotifSwimSound=Sound'XIIIsound.XIIIPerso__XIIISwim.XIIISwim__hXIIISwim'
00466	     bInteractive=False
00467	     bHasRollOff=False
00468	     bHasPosition=False
00469	     Mesh=SkeletalMesh'XIIIPersos.XIIIM'
00470	}

End Source Code