RuneI
Class GroundProjectile

source: c:\runehov\RuneI\Classes\GroundProjectile.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--RuneI.GroundProjectile
Direct Known Subclasses:None

class GroundProjectile
extends Engine.Projectile

//============================================================================= // GroundProjectile. //=============================================================================
Variables
 int DamageAmount
 float DamageRadius
 name DamageType
 Sound ExplosionSound
 float TimeToExplode


Function Summary
 
simulated
Explode(vector HitLocation, vector HitNormal)
 
simulated
HitWall(vector HitNormal, Actor Wall)
 void HurtRadius2(float DamageAmount, float DamageRadius, name DamageType, float Momentum, vector HitLocation)
     
//
// Hurt actors within the radius.
//
 
simulated
PostBeginPlay()
 
simulated
ProcessTouch(Actor Other, Vector HitLocation)
 
simulated
Tick(float DeltaSeconds)
 
simulated
Timer()



Source Code


00001	//=============================================================================
00002	// GroundProjectile.
00003	//=============================================================================
00004	class GroundProjectile expands Projectile;
00005	
00006	var() int DamageAmount;
00007	var() float DamageRadius;
00008	var() name DamageType;
00009	var() Sound ExplosionSound;
00010	var float TimeToExplode;
00011	
00012	simulated function PostBeginPlay()
00013	{
00014		local actor dust;
00015	
00016		Super.PostBeginPlay();
00017	
00018		dust = Spawn(class'BrownDust',,, Location);
00019		AttachActorToJoint(dust, 0);
00020	
00021		SetTimer(0.1, true);
00022	}
00023	
00024	simulated function Tick(float DeltaSeconds)
00025	{
00026		local vector HitLocation, HitNormal;
00027		local vector extent;
00028	
00029		extent.X = CollisionRadius;
00030		extent.Y = CollisionRadius;
00031		extent.Z = CollisionHeight;
00032	
00033		// Check below the object to see if it should go down slopes/stairs
00034		if(Trace(HitLocation, HitNormal, Location - vect(0, 0, 10), Location, false, extent) == None)
00035		{ // Hit nothing, so destroy the projectile
00036			Explode(Location, vect(0, 0, 1));
00037		}
00038	
00039		TimeToExplode -= DeltaSeconds;
00040		if(TimeToExplode <= 0)
00041			Explode(Location, vect(0, 0, 1));
00042	}
00043	
00044	simulated function Timer()
00045	{
00046		local int i;
00047		local vector loc;
00048		local debris D;
00049		local texture Texture;
00050		local vector Momentum;
00051		local vector center;
00052	
00053		center = GetJointPos(0);
00054	
00055		PrePivot.X = (FRand() - 0.5) * 20;
00056		PrePivot.Y = (FRand() - 0.5) * 20;
00057	
00058		MatterTrace(Location - vect(0, 0, 50), Location,, Texture);
00059		for(i = 0; i < 3; i++)
00060		{
00061			loc = center;
00062			loc.X += (FRand() - 0.5) * 30;
00063			loc.Y += (FRand() - 0.5) * 30;
00064			loc.Z += (FRand() - 0.5) * 10;
00065	
00066			D = Spawn(class'DebrisStone',,,loc);
00067			if (D != None)
00068			{
00069				D.SetSize(0.1 + FRand() * 0.15);
00070				D.SetTexture(Texture);
00071				D.ScaleGlow = 1.5; // Slightly brighter
00072				D.Velocity = VRand() * 80;
00073				D.Velocity.Z = FRand() * 100;
00074			}
00075		}
00076	
00077		SkelGroupSkins[1] = Texture;
00078	}
00079	
00080	simulated function ProcessTouch(Actor Other, Vector HitLocation)
00081	{
00082		if(Other == Owner)
00083			return;
00084	
00085		Explode(HitLocation, -Normal(Velocity));
00086	}
00087	
00088	simulated function HitWall(vector HitNormal, actor Wall)
00089	{
00090		Explode(Location, HitNormal);
00091	}
00092	
00093	//
00094	// Hurt actors within the radius.
00095	//
00096	function HurtRadius2( float DamageAmount, float DamageRadius, name DamageType, float Momentum, vector HitLocation )
00097	{
00098		local actor Victim;
00099		local float damageScale, dist;
00100		local vector dir;
00101		
00102		foreach VisibleCollidingActors( class 'Actor', Victim, DamageRadius, HitLocation )
00103		{
00104			if( Victim != self && Victim != Owner)
00105			{
00106				if(Victim.IsA('ScriptPawn') && ScriptPawn(Victim).bIsBoss)
00107				{ // Radius damage doesn't affect bosses
00108					DamageAmount = 0;
00109				}
00110	
00111				dir = Victim.Location - HitLocation;
00112				dist = FMax(1,VSize(dir));
00113				dir = dir/dist; 
00114				damageScale = 1 - FMax(0,(dist - Victim.CollisionRadius)/DamageRadius);
00115				
00116				Victim.JointDamaged(damageScale * DamageAmount,
00117					Instigator,
00118					Victim.Location - 0.5 * (Victim.CollisionHeight + Victim.CollisionRadius) * dir,
00119					(damageScale * Momentum * dir),
00120					DamageType,
00121					0);
00122			} 
00123		}
00124	}
00125	
00126	simulated function Explode(vector HitLocation, vector HitNormal)
00127	{
00128		PlaySound(ExplosionSound, SLOT_None);
00129		Spawn(class'MechRocketExplosion');
00130		HurtRadius2(Damage, DamageRadius, MyDamageType, Damage * 0.5, Location);
00131		Destroy();
00132	}
00133	
00134	defaultproperties
00135	{
00136	     DamageRadius=200.000000
00137	     ExplosionSound=Sound'WeaponsSnd.PowerUps.aorangepuff01'
00138	     TimeToExplode=2.000000
00139	     Damage=30.000000
00140	     MyDamageType=Blunt
00141	     RemoteRole=ROLE_SimulatedProxy
00142	     DrawType=DT_SkeletalMesh
00143	     DrawScale=1.500000
00144	     ScaleGlow=1.500000
00145	     CollisionRadius=20.000000
00146	     CollisionHeight=8.000000
00147	     Skeletal=SkelModel'objects.Rocks'
00148	}

End Source Code