UnrealI
Class RazorBladeAlt

source: e:\games\UnrealTournament\UnrealI\Classes\RazorBladeAlt.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--UnrealI.RazorBlade
            |
            +--UnrealI.RazorBladeAlt
Direct Known Subclasses:None

class RazorBladeAlt
extends UnrealI.RazorBlade

//============================================================================= // RazorBladeAlt. //=============================================================================
Variables
 OldGuiderRotation, GuidedRotation
 vector GuidedVelocity

States
Flying

Function Summary
 
simulated
PostBeginPlay()
 
simulated
SetRoll(vector NewVelocity)


State Flying Function Summary



Source Code


00001	//=============================================================================
00002	// RazorBladeAlt.
00003	//=============================================================================
00004	class RazorBladeAlt extends RazorBlade;
00005	
00006	var vector GuidedVelocity;
00007	var rotator OldGuiderRotation, GuidedRotation;
00008	
00009	replication
00010	{
00011		// Things the server should send to the client.
00012		unreliable if( Role==ROLE_Authority )
00013			GuidedVelocity;
00014	}
00015	
00016	simulated function SetRoll(vector NewVelocity) 
00017	{
00018		local rotator newRot;
00019		newRot = rotator(NewVelocity);
00020		newRot.Roll += 12768;		
00021		SetRotation(newRot);				
00022	}
00023	
00024	simulated function PostBeginPlay()
00025	{
00026		Super.PostBeginPlay();
00027		GuidedRotation = Rotation;
00028		OldGuiderRotation = Rotation;
00029	}
00030	
00031	auto state Flying
00032	{
00033		simulated function Tick(float DeltaTime)
00034		{
00035			local int DeltaYaw, DeltaPitch;
00036			local int YawDiff, PitchDiff;
00037	
00038			if ( Level.NetMode == NM_Client )
00039				Velocity = GuidedVelocity;
00040			else
00041			{
00042				if ( (instigator.Health <= 0) || instigator.IsA('Bot') )
00043				{
00044					Disable('Tick');
00045					return;
00046				}
00047				else
00048				{
00049					DeltaYaw = (instigator.ViewRotation.Yaw & 65535) - (OldGuiderRotation.Yaw & 65535);
00050					DeltaPitch = (instigator.ViewRotation.Pitch & 65535) - (OldGuiderRotation.Pitch & 65535);
00051					if ( DeltaPitch < -32768 )
00052						DeltaPitch += 65536;
00053					else if ( DeltaPitch > 32768 )
00054						DeltaPitch -= 65536;
00055					if ( DeltaYaw < -32768 )
00056						DeltaYaw += 65536;
00057					else if ( DeltaYaw > 32768 )
00058						DeltaYaw -= 65536;
00059	
00060					YawDiff = (Rotation.Yaw & 65535) - (GuidedRotation.Yaw & 65535) - DeltaYaw;
00061					if ( DeltaYaw < 0 )
00062					{
00063						if ( ((YawDiff > 0) && (YawDiff < 16384)) || (YawDiff < -49152) )
00064							GuidedRotation.Yaw += DeltaYaw;
00065					}	
00066					else if ( ((YawDiff < 0) && (YawDiff > -16384)) || (YawDiff > 49152) )
00067						GuidedRotation.Yaw += DeltaYaw;
00068	
00069					GuidedRotation.Pitch += DeltaPitch;
00070	
00071					Velocity += Vector(GuidedRotation) * 2000 * DeltaTime;
00072					speed = VSize(Velocity);
00073					Velocity = Velocity * FClamp(speed,400,750)/speed;
00074					GuidedVelocity = Velocity;
00075					OldGuiderRotation = instigator.ViewRotation;
00076				}
00077			}
00078			SetRotation(Rotator(Velocity) + rot(0,0,12768));
00079		}
00080	
00081		simulated function BeginState()
00082		{
00083			local rotator newRot;
00084	
00085			Super.BeginState();
00086			if ( Role == ROLE_Authority )
00087			{
00088				newRot = instigator.ViewRotation;
00089				newRot.Roll += 12768;
00090				SetRotation(newRot);
00091			}	
00092		}
00093	}
00094	
00095	defaultproperties
00096	{
00097	     bNetTemporary=False
00098	}

End Source Code