Botpack
Class UTChunk

source: e:\games\UnrealTournament\Botpack\Classes\UTChunk.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--Botpack.UTChunk
Direct Known Subclasses:UTChunk1, UTchunk2, UTChunk3, UTChunk4

class UTChunk
extends Engine.Projectile

//============================================================================= // UTChunk. //=============================================================================
Variables
 Texture AnimFrame[12]
 int Count


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



Source Code


00001	//=============================================================================
00002	// UTChunk.
00003	//=============================================================================
00004	class UTChunk extends Projectile;
00005	
00006	var	chunktrail trail;
00007	var Texture AnimFrame[12];
00008	var int Count;
00009	
00010	#exec OBJ LOAD FILE=textures\ChunkGlow.utx PACKAGE=Botpack.ChunkGlow
00011	
00012		simulated function PostBeginPlay()
00013		{
00014			local rotator RandRot;
00015	
00016			if ( Level.NetMode != NM_DedicatedServer )
00017			{
00018				if ( !Region.Zone.bWaterZone )
00019					Trail = Spawn(class'ChunkTrail',self);
00020				SetTimer(0.1, true);
00021			}
00022	
00023			if ( Role == ROLE_Authority )
00024			{
00025				RandRot = Rotation;
00026				RandRot.Pitch += FRand() * 2000 - 1000;
00027				RandRot.Yaw += FRand() * 2000 - 1000;
00028				RandRot.Roll += FRand() * 2000 - 1000;
00029				Velocity = Vector(RandRot) * (Speed + (FRand() * 200 - 100));
00030				if (Region.zone.bWaterZone)
00031					Velocity *= 0.65;
00032			}
00033			Super.PostBeginPlay();
00034		}
00035	
00036		simulated function ProcessTouch (Actor Other, vector HitLocation)
00037		{
00038			if ( (Chunk(Other) == None) && ((Physics == PHYS_Falling) || (Other != Instigator)) )
00039			{
00040				speed = VSize(Velocity);
00041				If ( speed > 200 )
00042				{
00043					if ( Role == ROLE_Authority )
00044						Other.TakeDamage(damage, instigator,HitLocation,
00045							(MomentumTransfer * Velocity/speed), MyDamageType );
00046					if ( FRand() < 0.5 )
00047						PlaySound(Sound 'ChunkHit',, 4.0,,200);
00048				}
00049				Destroy();
00050			}
00051		}
00052	
00053		simulated function Timer() 
00054		{
00055			Count++;
00056			Texture = AnimFrame[Count];
00057			if ( Count == 11 )
00058				SetTimer(0.0,false);
00059		}
00060	
00061		simulated function Landed( Vector HitNormal )
00062		{
00063			SetPhysics(PHYS_None);
00064		}
00065	
00066		simulated function HitWall( vector HitNormal, actor Wall )
00067		{
00068			local float Rand;
00069			local SmallSpark s;
00070	
00071			if ( (Mover(Wall) != None) && Mover(Wall).bDamageTriggered )
00072			{
00073				if ( Level.NetMode != NM_Client )
00074					Wall.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), MyDamageType);
00075				Destroy();
00076				return;
00077			}
00078			if ( Physics != PHYS_Falling ) 
00079			{
00080				SetPhysics(PHYS_Falling);
00081				if ( !Level.bDropDetail && (Level.Netmode != NM_DedicatedServer) && !Region.Zone.bWaterZone ) 
00082				{
00083					if ( FRand() < 0.5 )
00084					{
00085						s = Spawn(Class'SmallSpark',,,Location+HitNormal*5,rotator(HitNormal));
00086						s.RemoteRole = ROLE_None;
00087					}
00088					else
00089						Spawn(class'WallCrack',,,Location, rotator(HitNormal));
00090				}
00091			}
00092			Velocity = 0.8*(( Velocity dot HitNormal ) * HitNormal * (-1.8 + FRand()*0.8) + Velocity);   // Reflect off Wall w/damping
00093			SetRotation(rotator(Velocity));
00094			speed = VSize(Velocity);
00095			if ( speed > 100 ) 
00096			{
00097				MakeNoise(0.3);
00098				Rand = FRand();
00099				if (Rand < 0.33)	PlaySound(sound 'Hit1', SLOT_Misc,0.6,,1000);	
00100				else if (Rand < 0.66) PlaySound(sound 'Hit3', SLOT_Misc,0.6,,1000);
00101				else PlaySound(sound 'Hit5', SLOT_Misc,0.6,,1000);
00102			}
00103		}
00104	
00105		simulated function zonechange(Zoneinfo NewZone)
00106		{
00107			if (NewZone.bWaterZone)
00108			{
00109				if ( Trail != None )
00110					Trail.Destroy();
00111				SetTimer(0.0, false);
00112				Texture = AnimFrame[11];
00113				Velocity *= 0.65;
00114			}
00115		}
00116	
00117	defaultproperties
00118	{
00119	     AnimFrame(0)=Texture'Botpack.ChunkGlow.Chunk_a00'
00120	     AnimFrame(1)=Texture'Botpack.ChunkGlow.Chunk_a01'
00121	     AnimFrame(2)=Texture'Botpack.ChunkGlow.Chunk_a02'
00122	     AnimFrame(3)=Texture'Botpack.ChunkGlow.Chunk_a03'
00123	     AnimFrame(4)=Texture'Botpack.ChunkGlow.Chunk_a04'
00124	     AnimFrame(5)=Texture'Botpack.ChunkGlow.Chunk_a05'
00125	     AnimFrame(6)=Texture'Botpack.ChunkGlow.Chunk_a06'
00126	     AnimFrame(7)=Texture'Botpack.ChunkGlow.Chunk_a07'
00127	     AnimFrame(8)=Texture'Botpack.ChunkGlow.Chunk_a08'
00128	     AnimFrame(9)=Texture'Botpack.ChunkGlow.Chunk_a09'
00129	     AnimFrame(10)=Texture'Botpack.ChunkGlow.Chunk_a10'
00130	     AnimFrame(11)=Texture'Botpack.ChunkGlow.Chunk_a11'
00131	     speed=2500.000000
00132	     MaxSpeed=2700.000000
00133	     Damage=16.000000
00134	     MomentumTransfer=10000
00135	     MyDamageType=shredded
00136	     RemoteRole=ROLE_SimulatedProxy
00137	     LifeSpan=2.900000
00138	     Texture=Texture'Botpack.ChunkGlow.Chunk_a00'
00139	     DrawScale=0.400000
00140	     AmbientGlow=255
00141	     bUnlit=True
00142	     bNoSmooth=True
00143	     bBounce=True
00144	}

End Source Code