Engine
Class Projectile

source: e:\games\UnrealTournament\Engine\Classes\Projectile.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
Direct Known Subclasses:CannonShot, flakslug, MTracer, PBolt, PlasmaSphere, Razor2, RocketMk2, ShockProj, TranslocatorTarget, UTChunk, UTFlakShell, UT_BioGel, UT_Grenade, UT_ShellCase, WarShell, Fragment, BigRock, Chunk, EnergyBolt, FlakShell, ForceFieldProj, GasbagBelch, KraalBolt, PeaceRocket, RazorBlade, Tracer, WarlordRocket, Arc, Arrow, BioGel, BruteProjectile, DispersionAmmo, Grenade, Plasma, rocket, ShellCase, SkaarjProjectile, SlithProjectile, StingerProjectile, TazerProj, TentacleProjectile

class Projectile
extends Engine.Actor

//============================================================================= // Projectile. // // A delayed-hit projectile moves around for some time after it is created. // An instant-hit projectile acts immediately. //=============================================================================
Variables
 float Damage
           Limit on speed of projectile (0 means no limit)
 float ExploWallOut
           distance to move explosions out from wall
 class ExplosionDecal
           distance to move explosions out from wall
 sound ImpactSound
           Sound made when projectile hits something.
 float MaxSpeed
           Limit on speed of projectile (0 means no limit)
 sound MiscSound
           Miscellaneous Sound.
 int MomentumTransfer
           Momentum imparted by impacting projectile.
 name MyDamageType
           Momentum imparted by impacting projectile.
 sound SpawnSound
           Sound made when projectile is spawned.
 float Speed
           Initial speed of projectile.


Function Summary
 bool EncroachingOn(Actor Other)
     
//==============
// Encroachment
 
simulated
Explode(vector HitLocation, vector HitNormal)
 
simulated
HitWall(vector HitNormal, Actor Wall)
 
simulated
ProcessTouch(Actor Other, Vector HitLocation)
 void RandSpin(float spinRate)
 void Touch(Actor Other)
     
//==============
// Touching



Source Code


00001	//=============================================================================
00002	// Projectile.
00003	//
00004	// A delayed-hit projectile moves around for some time after it is created.
00005	// An instant-hit projectile acts immediately. 
00006	//=============================================================================
00007	class Projectile extends Actor
00008		abstract
00009		native;
00010	
00011	#exec Texture Import File=Textures\S_Camera.pcx Name=S_Camera Mips=Off Flags=2
00012	
00013	//-----------------------------------------------------------------------------
00014	// Projectile variables.
00015	
00016	// Motion information.
00017	var() float    Speed;               // Initial speed of projectile.
00018	var() float    MaxSpeed;            // Limit on speed of projectile (0 means no limit)
00019	
00020	// Damage attributes.
00021	var() float    Damage;         
00022	var() int	   MomentumTransfer; // Momentum imparted by impacting projectile.
00023	var() name	   MyDamageType;
00024	
00025	// Projectile sound effects
00026	var() sound    SpawnSound;		// Sound made when projectile is spawned.
00027	var() sound	   ImpactSound;		// Sound made when projectile hits something.
00028	var() sound    MiscSound;		// Miscellaneous Sound.
00029	
00030	var() float		ExploWallOut;	// distance to move explosions out from wall
00031	
00032	// explosion decal
00033	var() class<Decal> ExplosionDecal;
00034	
00035	//==============
00036	// Encroachment
00037	function bool EncroachingOn( actor Other )
00038	{
00039		if ( (Other.Brush != None) || (Brush(Other) != None) )
00040			return true;
00041			
00042		return false;
00043	}
00044	
00045	//==============
00046	// Touching
00047	simulated singular function Touch(Actor Other)
00048	{
00049		local actor HitActor;
00050		local vector HitLocation, HitNormal, TestLocation;
00051		
00052		if ( Other.IsA('BlockAll') )
00053		{
00054			HitWall( Normal(Location - Other.Location), Other);
00055			return;
00056		}
00057		if ( Other.bProjTarget || (Other.bBlockActors && Other.bBlockPlayers) )
00058		{
00059			//get exact hitlocation
00060		 	HitActor = Trace(HitLocation, HitNormal, Location, OldLocation, true);
00061			if (HitActor == Other)
00062			{
00063				if ( Other.bIsPawn 
00064					&& !Pawn(Other).AdjustHitLocation(HitLocation, Velocity) )
00065						return;
00066				ProcessTouch(Other, HitLocation); 
00067			}
00068			else 
00069				ProcessTouch(Other, Other.Location + Other.CollisionRadius * Normal(Location - Other.Location));
00070		}
00071	}
00072	
00073	simulated function ProcessTouch(Actor Other, Vector HitLocation)
00074	{
00075		//should be implemented in subclass
00076	}
00077	
00078	simulated function HitWall (vector HitNormal, actor Wall)
00079	{
00080		if ( Role == ROLE_Authority )
00081		{
00082			if ( (Mover(Wall) != None) && Mover(Wall).bDamageTriggered )
00083				Wall.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), '');
00084	
00085			MakeNoise(1.0);
00086		}
00087		Explode(Location + ExploWallOut * HitNormal, HitNormal);
00088		if ( (ExplosionDecal != None) && (Level.NetMode != NM_DedicatedServer) )
00089			Spawn(ExplosionDecal,self,,Location, rotator(HitNormal));
00090	}
00091	
00092	simulated function Explode(vector HitLocation, vector HitNormal)
00093	{
00094		Destroy();
00095	}
00096	
00097	simulated final function RandSpin(float spinRate)
00098	{
00099		DesiredRotation = RotRand();
00100		RotationRate.Yaw = spinRate * 2 *FRand() - spinRate;
00101		RotationRate.Pitch = spinRate * 2 *FRand() - spinRate;
00102		RotationRate.Roll = spinRate * 2 *FRand() - spinRate;	
00103	}
00104	
00105	defaultproperties
00106	{
00107	     MaxSpeed=2000.000000
00108	     bNetTemporary=True
00109	     bReplicateInstigator=True
00110	     Physics=PHYS_Projectile
00111	     LifeSpan=140.000000
00112	     bDirectional=True
00113	     DrawType=DT_Mesh
00114	     Texture=Texture'Engine.S_Camera'
00115	     bGameRelevant=True
00116	     SoundVolume=0
00117	     CollisionRadius=0.000000
00118	     CollisionHeight=0.000000
00119	     bCollideActors=True
00120	     bCollideWorld=True
00121	     NetPriority=2.500000
00122	}

End Source Code