UnrealI
Class Chunk

source: e:\games\UnrealTournament\UnrealI\Classes\Chunk.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--UnrealI.Chunk
Direct Known Subclasses:Chunk1, Chunk2, Chunk3, Chunk4

class Chunk
extends Engine.Projectile

//============================================================================= // Chunk. //=============================================================================
Variables
 bool bDelayTime


Function Summary
 
simulated
HitWall(vector HitNormal, Actor Wall)
 
simulated
Landed(Vector HitNormal)
 void PostBeginPlay()
 
simulated
ProcessTouch(Actor Other, vector HitLocation)
 
simulated
Timer()
 
simulated
zonechange(ZoneInfo NewZone)



Source Code


00001	//=============================================================================
00002	// Chunk.
00003	//=============================================================================
00004	class Chunk extends Projectile;
00005	
00006	#exec AUDIO IMPORT FILE="..\UnrealShare\Sounds\flak\flachit1.WAV" NAME="Hit1" GROUP="flak"
00007	#exec AUDIO IMPORT FILE="..\UnrealShare\Sounds\flak\flachit3.WAV" NAME="Hit3" GROUP="flak"
00008	#exec AUDIO IMPORT FILE="..\UnrealShare\Sounds\flak\flachit5.WAV" NAME="Hit5" GROUP="flak"
00009	#exec AUDIO IMPORT FILE="..\UnrealShare\Sounds\flak\chunkhit.WAV" NAME="ChunkHit" GROUP="flak"
00010	
00011	var bool bDelayTime;
00012	
00013		function PostBeginPlay()
00014		{
00015			local rotator RandRot;
00016	
00017			RandRot = Rotation;
00018			RandRot.Pitch += FRand() * 2000 - 1000;
00019			RandRot.Yaw += FRand() * 2000 - 1000;
00020			RandRot.Roll += FRand() * 2000 - 1000;
00021			Velocity = Vector(RandRot) * (Speed + (FRand() * 200 - 100));
00022			if (Region.zone.bWaterZone)
00023				SetPhysics(PHYS_Falling);
00024			Super.PostBeginPlay();
00025		}
00026	
00027		simulated function ProcessTouch (Actor Other, vector HitLocation)
00028		{
00029			if ( (Chunk(Other) == None) && (bDelayTime || (Other != Instigator)) )
00030			{
00031				speed = VSize(Velocity);
00032				If ( speed > 200 )
00033				{
00034					if ( Role == ROLE_Authority )
00035						Other.TakeDamage(damage, instigator,HitLocation,
00036							(MomentumTransfer * Velocity/speed), 'shredded' );
00037					if ( FRand() < 0.5 )
00038						PlaySound(Sound 'ChunkHit',, 2.0,,1000);
00039				}
00040				Destroy();
00041			}
00042		}
00043	
00044		simulated function Timer() 
00045		{
00046			Destroy();
00047		}
00048	
00049		simulated function Landed( Vector HitNormal )
00050		{
00051			SetPhysics(PHYS_None);
00052		}
00053	
00054		simulated function HitWall( vector HitNormal, actor Wall )
00055		{
00056			local float Rand;
00057			local SmallSpark s;
00058	
00059			if ( (Mover(Wall) != None) && Mover(Wall).bDamageTriggered )
00060			{
00061				if ( Level.NetMode != NM_Client )
00062					Wall.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), '');
00063				Destroy();
00064				return;
00065			}
00066			if (!bDelayTime) 
00067			{
00068				bDelayTime=True;
00069				SetPhysics(PHYS_Falling);
00070				if ( (Level.Netmode != NM_DedicatedServer) && (FRand()<0.2) ) 
00071				{
00072					s = Spawn(Class'SmallSpark',,,Location+HitNormal*5,rotator(HitNormal));
00073					s.RemoteRole = ROLE_None;
00074				}
00075			}
00076			Velocity = 0.8*(( Velocity dot HitNormal ) * HitNormal * (-1.8 + FRand()*0.8) + Velocity);   // Reflect off Wall w/damping
00077			SetRotation(rotator(Velocity));
00078			speed = VSize(Velocity);
00079			if ( speed > 100 ) 
00080			{
00081				MakeNoise(0.3);
00082				Rand = FRand();
00083				if (Rand < 0.33)	PlaySound(sound 'Hit1', SLOT_Misc,0.6,,1000);	
00084				else if (Rand < 0.66) PlaySound(sound 'Hit3', SLOT_Misc,0.6,,1000);
00085				else PlaySound(sound 'Hit5', SLOT_Misc,0.6,,1000);
00086			}
00087			else 
00088			{
00089				bBounce = False;
00090				SetTimer(1.0,False);
00091			}
00092		}
00093	
00094		simulated function zonechange(Zoneinfo NewZone)
00095		{
00096			if (NewZone.bWaterZone)
00097				SetPhysics(PHYS_Falling);			
00098		}
00099	
00100	defaultproperties
00101	{
00102	     speed=2500.000000
00103	     MaxSpeed=2700.000000
00104	     Damage=17.000000
00105	     MomentumTransfer=10000
00106	     MyDamageType=shredded
00107	     RemoteRole=ROLE_SimulatedProxy
00108	     LifeSpan=3.000000
00109	     bUnlit=True
00110	     bNoSmooth=True
00111	     bBounce=True
00112	}

End Source Code