UnrealShare
Class Book

source: e:\games\UnrealTournament\UnrealShare\Classes\Book.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--UnrealShare.Book
Direct Known Subclasses:BlueBook, GreenBook, YellowBook

class Book
extends Engine.Decoration

//============================================================================= // Book. //=============================================================================
Variables
 bool bFirstHit

States
Animate
State Animate Function Summary
 void TakeDamage(int NDamage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType)
 void HitWall(vector HitNormal, Actor Wall)



Source Code


00001	//=============================================================================
00002	// Book.
00003	//=============================================================================
00004	class Book extends Decoration;
00005	
00006	#exec MESH IMPORT MESH=BookM ANIVFILE=MODELS\book_a.3D DATAFILE=MODELS\book_d.3D X=0 Y=0 Z=0
00007	#exec MESH ORIGIN MESH=BookM X=0 Y=0 Z=0 YAW=64
00008	#exec MESH SEQUENCE MESH=BookM SEQ=All    STARTFRAME=0   NUMFRAMES=1
00009	#exec MESH SEQUENCE MESH=BookM SEQ=Still  STARTFRAME=0   NUMFRAMES=1
00010	#exec TEXTURE IMPORT NAME=JBook1 FILE=MODELS\Book1.PCX GROUP=Skins
00011	#exec TEXTURE IMPORT NAME=JBook2 FILE=MODELS\Book2.PCX GROUP=Skins
00012	#exec TEXTURE IMPORT NAME=JBook3 FILE=MODELS\Book3.PCX GROUP=Skins
00013	#exec TEXTURE IMPORT NAME=JBook4 FILE=MODELS\Book4.PCX GROUP=Skins
00014	#exec MESHMAP SCALE MESHMAP=BookM X=0.02 Y=0.02 Z=0.04
00015	#exec MESHMAP SETTEXTURE MESHMAP=BookM NUM=0 TEXTURE=JBook1 TLOD=10
00016	
00017	#exec AUDIO IMPORT FILE="Sounds\General\Chunkhit2.WAV" NAME="Chunkhit2" GROUP="General"
00018	
00019	var bool bFirstHit;
00020	
00021	Auto State Animate
00022	{
00023		function HitWall (vector HitNormal, actor Wall)
00024		{
00025			local float speed;
00026	
00027			Velocity = 0.5*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
00028			speed = VSize(Velocity);
00029			if (speed>500) PlaySound(PushSound, SLOT_Misc,1.0);			
00030			if (bFirstHit && speed<400) 
00031			{
00032				bFirstHit=False;
00033				bRotatetoDesired=True;
00034				bFixedRotationDir=False;
00035				DesiredRotation.Pitch=0;	
00036				DesiredRotation.Yaw=FRand()*65536;
00037				DesiredRotation.Roll=0;		
00038			}
00039			RotationRate.Yaw = RotationRate.Yaw*0.75;
00040			RotationRate.Roll = RotationRate.Roll*0.75;
00041			RotationRate.Pitch = RotationRate.Pitch*0.75;	
00042			If (speed < 30) 
00043				bBounce = False;
00044		}	
00045	
00046		function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation, 
00047							Vector momentum, name damageType)
00048		{
00049			SetPhysics(PHYS_Falling);
00050			bBounce = True;
00051			Momentum.Z = abs(Momentum.Z*4+3000);
00052			Velocity=Momentum*0.02;
00053			RotationRate.Yaw = 250000*FRand() - 125000;
00054			RotationRate.Pitch = 250000*FRand() - 125000;
00055			RotationRate.Roll = 250000*FRand() - 125000;	
00056			DesiredRotation = RotRand();
00057			bRotateToDesired=False;
00058			bFixedRotationDir=True;
00059			bFirstHit=True;
00060		}
00061	}
00062	
00063	defaultproperties
00064	{
00065	     bPushable=True
00066	     PushSound=Sound'UnrealShare.General.Chunkhit2'
00067	     bStatic=False
00068	     DrawType=DT_Mesh
00069	     Mesh=LodMesh'UnrealShare.BookM'
00070	     CollisionRadius=12.000000
00071	     CollisionHeight=4.000000
00072	     bCollideActors=True
00073	     bCollideWorld=True
00074	     bBlockActors=True
00075	     bBlockPlayers=True
00076	     Mass=1.000000
00077	}

End Source Code