## Engine
Class Projectile

source: C:\XIII\Engine\Classes\Projectile.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Projectile

Direct Known Subclasses:XIIIProjectile

class Projectile
extends Engine.Actor

    //=============================================================================
    // Projectile.
    //
    // A delayed-hit projectile that moves around for some time after it is created.
    //=============================================================================

Variables
`float` | `Damage`
`float` | `ExploWallOut` distance to move explosions out from wall
`class` | `ExplosionDecal` Sound made when projectile hits something.
`sound` | `ImpactSound` Sound made when projectile hits something.
`float` | `MomentumTransfer` Momentum magnitude imparted by impacting projectile.
`class` | `MyDamageType` Momentum magnitude imparted by impacting projectile.
`sound` | `SpawnSound` Sound made when projectile is spawned.

Function Summary
`simulated` | `BlowUp(vector HitLocation)`
`bool` | `EncroachingOn(Actor Other)`
    //==============
    // Encroachment
`simulated` | `Explode(vector HitLocation, vector HitNormal)`
`vector` | `GetTossVelocity(Pawn P, Rotator R)`
`simulated` | `HitWall(vector HitNormal, Actor Wall)`
`simulated` | `ProcessTouch(Actor Other, Vector HitLocation)`
`void` | `RandSpin(float spinRate)`
`void` | `StaticParseDynamicLoading(LevelInfo MyLI)`
    //_____________________________________________________________________________
`void` | `Touch(Actor Other)`
    //==============
    // Touching

Source Code

    00001	//=============================================================================
    00002	// Projectile.
    00003	//
    00004	// A delayed-hit projectile that moves around for some time after it is created.
    00005	//=============================================================================
    00006	class Projectile extends Actor
    00007		abstract
    00008		native;
    00009
    00010	//-----------------------------------------------------------------------------
    00011	// Projectile variables.
    00012
    00013	// Motion information.
    00014	var		float   Speed;               // Initial speed of projectile.
    00015	var		float   MaxSpeed;            // Limit on speed of projectile (0 means no limit)
    00016	var		float	TossZ;
    00017
    00018	// Damage attributes.
    00019	var   float    Damage;
    00020	var	  float	   DamageRadius;
    00021	var   float	   MomentumTransfer; // Momentum magnitude imparted by impacting projectile.
    00022	var   class<DamageType>	   MyDamageType;
    00023
    00024	// Projectile sound effects
    00025	var   sound    SpawnSound;		// Sound made when projectile is spawned.
    00026	var   sound	   ImpactSound;		// Sound made when projectile hits something.
    00027
    00028	// explosion effects
    00029	var   class<Projector> ExplosionDecal;
    00030	var   float		ExploWallOut;	// distance to move explosions out from wall
    00031
    00032	//_____________________________________________________________________________
    00033	Static function StaticParseDynamicLoading(LevelInfo MyLI);
    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, VelDir;
    00051		local bool bBeyondOther;
    00052		local float BackDist, DirZ;
    00053
    00054		if ( Other.bProjTarget || (Other.bBlockActors && Other.bBlockPlayers) )
    00055		{
    00056			if ( Velocity == vect(0,0,0) )
    00057			{
    00058				ProcessTouch(Other,Location);
    00059				return;
    00060			}
    00061
    00062			//get exact hitlocation - trace back along velocity vector
    00063			bBeyondOther = ( (Velocity Dot (Location - Other.Location)) > 0 );
    00064			VelDir = Normal(Velocity);
    00065			DirZ = sqrt(VelDir.Z);
    00066			BackDist = Other.CollisionRadius * (1 - DirZ) + Other.CollisionHeight * DirZ;
    00067			if ( bBeyondOther )
    00068				BackDist += VSize(Location - Other.Location);
    00069			else
    00070				BackDist -= VSize(Location - Other.Location);
    00071
    00072		 	HitActor = Trace(HitLocation, HitNormal, Location, Location - 1.1 * BackDist * VelDir, true);
    00073			if (HitActor == Other)
    00074				ProcessTouch(Other, HitLocation);
    00075			else if ( bBeyondOther )
    00076				ProcessTouch(Other, Other.Location - Other.CollisionRadius * VelDir);
    00077			else
    00078				ProcessTouch(Other, Location);
    00079		}
    00080	}
    00081
    00082	simulated function ProcessTouch(Actor Other, Vector HitLocation)
    00083	{
    00084		if ( Other != Instigator )
    00085			Explode(HitLocation,Normal(HitLocation-Other.Location));
    00086	}
    00087
    00088	simulated function HitWall (vector HitNormal, actor Wall)
    00089	{
    00090		if ( Role == ROLE_Authority )
    00091		{
    00092			if ( Mover(Wall) != None )
    00093				Wall.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), MyDamageType);
    00094
    00095			MakeNoise(1.0);
    00096		}
    00097		Explode(Location + ExploWallOut * HitNormal, HitNormal);
    00098		if ( (ExplosionDecal != None) && (Level.NetMode != NM_DedicatedServer) )
    00099			Spawn(ExplosionDecal,self,,Location, rotator(-HitNormal));
    00100	}
    00101
    00102	simulated function BlowUp(vector HitLocation)
    00103	{
    00104		HurtRadius(Damage,DamageRadius, MyDamageType, MomentumTransfer, HitLocation );
    00105		if ( Role == ROLE_Authority )
    00106			MakeNoise(1.0);
    00107	}
    00108
    00109	simulated function Explode(vector HitLocation, vector HitNormal)
    00110	{
    00111		Destroy();
    00112	}
    00113
    00114	simulated final function RandSpin(float spinRate)
    00115	{
    00116		DesiredRotation = RotRand();
    00117		RotationRate.Yaw = spinRate * 2 *FRand() - spinRate;
    00118		RotationRate.Pitch = spinRate * 2 *FRand() - spinRate;
    00119		RotationRate.Roll = spinRate * 2 *FRand() - spinRate;
    00120	}
    00121
    00122	static function vector GetTossVelocity(Pawn P, Rotator R)
    00123	{
    00124		local vector V;
    00125
    00126		V = Vector(R);
    00127		V *= ((P.Velocity Dot V)*0.4 + Default.Speed);
    00128		V.Z += Default.TossZ;
    00129		return V;
    00130	}
    00131
    00132	defaultproperties
    00133	{
    00134	     MaxSpeed=2000.000000
    00135	     TossZ=100.000000
    00136	     DamageRadius=220.000000
    00137	     MyDamageType=Class'Engine.DamageType'
    00138	     bInteractive=False
    00139	     bNetTemporary=True
    00140	     bReplicateInstigator=True
    00141	     bUnlit=True
    00142	     bGameRelevant=True
    00143	     bCollideActors=True
    00144	     bCollideWorld=True
    00145	     Physics=PHYS_Projectile
    00146	     RemoteRole=ROLE_SimulatedProxy
    00147	     DrawType=DT_Mesh
    00148	     LifeSpan=140.000000
    00149	     Texture=Texture'Engine.S_Camera'
    00150	     CollisionRadius=0.000000
    00151	     CollisionHeight=0.000000
    00152	     NetPriority=2.500000
    00153	}

End Source Code