Botpack
Class Razor2

source: e:\games\UnrealTournament\Botpack\Classes\Razor2.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--Botpack.Razor2
Direct Known Subclasses:Razor2Alt

class Razor2
extends Engine.Projectile

//============================================================================= // Razor2 // A human modified RazorBlade //=============================================================================
Variables
 int NumWallHits
 bCanHitInstigator, bHitWater

States
Flying
State Flying Function Summary
 void SetUp()



Source Code


00001	//=============================================================================
00002	// Razor2
00003	// A human modified RazorBlade
00004	//=============================================================================
00005	class Razor2 extends Projectile;
00006	
00007	#exec MESH IMPORT MESH=razorblade ANIVFILE=MODELS\razorblade_a.3D DATAFILE=MODELS\razorblade_d.3D X=0 Y=0 Z=0
00008	#exec MESH ORIGIN MESH=razorblade X=0 Y=0 Z=0 YAW=-64
00009	#exec MESH SEQUENCE MESH=razorblade SEQ=All    STARTFRAME=0   NUMFRAMES=30
00010	#exec MESH SEQUENCE MESH=razorblade SEQ=Spin  STARTFRAME=0   NUMFRAMES=29
00011	#exec MESHMAP SCALE MESHMAP=razorblade X=0.09 Y=0.09 Z=0.18
00012	#exec TEXTURE IMPORT NAME=RazTrail FILE=MODELS\raztrail.PCX GROUP="Skins"
00013	#exec TEXTURE IMPORT NAME=RazSkin FILE=MODELS\razorskin.PCX GROUP="Skins"
00014	#exec MESHMAP SETTEXTURE MESHMAP=razorblade NUM=1 TEXTURE=RazSkin
00015	#exec MESHMAP SETTEXTURE MESHMAP=razorblade NUM=2 TEXTURE=RazTrail
00016	
00017	var int NumWallHits;
00018	var bool bCanHitInstigator, bHitWater;
00019	
00020	/////////////////////////////////////////////////////
00021	auto state Flying
00022	{
00023		simulated function ProcessTouch (Actor Other, Vector HitLocation)
00024		{
00025			if ( bCanHitInstigator || (Other != Instigator) ) 
00026			{
00027				if ( Role == ROLE_Authority )
00028				{
00029					if ( Other.bIsPawn && (HitLocation.Z - Other.Location.Z > 0.62 * Other.CollisionHeight) 
00030						&& (!Instigator.IsA('Bot') || !Bot(Instigator).bNovice) )
00031						Other.TakeDamage(3.5 * damage, instigator,HitLocation,
00032							(MomentumTransfer * Normal(Velocity)), 'decapitated' );
00033					else			 
00034						Other.TakeDamage(damage, instigator,HitLocation,
00035							(MomentumTransfer * Normal(Velocity)), 'shredded' );
00036				}
00037				if ( Other.bIsPawn )
00038					PlaySound(MiscSound, SLOT_Misc, 2.0);
00039				else
00040					PlaySound(ImpactSound, SLOT_Misc, 2.0);
00041				destroy();
00042			}
00043		}
00044	
00045		simulated function ZoneChange( Zoneinfo NewZone )
00046		{
00047			local Splash w;
00048			
00049			if (!NewZone.bWaterZone || bHitWater) Return;
00050	
00051			bHitWater = True;
00052			if ( Level.NetMode != NM_DedicatedServer )
00053			{
00054				w = Spawn(class'Splash',,,,rot(16384,0,0));
00055				w.DrawScale = 0.5;
00056				w.RemoteRole = ROLE_None;
00057			}
00058			Velocity=0.6*Velocity;
00059		}
00060	
00061		simulated function SetRoll(vector NewVelocity) 
00062		{
00063			local rotator newRot;	
00064		
00065			newRot = rotator(NewVelocity);	
00066			SetRotation(newRot);	
00067		}
00068	
00069		simulated function HitWall (vector HitNormal, actor Wall)
00070		{
00071			local vector Vel2D, Norm2D;
00072	
00073			bCanHitInstigator = true;
00074			PlaySound(ImpactSound, SLOT_Misc, 2.0);
00075			LoopAnim('Spin',1.0);
00076			if ( (Mover(Wall) != None) && Mover(Wall).bDamageTriggered )
00077			{
00078				if ( Role == ROLE_Authority )
00079					Wall.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), MyDamageType);
00080				Destroy();
00081				return;
00082			}
00083			NumWallHits++;
00084			SetTimer(0, False);
00085			MakeNoise(0.3);
00086			if ( NumWallHits > 6 )
00087				Destroy();
00088	
00089			if ( NumWallHits == 1 ) 
00090			{
00091				Spawn(class'WallCrack',,,Location, rotator(HitNormal));
00092				Vel2D = Velocity;
00093				Vel2D.Z = 0;
00094				Norm2D = HitNormal;
00095				Norm2D.Z = 0;
00096				Norm2D = Normal(Norm2D);
00097				Vel2D = Normal(Vel2D);
00098				if ( (Vel2D Dot Norm2D) < -0.999 )
00099				{
00100					HitNormal = Normal(HitNormal + 0.6 * Vel2D);
00101					Norm2D = HitNormal;
00102					Norm2D.Z = 0;
00103					Norm2D = Normal(Norm2D);
00104					if ( (Vel2D Dot Norm2D) < -0.999 )
00105					{
00106						if ( Rand(1) == 0 )
00107							HitNormal = HitNormal + vect(0.05,0,0);
00108						else
00109							HitNormal = HitNormal - vect(0.05,0,0);
00110						if ( Rand(1) == 0 )
00111							HitNormal = HitNormal + vect(0,0.05,0);
00112						else
00113							HitNormal = HitNormal - vect(0,0.05,0);
00114						HitNormal = Normal(HitNormal);
00115					}
00116				}
00117			}
00118			Velocity -= 2 * (Velocity dot HitNormal) * HitNormal;  
00119			SetRoll(Velocity);
00120		}
00121	
00122		function SetUp()
00123		{
00124			local vector X;
00125	
00126			X = vector(Rotation);	
00127			Velocity = Speed * X;     // Impart ONLY forward vel
00128			if (Instigator.HeadRegion.Zone.bWaterZone)
00129				bHitWater = True;	
00130		}
00131	
00132		simulated function BeginState()
00133		{
00134	
00135			SetTimer(0.2, false);
00136			SetUp();
00137	
00138			if ( Level.NetMode != NM_DedicatedServer )
00139			{
00140				LoopAnim('Spin',1.0);
00141				if ( Level.NetMode == NM_Standalone )
00142					SoundPitch = 200 + 50 * FRand();
00143			}			
00144		}
00145	
00146		simulated function Timer()
00147		{
00148			bCanHitInstigator = true;
00149		}
00150	}
00151	
00152	defaultproperties
00153	{
00154	     speed=1300.000000
00155	     MaxSpeed=1200.000000
00156	     Damage=30.000000
00157	     MomentumTransfer=15000
00158	     SpawnSound=Sound'UnrealI.Razorjack.StartBlade'
00159	     ImpactSound=Sound'UnrealI.Razorjack.BladeHit'
00160	     MiscSound=Sound'UnrealI.Razorjack.BladeThunk'
00161	     RemoteRole=ROLE_SimulatedProxy
00162	     LifeSpan=6.000000
00163	     AnimSequence=spin
00164	     AmbientSound=Sound'UnrealI.Razorjack.RazorHum'
00165	     Mesh=LodMesh'Botpack.RazorBlade'
00166	     AmbientGlow=167
00167	     bUnlit=True
00168	     SoundRadius=12
00169	     SoundVolume=255
00170	     SoundPitch=200
00171	     bBounce=True
00172	}

End Source Code