XIII
Class BeretFlying

source: C:\XIII\XIII\Classes\BeretFlying.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Effects
         |
         +--XIII.BeretFlying
Direct Known Subclasses:None

class BeretFlying
extends Engine.Effects

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 ImpactSound, AltImpactSound
 float SplashTime
 bool bFirstHit

States
Flying

Function Summary
 
simulated
CalcVelocity(vector Momentum)
     
//_____________________________________________________________________________
 bool CanSplash()
     
//_____________________________________________________________________________
 void RandSpin(float spinRate)
     
//_____________________________________________________________________________


State Flying Function Summary



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class BeretFlying extends Effects;
00005	
00006	var bool bFirstHit;
00007	var() sound    ImpactSound, AltImpactSound;
00008	var()	float  SplashTime;
00009	
00010	//_____________________________________________________________________________
00011	function bool CanSplash()
00012	{
00013		if ( (Level.TimeSeconds - SplashTime > 0.25)
00014			&& (Physics == PHYS_Falling)
00015			&& (Abs(Velocity.Z) > 100) )
00016		{
00017			SplashTime = Level.TimeSeconds;
00018			return true;
00019		}
00020		return false;
00021	}
00022	
00023	//_____________________________________________________________________________
00024	simulated function CalcVelocity(vector Momentum)
00025	{
00026	    local float ExplosionSize;
00027	
00028	    ExplosionSize = 0.011 * VSize(Momentum);
00029	    Velocity = 0.0033 * Momentum + 0.7 * VRand()*(ExplosionSize+FRand()*100.0+100.0);
00030	//    Velocity.z += 0.5 * ExplosionSize;
00031	//    Log("CalcVelocity Velocity="$Velocity);
00032	}
00033	
00034	//_____________________________________________________________________________
00035	simulated event HitWall (vector HitNormal, actor HitWall)
00036	{
00037	    local float speed;
00038	
00039	    Velocity = 0.5*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
00040	    speed = VSize(Velocity);
00041	    if (bFirstHit && speed<400)
00042	    {
00043	      bFirstHit=False;
00044	      bRotatetoDesired=True;
00045	      bFixedRotationDir=False;
00046	      DesiredRotation.Pitch=0;
00047	      DesiredRotation.Yaw=FRand()*65536;
00048	      DesiredRotation.roll=0;
00049	    }
00050	    RotationRate.Yaw = RotationRate.Yaw*0.75;
00051	    RotationRate.Roll = RotationRate.Roll*0.75;
00052	    RotationRate.Pitch = RotationRate.Pitch*0.75;
00053	    if ( (speed < 60) && (HitNormal.Z > 0.7) )
00054	    {
00055	      SetPhysics(PHYS_none);
00056	      bBounce = false;
00057	      GoToState('');
00058	    }
00059	    else if (speed > 80)
00060	    {
00061	      if (FRand()<0.5)
00062	      	PlaySound(ImpactSound);
00063	      else
00064	      	PlaySound(AltImpactSound);
00065	    }
00066	}
00067	
00068	/*
00069	//_____________________________________________________________________________
00070	event TakeDamage( int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType)
00071	{
00072	//    Log(self$" TakeDamage");
00073	    GotoState('Flying');
00074	//    bBounce = true;
00075	    SetPhysics(PHYS_Falling);
00076	    CalcVelocity((HitLocation - Location) * vSize(Momentum));
00077	}
00078	*/
00079	
00080	//_____________________________________________________________________________
00081	simulated final function RandSpin(float spinRate)
00082	{
00083	    DesiredRotation = RotRand();
00084	    RotationRate.Yaw = spinRate * 2 *FRand() - spinRate;
00085	    RotationRate.Pitch = spinRate * 2 *FRand() - spinRate;
00086	    RotationRate.Roll = spinRate * 2 *FRand() - spinRate;
00087	}
00088	
00089	//_____________________________________________________________________________
00090	auto state Flying
00091	{
00092		simulated singular event PhysicsVolumeChange( PhysicsVolume NewVolume )
00093		{
00094			if ( NewVolume.bWaterVolume )
00095			{
00096				Velocity = 0.2 * Velocity;
00097				if (bFirstHit)
00098				{
00099					bFirstHit=False;
00100					bRotatetoDesired=True;
00101					bFixedRotationDir=False;
00102					DesiredRotation.Pitch=0;
00103					DesiredRotation.Yaw=FRand()*65536;
00104					DesiredRotation.roll=0;
00105				}
00106				RotationRate = 0.2 * RotationRate;
00107			}
00108		}
00109	
00110		simulated event BeginState()
00111		{
00112			RandSpin(125000);
00113			if (abs(RotationRate.Pitch)<10000)
00114				RotationRate.Pitch=10000;
00115			if (abs(RotationRate.Roll)<10000)
00116				RotationRate.Roll=10000;
00117		}
00118	}
00119	
00120	
00121	defaultproperties
00122	{
00123	     bFirstHit=True
00124	     bIgnoreVignetteAlpha=True
00125	     bCollideActors=True
00126	     bCollideWorld=True
00127	     bFixedRotationDir=True
00128	     Physics=PHYS_Falling
00129	     DrawType=DT_StaticMesh
00130	     StaticMesh=StaticMesh'MeshArmesPickup.beret'
00131	     CollisionRadius=10.000000
00132	     CollisionHeight=8.000000
00133	}

End Source Code