Botpack
Class Pylon

source: e:\games\UnrealTournament\Botpack\Classes\Pylon.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--Botpack.Pylon
Direct Known Subclasses:None

class Pylon
extends Engine.Decoration

//============================================================================= // Pylon. //=============================================================================
Variables
 bool bFirstHit

States
Animate

Function Summary
 void Attach(Actor Other)
 void Bump(Actor Other)
 void Landed(vector HitNormal)
 void StartRotating()
 void Timer()


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	// Pylon.
00003	//=============================================================================
00004	class Pylon extends Decoration;
00005	
00006	#exec MESH IMPORT MESH=PylonM ANIVFILE=MODELS\Pylon_a.3D DATAFILE=MODELS\Pylon_d.3D X=0 Y=0 Z=0 MLOD=0
00007	#exec MESH ORIGIN MESH=PylonM X=0 Y=0 Z=0 YAW=64
00008	#exec MESH SEQUENCE MESH=PylonM SEQ=All    STARTFRAME=0   NUMFRAMES=1
00009	#exec MESH SEQUENCE MESH=PylonM SEQ=Still  STARTFRAME=0   NUMFRAMES=1
00010	#exec TEXTURE IMPORT NAME=JPylon1 FILE=MODELS\Pylon.PCX GROUP=Skins LODSET=2
00011	#exec MESHMAP SCALE MESHMAP=PylonM X=0.04 Y=0.04 Z=0.08
00012	#exec MESHMAP SETTEXTURE MESHMAP=PylonM NUM=0 TEXTURE=JPylon1
00013	
00014	var bool bFirstHit;
00015	
00016	function Attach( Actor Other )
00017	{
00018		Velocity.X = 0;
00019		Velocity.Y = 0;
00020		Velocity.Z = FMin(0, Velocity.Z);
00021	}
00022	
00023	function Timer()
00024	{
00025		SetCollision(true,true,true);
00026	}
00027	
00028	function Bump( actor Other )
00029	{
00030		if( Other.Mass >= 40 )
00031		{
00032			bBobbing = false;
00033			Velocity += 1.5 * VSize(Other.Velocity) * Normal(Location - Other.Location);
00034			if ( Physics == PHYS_None ) 
00035				Velocity.Z = FMax(Velocity.Z,250);
00036			SetPhysics(PHYS_Falling);
00037			SetTimer(0.3,False);
00038			Instigator = Pawn(Other);
00039			SetCollision(true,false,false);
00040			StartRotating();
00041		}
00042	}
00043	
00044	function StartRotating()
00045	{
00046		RotationRate.Yaw = 250000*FRand() - 125000;
00047		RotationRate.Pitch = 250000*FRand() - 125000;
00048		RotationRate.Roll = 250000*FRand() - 125000;	
00049		DesiredRotation = RotRand();
00050		bRotateToDesired=False;
00051		bFixedRotationDir=True;
00052		bFirstHit=True;
00053	}
00054	
00055	function Landed(vector HitNormal)
00056	{
00057		local Rotator NewRot;
00058		Super.Landed(HitNormal);
00059		NewRot = Rotation;
00060		NewRot.Pitch = 18768;
00061		SetRotation(NewRot);
00062	}
00063	
00064	Auto State Animate
00065	{
00066		function HitWall (vector HitNormal, actor Wall)
00067		{
00068			local float speed;
00069	
00070			Velocity = 0.5*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
00071			speed = VSize(Velocity);
00072			if (bFirstHit && speed<400) 
00073			{
00074				bFirstHit=False;
00075				bRotatetoDesired=True;
00076				bFixedRotationDir=False;
00077				DesiredRotation.Yaw=Rand(65535);
00078				DesiredRotation.Pitch=Rand(65535);
00079				DesiredRotation.Roll=0;
00080			}
00081			RotationRate.Yaw = RotationRate.Yaw*0.75;
00082			RotationRate.Roll = RotationRate.Roll*0.75;
00083			RotationRate.Pitch = RotationRate.Pitch*0.75;	
00084			If (speed < 50) 
00085			{
00086				bBounce = False;
00087				DesiredRotation.Yaw = Rotation.Yaw;
00088				DesiredRotation.Roll = Rotation.Roll;
00089				DesiredRotation.Pitch=18768;
00090				SetRotation(DesiredRotation);
00091			}
00092		}	
00093	
00094		function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation, 
00095							Vector momentum, name damageType)
00096		{
00097			if ( StandingCount > 0 )
00098				return;
00099			SetPhysics(PHYS_Falling);
00100			bBounce = True;
00101			Velocity += Momentum/Mass;
00102			Velocity.Z = FMax(Momentum.Z, 200);
00103			StartRotating();
00104		}
00105	}
00106	
00107	defaultproperties
00108	{
00109	     bPushable=True
00110	     bStatic=False
00111	     bNetTemporary=True
00112	     RemoteRole=ROLE_None
00113	     bNet=False
00114	     DrawType=DT_Mesh
00115	     Mesh=Mesh'Botpack.PylonM'
00116	     CollisionRadius=12.000000
00117	     CollisionHeight=8.000000
00118	     bCollideActors=True
00119	     bCollideWorld=True
00120	     bBlockActors=True
00121	     bBlockPlayers=True
00122	     bProjTarget=True
00123	     Mass=35.000000
00124	     Buoyancy=40.000000
00125	}

End Source Code