Engine
Class Projectile

source: c:\runehov\Engine\Classes\Projectile.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
Direct Known Subclasses:Fragment, EnergyBall, GroundProjectile, LightningPowerupBall, MechRocket, Seeker, SpiderBomb

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)
 
simulated
Tick(float DeltaTime)
     
//===================================================================
//
// Tick
//
// RUNE:  Projectile tick checks for actors with collision joints
// in the direction it is travelling.  This is done so that the 
// collision is joint-accurate, and so that shields will absorb the projectile.
//
// Note that the Touch function is still valid and used because projectiles 
// should collide with some actors that do not have collision joints
//===================================================================
 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				ProcessTouch(Other, HitLocation); 
00064			}
00065			else 
00066				ProcessTouch(Other, Other.Location + Other.CollisionRadius * Normal(Location - Other.Location));
00067		}
00068	}
00069	
00070	simulated function ProcessTouch(Actor Other, Vector HitLocation)
00071	{
00072		//should be implemented in subclass
00073	}
00074	
00075	simulated function HitWall (vector HitNormal, actor Wall)
00076	{
00077		if ( Role == ROLE_Authority )
00078		{
00079			if ( (Mover(Wall) != None) && Mover(Wall).bDamageTriggered )
00080				ProcessTouch(Wall, Location);
00081	
00082			if ( (Polyobj(Wall) != None))
00083				ProcessTouch(Wall, Location);
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	//===================================================================
00106	//
00107	// Tick
00108	//
00109	// RUNE:  Projectile tick checks for actors with collision joints
00110	// in the direction it is travelling.  This is done so that the 
00111	// collision is joint-accurate, and so that shields will absorb the projectile.
00112	//
00113	// Note that the Touch function is still valid and used because projectiles 
00114	// should collide with some actors that do not have collision joints
00115	//===================================================================
00116	
00117	simulated function Tick(float DeltaTime)
00118	{
00119		local actor A;
00120		local vector Begin;
00121		local vector End;
00122		local float Extent;
00123		local vector HitLoc, HitNorm;
00124		local int LowMask, HighMask;
00125	
00126		Begin = Location;
00127		End = Location + Velocity * DeltaTime;
00128	
00129		Extent = Max(CollisionRadius, CollisionHeight);
00130	
00131		foreach SweepActors(class'actor', A, Begin, End, Begin, End, Extent,
00132			HitLoc, HitNorm, LowMask, HighMask)
00133		{
00134			// Check if this actor is valid to be struck
00135			if(A == Owner || A.Owner == Owner || A == self || !A.bSweepable)
00136				continue;
00137	
00138			// Hit the first actor encountered
00139			ProcessTouch(A, HitLoc);
00140			return; // Only allow projectiles to strike one actor
00141		}
00142	}
00143	
00144	defaultproperties
00145	{
00146	     MaxSpeed=2000.000000
00147	     bNetTemporary=True
00148	     bReplicateInstigator=True
00149	     Physics=PHYS_Projectile
00150	     LifeSpan=140.000000
00151	     bDirectional=True
00152	     DrawType=DT_Mesh
00153	     Texture=Texture'Engine.S_Camera'
00154	     bGameRelevant=True
00155	     SoundVolume=0
00156	     CollisionRadius=0.000000
00157	     CollisionHeight=0.000000
00158	     bCollideActors=True
00159	     bCollideWorld=True
00160	     NetPriority=2.500000
00161	}

End Source Code